-
Notifications
You must be signed in to change notification settings - Fork 107
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
fix(Docker): Pass build args to runtime
images
#7175
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.
This looks good to me, but I think we might also want these env vars:
- SHORT_SHA: tells us which commit Zebra was built from in the logs
zebra/zebrad/src/application.rs
Line 177 in f6afec2
const GIT_COMMIT_GCLOUD: Option<&str> = option_env!("SHORT_SHA"); |
I'd also like Gustavo to review this PR, because he made the last change to this config, and Dockerfiles are his thing.
I added |
Temporary failure on the testnet checkpoints job. |
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.
The only environment variables needed at build time are: RUST_BACKTRACE
, COLORBT_SHOW_HIDDEN
, RUST_LOG
, and CARGO_HOME
.
The ones added here are just environment variables for runtime, not build time.
If we need environment variables available at runtime, then we should add those here:
https://github.com/ZcashFoundation/zebra/blob/main/.github/workflows/continous-delivery.yml#L266
and
https://github.com/ZcashFoundation/zebra/blob/main/.github/workflows/continous-delivery.yml#L367
Most of these environment variables are wrongly defined here as build args: https://github.com/zcashfoundation/zebra/blob/ee54a59ee20fcae73a04f26198146b23ccd0de39/.github/workflows/build-docker-image.yml#L156-L166 (the ones only used at runtime
should be removed from here)
That's why this might be confusing.
zebra/zebrad/src/application.rs Line 177 in f6afec2
(In Rust,
And for completeness, |
My previous reply could be confusing based on how the Dockerfile has been built so far, so I'll reformulate based on @teor2345 answers.
But it should be added here: https://github.com/ZcashFoundation/zebra/blob/main/docker/Dockerfile#L66-L95 in the
Both of these variables have default If the user would like to build with a different value in production, they'd just need to build with ARG FEATURES="default-release-binaries"
ENV FEATURES=${FEATURES}
These can be kept And about the other ones which were added in the PR:
Summarizing:
|
Extra info. This once helped me to understand this better |
We need a way of passing the RPC port from the |
From reading the discussion above, I think we only need the env vars in this PR that are required by |
This was superseded by #7200 |
Motivation
When we create the release binaries in our CI, we pass some params from the release workflow (https://github.com/zcashfoundation/zebra/blob/ee54a59ee20fcae73a04f26198146b23ccd0de39/.github/workflows/release-binaries.yml#L46-L51) to the build workflow (https://github.com/zcashfoundation/zebra/blob/ee54a59ee20fcae73a04f26198146b23ccd0de39/.github/workflows/build-docker-image.yml#L156-L166). The latter then passes the params to Dockerfile as
build-args
. Docker then uses them, and also passes them to thedeps
image as env vars. However, when we create theruntime
image, we cherry-pick only the required binaries and files, and we put them into a fresh image that doesn't contain the env vars from thedeps
image. This also means that the env vars thatruntime-entrypoint.sh
relies on are not set.Depends-On: #7158
Solution
Pick up
ARG
s passed to the Dockerfile forruntime
images and pass them to the image as env vars. Note thatARG
s are scoped (https://docs.docker.com/engine/reference/builder/#scope) betweenFROM
instructions, so we need to declare them separately in theruntime
image.Review
I wasn't completely sure about which env vars to pick and also about the default values. I'd be glad if the reviewers checked that we
Reviewer Checklist