moby / buildkit

concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit
https://github.com/moby/moby/issues/34227
Apache License 2.0
7.85k stars 1.09k forks source link

Initialize build args from stage base #5048

Closed daghack closed 2 weeks ago

daghack commented 2 weeks ago

Currently, when we initialize a new dispatchState, buildArgs are not carried forward from the base. This causes a subtle issue while linting where a Dockerfile such as

FROM alpine AS declared
ARG foo
COPY $foo .

FROM declared AS dependent
COPY $foo .

Will erroneously emit a UndeclaredVariable linting warning for the occurrence of $foo in the dependent stage.

This updates dispatchState to initialize buildArgs from its base.