Multi stage build fails when referencing a previous stage with ARG #747
Labels
area/dockerfile-command
For all bugs related to dockerfile file commands
area/multi-stage builds
issues related to kaniko multi-stage builds
kind/bug
Something isn't working
kind/enhancement
New feature or request
priority/p2
High impact feature/bug. Will get a lot of users happy
Milestone
TLDR
FROM <previous-stage-alias>-${SOME_ARG}
fails Kaniko.This issue presents a special case of #233 where the stage alias contains a reference to an
ARG
, a pattern supported by docker & BuildKit.Actual behavior
A handy feature of Multistage builds is the ability to dynamically select a base stage in later stages:
In the above example, when
VARIANT
is set to dev, the final image will inherit frombase-dev
. This pattern works great on stock Docker & BuildKit (which even skips unused branches, likebase-prod
, to speed up the build further). However, on Kaniko, the above build will failVARIANT=dev
:But, if we replace
FROM base-${VARIANT}
with a hardcodedFROM base-dev
, everything is resolved correctly, though it renders the dynamic base picking useless.So, it seems that Kaniko doesn't properly resolve stage aliases when they contain an ARG expression.
Expected behavior
Kaniko should correctly handle
FROM <previous-stage-name>-${SOME_ARG}
instructions.To Reproduce
Steps to reproduce the behavior:
docker
(should succeed)Additional Information
As presented in the example above.
--build-arg VARIANT=dev
gcr.io/kaniko-project/executor@sha256:78d44ec4e9cb5545d7f85c1924695c89503ded86a59f92c7ae658afa3cff5400
The text was updated successfully, but these errors were encountered: