-
Notifications
You must be signed in to change notification settings - Fork 336
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
Docker: Mount rust from image at build time instead of downloading it #1522
base: master
Are you sure you want to change the base?
Conversation
pkg/docker/Dockerfile.go1.22
Outdated
@@ -8,30 +10,16 @@ LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installatio | |||
LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers <docker-maint@nginx.com>" | |||
LABEL org.opencontainers.image.version="1.34.0" | |||
|
|||
RUN set -ex \ | |||
RUN --mount=type=bind,target=/rust,from=rust,rw \ |
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.
Because this is from=
a stage, it would be mostly OK, but it's technically not officially supported in the DOI build system / dependency calculation, so adding it makes me a little nervous: https://github.com/docker-library/bashbrew/blob/f71d6ef63e1f5abe6d5cb06a62a3e5e42d68566e/cmd/bashbrew/docker.go#L96-L190
(For example, if we accept this, and then the FROM ... AS rust
gets removed later, we won't necessarily remember the implications of that meaning that this line now implies from=rust:latest
which will "just work" but not be accounted for correctly in our dependency calculations.)
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.
Would using a target that isn't matching an image solve this such as rust-build
?
8e1f00d
to
bbefca2
Compare
Hmm, I think we can just re-use the "minimal" image instead of creating yet another "base" one. I'll try to give it a shot. |
This ensures that rust is not left behind in the image
Instead of rebuilding unitd binaries every time a module image is built, copy them from the minimal image.
We need to have this image built to copy the unitd binaries to the modules images.
This helps to debug the issues.
I've pushed some commits that implement the "mount rust" idea, as well as removing build duplication into https://github.com/thresheek/unit/commits/optimize-docker-take2/. I can create another PR, or force-push to @LaurentGoderre's branch if @LaurentGoderre doesnt mind so we can review them here. I've split the changes into reviewable items, so it should be easier to catch issues this way. One thing I don't like is that the majority of "modules" don't really need a Rust image mounted since they won't be building any Rust code - the only users are |
@thresheek feel free to use my branch however you need! |
bbefca2
to
e846d28
Compare
There we go. Please take a look. |
bbefca2
to
e846d28
Compare
e846d28
to
cd6032e
Compare
@thresheek LGTM! |
This ensures that rust is not left behind in the image