-
Notifications
You must be signed in to change notification settings - Fork 341
Description
Giving a simple Dockerfile example, leveraging the TARGETARCH automatic variable provided in the global scope by buildkit:
ARG APT_FLAGS="-y -qq --no-install-recommends --no-install-suggests"
FROM node AS base-arm64
ONBUILD ARG PACKAGES="\
build-essential \
python3 \
"
FROM node AS base-amd64
ONBUILD ARG PACKAGES=""
FROM base-${TARGETARCH} AS base
apt-get install ${APT_FLAGS} ${PACKAGES}
# do common stuffThe TARGETARCH global scope variable (Nor for that matter any others) does not seem available for replacement when searching the base image in the findBaseImage function called by internalGetImageBuildInfoFromDockerfile during the build
cli/src/spec-node/dockerfileUtils.ts
Line 95 in f3be29d
| export function findBaseImage(dockerfile: Dockerfile, buildArgs: Record<string, string>, target: string | undefined) { |
in our case ending up returning the value base- which does not exist and then fails:
[1197 ms] Start: Run: docker inspect --type image base-
[3802 ms] Error fetching image details: No manifest found for docker.io/library/base-.
[3802 ms] Start: Run: docker pull base-
invalid reference format
[3903 ms] []
[3903 ms] Error response from daemon: no such image: base-: invalid reference format
Also, another issue I found along the way when inspecting available values, parsing does not handle quoted values (nor multilines). Based on the previous Dockerfile example, we end up in the provided replacements to replaceVariables function with:
// [...]
{ instruction: 'ARG', name: 'APT_FLAGS', value: '"-y' },
{ instruction: 'ARG', name: 'PACKAGES', value: '"\\' },
// [...]