Skip to content

Allow using an arbitrary Docker image instead of forcing crates-build-env #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2020

Conversation

pietroalbini
Copy link
Member

While Rustwide technically already allows to run a build with an arbitrary container image, it forces you to use (a fork of) crates-build-env as it integrated with it (through the MAP_USER_ID environment variable) to drop privileges inside the container.

This PR lifts that restriction by using Docker's --user flag to drop privileges, instead of the entrypoint in crates-build-env.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2020-07-03T12:57:36.9284918Z [INFO  rustwide::cmd] running `Command { std: "docker" "create" "-v" "/home/runner/work/rustwide/rustwide/.workspaces/integration/builds/out-of-memory/target:/opt/rustwide/target:rw,Z" "-v" "/home/runner/work/rustwide/rustwide/.workspaces/integration/builds/out-of-memory/source:/opt/rustwide/workdir:ro,Z" "-v" "/home/runner/work/rustwide/rustwide/.workspaces/integration/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/home/runner/work/rustwide/rustwide/.workspaces/integration/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "536870912" "--user" "1001:116" "--network" "none" "rustops/crates-build-env@sha256:819119df93c0f5eca3f29186f14981ef29945a311854d7222af07488600a2584" "/opt/rustwide/cargo-home/bin/cargo" "+stable" "run", kill_on_drop: false }`
2020-07-03T12:57:36.9285260Z [INFO  rustwide::cmd] [stdout] 6ed676cd022fb006c0792904bc334784e6ff9d87a9a45ce4ee0f6f5d84b84737
2020-07-03T12:57:36.9285852Z [INFO  rustwide::cmd] running `Command { std: "docker" "start" "-a" "6ed676cd022fb006c0792904bc334784e6ff9d87a9a45ce4ee0f6f5d84b84737", kill_on_drop: false }`
2020-07-03T12:57:36.9286362Z [INFO  rustwide::cmd] [stderr] /opt/crates-build-env/entrypoint.sh: line 7: /etc/hosts: Permission denied
2020-07-03T12:57:36.9286831Z [INFO  rustwide::cmd] [stderr]    Compiling out-of-memory v0.1.0 (/opt/rustwide/workdir)
2020-07-03T12:57:36.9286991Z [INFO  rustwide::cmd] [stderr]     Finished dev [unoptimized + debuginfo] target(s) in 0.28s
2020-07-03T12:57:36.9287457Z [INFO  rustwide::cmd] [stderr]      Running `/opt/rustwide/target/debug/out-of-memory`
2020-07-03T12:57:36.9287633Z [INFO  rustwide::cmd] running `Command { std: "docker" "inspect" "6ed676cd022fb006c0792904bc334784e6ff9d87a9a45ce4ee0f6f5d84b84737", kill_on_drop: false }`
2020-07-03T12:57:36.9288497Z [INFO  rustwide::cmd] running `Command { std: "docker" "rm" "-f" "6ed676cd022fb006c0792904bc334784e6ff9d87a9a45ce4ee0f6f5d84b84737", kill_on_drop: false }`
2020-07-03T12:57:36.9288677Z [INFO  rustwide::cmd] [stdout] 6ed676cd022fb006c0792904bc334784e6ff9d87a9a45ce4ee0f6f5d84b84737
2020-07-03T12:57:36.9289477Z thread 'buildtest::test_sandbox_oom' panicked at 'didn't get the error CommandError::SandboxOOM', tests/buildtest/mod.rs:79:13

Not sure if the /etc/hosts failure is relevant. The user is being passed, as is the memory limit ... not sure what's going wrong.

@pietroalbini
Copy link
Member Author

🎉

@pietroalbini pietroalbini merged commit d2449fb into master Aug 8, 2020
@pietroalbini pietroalbini deleted the docker-user branch August 8, 2020 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants