我正在尝试构建具有以下阶段的多阶段 dockerfile,但所有阶段都在执行。
即使我EXECUTION_ENV=local
在 docker build中指定了,我总是 c git clone 正在执行
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 试过:
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.
注意:
如果我"features": { "buildkit": true}
在 docker daemon 中启用并运行 cmd docker build -t somecontainer --build-arg GIT_TOKEN=abc:123 --build-arg EXECUTION_ENV=local.
,我会收到以下错误
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