Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iambryancs/118f99e2a87dcc2e52f72534aaaad3b1 to your computer and use it in GitHub Desktop.
Save iambryancs/118f99e2a87dcc2e52f72534aaaad3b1 to your computer and use it in GitHub Desktop.
Sharing Docker build ARG in multi-stage builds

Sharing Docker build ARG in multi-stage builds

To share Docker build ARGs in a multi-stage build, simply declare it globally then mention it in subsequent builds to renew.

ARG IMG=alpine:3.14.2
FROM gcr.io/kaniko-project/executor:v1.9.0-debug AS kaniko

ARG IMG
FROM ${IMG}
RUN apk --update add \
  bash \
  coreutils \
  jq

COPY --from=kaniko /kaniko/warmer /kaniko/
COPY --from=kaniko /kaniko/executor /kaniko/
COPY --from=kaniko /kaniko/ssl /kaniko/
COPY --from=kaniko /kaniko/docker-credential-ecr-login /kaniko/
COPY --from=busybox:1.32.0 /bin /busybox

ENV PATH $PATH:/usr/local/bin:/kaniko:/busybox
ENV PATH $PATH:/usr/local/bin:/kaniko
ENV DOCKER_CONFIG /kaniko/.docker/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment