Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Args not resolved in multi-stage build #1911

Closed
gabyx opened this issue Feb 2, 2022 · 2 comments · Fixed by #1928
Closed

[Bug] Args not resolved in multi-stage build #1911

gabyx opened this issue Feb 2, 2022 · 2 comments · Fixed by #1928

Comments

@gabyx
Copy link
Contributor

gabyx commented Feb 2, 2022

Actual behavior
Accessing ARGs in previous stages are not resolved correctly.

Expected behavior
They should be resolved.

To Reproduce

FROM alpine:latest as base
ARG NAME="1234"
RUN echo "base:: $NAME"

FROM base AS base-dev
ARG NAME
RUN echo "dev:: $NAME"

FROM base-dev as base-custom
ARG NAME
RUN echo "custom::" $NAME

Build without specifying --build-arg="...".

Result: custom:: . ($NAME is empty) but should be 1234)

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile
@gabyx
Copy link
Contributor Author

gabyx commented Feb 2, 2022

Related: #1160

@gabyx
Copy link
Contributor Author

gabyx commented Feb 2, 2022

I see that here
only the Meta variables (before the first FROM) are retrieved.

Shouldn't it look also in the build args (for what stands "allowed args" ?)

} else {
		args := ba.GetAllAllowed()
		if value, ok := args[resolvedKey]; ok {
			resolvedValue = &value
		}
		meta := ba.GetAllMeta()
		if value, ok := meta[resolvedKey]; ok {
			resolvedValue = &value
		}
	}

@gabyx gabyx changed the title Args not resolved in multi-stage build [Bug] Args not resolved in multi-stage build Feb 2, 2022
gabyx added a commit to gabyx/kaniko that referenced this issue Feb 7, 2022
- Building multi-stage Dockerfiles did not correctly resolve
  ARG commands over different stages. Now, each stage depends on the
  build arguments set by the stage before.

Closes: GoogleContainerTools#1911
gabyx added a commit to gabyx/kaniko that referenced this issue Feb 8, 2022
- Building multi-stage Dockerfiles did not correctly resolve
  ARG commands over different stages. Now, each stage depends on the
  build arguments set by the stage before.

Closes: GoogleContainerTools#1911
gabyx added a commit to gabyx/kaniko that referenced this issue Feb 8, 2022
- Building multi-stage Dockerfiles did not correctly resolve
  ARG commands over different stages. Now, each stage depends on the
  build arguments set by the stage before.

Closes: GoogleContainerTools#1911
tejal29 pushed a commit that referenced this issue Feb 10, 2022
* Fix resolving argument over mulit-stage build

- Building multi-stage Dockerfiles did not correctly resolve
  ARG commands over different stages. Now, each stage depends on the
  build arguments set by the stage before.

Closes: #1911

* Fix resolving empty arg commands
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 a pull request may close this issue.

1 participant