Skip to content

orbit: switch production/dev toggle from environment to ARG#31

Merged
theyoyojo merged 1 commit into
masterfrom
env_to_arg
Mar 19, 2024
Merged

orbit: switch production/dev toggle from environment to ARG#31
theyoyojo merged 1 commit into
masterfrom
env_to_arg

Conversation

@charliemirabile

Copy link
Copy Markdown
Contributor

By passing the value as an environment variable in the compose file it trashes the cache of all layers because that environment variable has to be set for all commands in all layers and could affect their behavior. This forces the builder to re-run everything including installing packages, building pip wheels etc. Since there are only two values, it isn't so bad -- once you have built with each at least once you will have a cache of both, but there is no reason to have two versions of each layer in the cache when really we only want to have it apply to the runtime environment. Passing the value as a build arg instead allows it to interact more carefully with the cache. Layers before the arg is mentioned in the Containerfile are blissfully unaware of it and because we really only want it for runtime, it can go right at the end and be used with an ENV instruction to introduce that environment variable for the only step that needs to be aware of it and rerun: setting the CMD.

Fixes: 8bfc3ca ("orbit: specify production config boolean via appropriate container-compose")

By passing the value as an environment variable in the compose file
it trashes the cache of all layers because that environment variable
has to be set for all commands in all layers and could affect their
behavior. This forces the builder to re-run everything including
installing packages, building pip wheels etc. Since there are only two
values, it isn't so bad -- once you have built with each at least once
you will have a cache of both, but there is no reason to have two versions
of each layer in the cache when really we only want to have it apply to
the runtime environment. Passing the value as a build arg instead allows
it to interact more carefully with the cache. Layers before the arg is
mentioned in the Containerfile are blissfully unaware of it and because
we really only want it for runtime, it can go right at the end and be
used with an ENV instruction to introduce that environment variable for
the only step that needs to be aware of it and rerun: setting the CMD.

Fixes: 8bfc3ca ("orbit: specify production config boolean via appropriate container-compose")

@theyoyojo theyoyojo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice

@theyoyojo theyoyojo merged commit f668b0e into master Mar 19, 2024
@theyoyojo theyoyojo deleted the env_to_arg branch March 19, 2024 18:23
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