-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Remove proxy/Dockerfile-deps #279
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By my reading of this, my default build command will become:
DOCKER_TRACE=1 BUILD_UNOPTIMIZED=1 SKIP_TESTS=1 bin/mkube bin/docker-build
...BUILD_UNOPTIMIZED
and SKIP_TESTS
are both nice build improvements. Can we consider making bin/docker-build
leverage these build behaviors by default? CI and more official release scripts seem like better places to explicitly flip switches like these with more verbose commands.
Got a build error around conduit-grpc
, perhaps something broke in the PR split:
$ DOCKER_TRACE=1 time bin/docker-build
...
Removing intermediate container 90b45479bf82
Step 38/54 : RUN if [ -n "$BUILD_UNOPTIMIZED" ]; then cargo build -p conduit-grpc --features=arbitrary --frozen ; else cargo build -p conduit-grpc --features=arbitrary --frozen --release ; fi
---> Running in 5c9e6110f2ab
error: package id specification `conduit-grpc` matched no packages
The command '/bin/sh -c if [ -n "$BUILD_UNOPTIMIZED" ]; then cargo build -p conduit-grpc --features=arbitrary --frozen ; else cargo build -p conduit-grpc --features=arbitrary --frozen --release ; fi' returned a non-zero code: 101
bin/docker-build
Outdated
|
||
bin/docker-build-proxy \ | ||
--build-arg="SKIP_TESTS=${SKIP_TESTS:-}" \ | ||
--build-arg="BUILD_UNOPTIMIZED=${PROXY_UNOPTIMIZED:-}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we settle on one of BUILD_UNOPTIMIZED
/ PROXY_UNOPTIMIZED
. i'd prefer the latter as it more explicitly affects the proxy build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the context of proxy/Dockerfile, it's weird to have PROXY_UNOPTIMIZED, as it relates to much more than just the proxy. In the context of bin/docker-build, BUILD_UNOPTIMIZED is too generic. I suppose we can just use PROXY_UNOPTIMIZED but i think it's weird...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with siggy.
proxy/Dockerfile
Outdated
# | ||
# Mocks out all local code and fetch external dependencies to ensure that external sources | ||
# are cached. | ||
FROM $RUST_IMAGE as fetch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how actionable this is, or how much it will affect build performance, but these multistage builds come at some cost to disk space:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gcr.io/runconduit/proxy git-03261aaf c0a0a95e20f9 6 minutes ago 109 MB
<none> <none> aa25ba002caa 6 minutes ago 2.02 GB
<none> <none> a59dda926066 44 minutes ago 1.93 GB
<none> <none> 064aba0af483 46 minutes ago 1.88 GB
<none> <none> ee978ff534a7 50 minutes ago 1.78 GB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least we're no longer trying to ship these intermediates around the network ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem unfortunate that there is so much disk space being used but I think we can improve that later.
I'm wary of using BUILD_UNOPTIMIZED by default. It results in much worse proxy performance. It'd be terrible for one of these builds to get used unintentionally. I'm specifically worried about having to set additional flags when doing a release... |
.travis.yml
Outdated
|
||
script: | ||
- bin/docker-build | ||
- SKIP_TESTS=1 bin/docker-build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous version of this PR I asked why we're skipping the tests here and you said we're skipping them because the tests have already been run at this point. At least let's add a comment mentioning that here.
I also filed #280 to clean this up, as I don't think we should continue to maintain without-Docker and with-Docker build scripts going forward.
.travis.yml
Outdated
|
||
after_success: | ||
- bin/docker-push-deps | ||
- bin/docker-push $CONDUIT_TAG | ||
- bin/docker-retag-all $CONDUIT_TAG master && bin/docker-push master | ||
- target/cli/linux/conduit install --conduit-version=$CONDUIT_TAG |tee conduit.yml | ||
- target/cli/linux/conduit install --version=$CONDUIT_TAG |tee conduit.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a bad merge; didn't we just rename --version
to --conduit-version
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--conduit-version
bin/docker-build
Outdated
|
||
bin/docker-build-proxy \ | ||
--build-arg="SKIP_TESTS=${SKIP_TESTS:-}" \ | ||
--build-arg="BUILD_UNOPTIMIZED=${PROXY_UNOPTIMIZED:-}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with siggy.
proxy/Dockerfile
Outdated
# | ||
# Mocks out all local code and fetch external dependencies to ensure that external sources | ||
# are cached. | ||
FROM $RUST_IMAGE as fetch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem unfortunate that there is so much disk space being used but I think we can improve that later.
proxy/Dockerfile
Outdated
FROM gcr.io/runconduit/proxy-deps:673c53de as build | ||
# Mocks proxy sources to ensure that dependencies, including build-time dependencies | ||
# needed to generate the bindings, are cached. | ||
FROM $RUST_IMAGE as grpc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment about why this is a separate named stage, instead of just being the end of the previous stage or the beginning of the next stage. (AFAICT Docker will cache things about the same whichever way is chosen.)
proxy/Dockerfile
Outdated
## Build libraries. | ||
# | ||
# Mocks proxy sources and gRPC bindings to ensure that dependencies are cached. | ||
FROM $RUST_IMAGE as libs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment about why this is a separate named stage, instead of just being the end of the previous stage.
It seems like everything should work just fine if fetch
and libs
were combined into a single stage. Am I overlooking something?
To clarify my previous comments, it's unclear why our Dockerfiles here are so much more complicated than what's described at rust-lang/cargo#2644 and https://whitfin.io/speeding-up-rust-docker-builds/. I would love to see them simplified so that it's easier for Docker non-exports (i.e. myself) to understand and maintain them. However, if the extra complication actually does have significant benefits then those benefits should be documented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, still broken...
$ DOCKER_TRACE=1 time bin/docker-build
...
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Doc-tests conduit-proxy
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
---> 3a5477cab8b3
Removing intermediate container c3b9c66e85cd
Step 50/54 : RUN if [ -z "$BUILD_OPTIMIZED" ]; then mv target/debug/conduit-proxy target/conduit-proxy ; else mv target/release/conduit-proxy target/conduit-proxy ; fi
---> Running in 98a38b1c83cb
mv: cannot stat 'target/debug/conduit-proxy': No such file or directory
The command '/bin/sh -c if [ -z "$BUILD_OPTIMIZED" ]; then mv target/debug/conduit-proxy target/conduit-proxy ; else mv target/release/conduit-proxy target/conduit-proxy ; fi' returned a non-zero code: 1
1187.08 real 10.57 user 3.50 sys
|
261b1ae
to
bf1a041
Compare
To summarize an offline conversation with @siggy:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
per offline convo, we should move away from explicit env vars like SKIP_TESTS
and PROXY_UNOPTIMIZED
, in favor of simply passing docker build args into the docker-build*
scripts.
.travis.yml
Outdated
|
||
after_success: | ||
- bin/docker-push-deps | ||
- bin/docker-push $CONDUIT_TAG | ||
- bin/docker-retag-all $CONDUIT_TAG master && bin/docker-push master | ||
- target/cli/linux/conduit install --conduit-version=$CONDUIT_TAG |tee conduit.yml | ||
- target/cli/linux/conduit install --version=$CONDUIT_TAG |tee conduit.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--conduit-version
@siggy I reverted my changes to docker-build-proxy so that it behaves like other docker-build scripts today. If we want to change the behavior of these later, we can revisit that. (Too large a change to make now.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
$ time env PROXY_UNOPTIMIZED=1 SKIP_TESTS=1 DOCKER_TRACE=1 bin/docker-build-proxy
...
real 0m13.040s
user 0m1.465s
sys 0m0.461s
The current proxy Dockerfile configuration does not cache dependencies well, which can increase build times substantially. By carefully splitting proxy/Dockerfile into several stages that mock parts of the project, dependencies may be built and cached in Docker such that changes to the proxy only require building the conduit-proxy crate. Furthermore, proxy/Dockerfile now runs the proxy's tests before producing an artifact, unless the `SKIP_TESTS` build-arg is set and not-empty. The `BUILD_UNOPTIMIZED` build-arg has been added to support quicker, debug-friendly builds. `bin/docker-build-proxy` has been changed to admit arbitrary command-line arguments that are passed to `docker`.
This reduces build times by avoiding extra COPYing of large target dirs and results in fewer images with lesser total size.
Remove changes to docker-build-proxy, so it behaves like all other docker-builds.
2d75508
to
1f2b36b
Compare
The current proxy Dockerfile configuration does not cache dependencies well, which can increase build times substantially.
By carefully splitting proxy/Dockerfile into several stages that mock parts of the project, dependencies may be built and cached in Docker such that changes to the proxy only require building the conduit-proxy crate.
Furthermore, proxy/Dockerfile now runs the proxy's tests before producing an artifact, unless the
SKIP_TESTS
build-arg is set and not-empty.The
BUILD_UNOPTIMIZED
build-arg has been added to support quicker, debug-friendly builds.bin/docker-build-proxy
has been changed to admit arbitrary command-line arguments that are passed todocker
.