charliecloud icon indicating copy to clipboard operation
charliecloud copied to clipboard

validate metadata flow in multi-stage build

Open reidpr opened this issue 3 years ago • 2 comments

When the interpreter executes the 2nd and subsequent FROM in a multi-stage Dockerfile, where is the image metadata (e.g. build environment from ARG and ENV) supposed to come from? I.e., the previous stage, the base image, a merger of the two? I'm not sure we've checked this.

reidpr avatar May 17 '22 20:05 reidpr

The Dockerfile reference suggests it's the base image:

An ARG instruction goes out of scope at the end of the build stage where it was defined. To use an arg in multiple stages, each stage must include the ARG instruction.

That documentation doesn't say for ENV, but this GitHub issue comment says that's the ENV behavior as well.

I think we do this already, but add a test?

However, the comment also says that global ARG, i.e. before any FROM, does apply to all stages. That would require a merge (and make the build cache not a tree).

reidpr avatar May 17 '22 20:05 reidpr

See also issue #779.

reidpr avatar May 17 '22 22:05 reidpr