I am trying to build a multistage dockerfile with following stage but all stages are getting executed.
I always c that git clone is getting executed even if I have specified EXECUTION_ENV=local
in the docker build
Dockerfile:
ARG GIT_TOKEN=abc:1a2b3
ARG EXECUTION_ENV=local
# get dependencies from github
FROM alpine/git as gitclone-ci
WORKDIR /usr/src/
RUN git clone https://{GIT_USER_TOKEN}@github.com/something.git \
&& git clone https://{GIT_USER_TOKEN}@github.com/somethingelse.git
## in local dependencies are already available in the parent folder
FROM alpine/git as gitclone-local
WORKDIR /usr/src/
COPY ../something /usr/src/something
COPY ../somethingelse /usr/src/somethingelse
FROM node:latest as builder
WORKDIR /usr/src
COPY --from=gitclone-${EXECUTION_ENV} /usr/src .
COPY package* ./
COPY src/ src/
RUN ["npm", "install"]
Docker build cmds tried:
docker build -t somecontainer --build-arg GIT_TOKEN=abc:123 --build-arg EXECUTION_ENV=local.
docker build -t somecontainer --target builder --build-arg GIT_TOKEN=abc:123 --build-arg EXECUTION_ENV=local.
Note:
If I enable "features": { "buildkit": true}
in the docker daemon and run the cmd docker build -t somecontainer --build-arg GIT_TOKEN=abc:123 --build-arg EXECUTION_ENV=local.
I get the following error
failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to parse stage name "gitclone-$EXECUTION_ENV": invalid reference format: repository name must be lowercase