You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4c945db
Browse filesBrowse the repository at this point in the historyBrowse files
fix(build): let a builder stage inherit its base stage's platform
The cross-compile check read only the literal FROM line, so a stage
built FROM an earlier --platform=$BUILDPLATFORM stage counted as
emulated even though it runs natively. The shadowbox webpack stage is
such a stage, and it failed the check on main.
The check now follows FROM <stage> to its base and inherits its
platform. ARCH_NEUTRAL also accepts "<file>:<stage>", so the webpack
stage can be marked as producing no architecture without excusing the
Go stage in the same Dockerfile. A lookup failure now fails the stage
instead of passing it.
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <[email protected]>
printf'%s\n''FROM golang AS builder''RUN --mount=type=cache,target=/root/.cache go build .'>"$fixture"
84
103
out="$(stages "$fixture")"
85
104
rm -f "$fixture"
86
-
[ "$out"="1 0 FROM golang AS builder" ]
105
+
[ "$out"="1 0 0 builder FROM golang AS builder" ]
106
+
}
107
+
108
+
@test "a stage built FROM an earlier BUILDPLATFORM stage runs on the build platform too" {
109
+
fixture="$(mktemp)"
110
+
printf'%s\n''FROM --platform=$BUILDPLATFORM node AS source''RUN true''FROM source AS app''RUN npm ci''FROM node AS emulated''RUN npm ci''FROM emulated AS child''RUN go build .'>"$fixture"
111
+
out="$(stages "$fixture")"
112
+
rm -f "$fixture"
113
+
[ "$(printf '%s\n'"$out"| sed -n 2p)"="1 0 1 app FROM source AS app" ]
114
+
[ "$(printf '%s\n'"$out"| sed -n 3p)"="1 0 0 emulated FROM node AS emulated" ]
115
+
# A stage built from an emulated stage stays emulated.
116
+
[ "$(printf '%s\n'"$out"| sed -n 4p)"="1 0 0 child FROM emulated AS child" ]
117
+
}
118
+
119
+
@test "an arch-neutral stage entry excuses only that stage" {
0 commit comments