Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LaurentGoderre
Copy link

This ensures that rust is not left behind in the image

@@ -8,30 +10,16 @@ LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installatio
LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers <[email protected]>"
LABEL org.opencontainers.image.version="1.34.0"

RUN set -ex \
RUN --mount=type=bind,target=/rust,from=rust,rw \
Copy link

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.)

Copy link
Author

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?

@@ -1,3 +1,5 @@
FROM rust:1.83.0-bookworm AS rust
Copy link

Choose a reason for hiding this comment

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

The rust image only maintains a single version at any given time, so this is only reasonable if it's going to be proactively kept up-to-date. 😬

@LaurentGoderre LaurentGoderre force-pushed the optimize-docker branch 5 times, most recently from 2c9ba88 to 8e1f00d Compare December 24, 2024 17:20
This ensures that rust is not left behind in the image
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