softprops / lambda-rust

🐳 🦀 a dockerized lambda build env for rust applications
MIT License
162 stars 76 forks source link

Run build.sh as a normal user #62

Closed medwards closed 4 years ago

medwards commented 4 years ago

The docker container runs as root so mounting registry and git in the container results in pollution of a users .cargo folder with root-owned artifacts. Trying to do things like cargo update will then break.

Instead run the container as a normal user.

Requires pulling the cargo install out of /root. Also the yum install step won't work when running as a normal user. When run in the test suite the container will recompile the project even though it doesn't have to (I haven't figured out why, when I docker run by hand in the test folder it works as expected (finishes compilation in less than a second because its already done).

Note: this will still write ~/.cargo/registry and ~/.cargo/git as owned by root if they don't exist when the container runs. May be due to -v mounts ignoring -u when the mountpoint doesn't exist.

medwards commented 4 years ago

When run in the test suite the container will recompile the project even though it doesn't have to (I haven't figured out why, when I docker run by hand in the test folder it works as expected (finishes compilation in less than a second because its already done).

Oh this is nasty, the old behaviour (tests not doing a full recompile on the second release build) is actually a bug due to the target folder being owned by root. It's supposed to clean up the target folder before every build but since the tests didn't have permissions the old target folder remained.

softprops commented 4 years ago

Thanks for spotting this. I'll take a closer look soon