underground-software / singularity

KDLP: Beyond the event horizon
https://kdlp.underground.software
GNU General Public License v3.0
0 stars 0 forks source link

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

Closed charliemirabile closed 3 months ago

charliemirabile commented 3 months ago

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