Skip to content

Commit 804939e

Browse files
authored
docker: add STAGE build arg to Dockerfile (#1104)
## Summary - Add `STAGE` build arg to the root Dockerfile so the compiler bootstrap stage is configurable (default: 0) - Forward `STAGE` env var from `docker_build.sh` to the `skiplang` and `skip` bake targets - Usage: `STAGE=1 bin/docker_build.sh skiplang` ## Test plan - [x] Verified `STAGE=1 bin/docker_build.sh --dry-run skiplang` passes `--set skiplang.args.STAGE=1` to bake - [x] Verified default (no STAGE) doesn't add any extra args - [x] Verified full build succeeds with default STAGE 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents c17a839 + a044d1f commit 804939e

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ ENV CXX=clang++
1313

1414
FROM skiplang-base AS bootstrap
1515

16+
ARG STAGE=0
1617
COPY ./skiplang /work
1718

1819
WORKDIR /work/compiler
19-
RUN make clean && make STAGE=0
20+
RUN make clean && make STAGE=$STAGE
2021

2122
FROM skiplang-base AS skiplang
2223

23-
COPY --link --from=bootstrap /work/compiler/stage0/bin/ /usr/bin/
24-
COPY --link --from=bootstrap /work/compiler/stage0/lib/ /usr/lib/
24+
ARG STAGE=0
25+
COPY --link --from=bootstrap /work/compiler/stage${STAGE}/bin/ /usr/bin/
26+
COPY --link --from=bootstrap /work/compiler/stage${STAGE}/lib/ /usr/lib/
2527

2628
FROM skiplang AS skip
2729

bin/docker_build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
# --arch PLAT Override platform(s). Shorthands: amd, amd64, arm, arm64.
2020
# Comma-separated for multiple. Default depends on mode.
2121
#
22+
# Environment variables:
23+
# STAGE Compiler bootstrap stage (default: 0). Passed as STAGE build
24+
# arg to the root Dockerfile (skiplang/skip targets).
25+
#
2226
# Images (if none specified, builds all applicable images):
2327
# skiplang Dockerfile --target skiplang
2428
# skiplang-bin-builder skiplang/Dockerfile
@@ -189,6 +193,11 @@ else
189193
fi
190194
fi
191195

196+
# Pass STAGE build arg to targets using the root Dockerfile
197+
if [[ -n "${STAGE:-}" ]]; then
198+
BAKE_ARGS+=(--set "skiplang.args.STAGE=$STAGE" --set "skip.args.STAGE=$STAGE")
199+
fi
200+
192201
# Determine which bake targets to build
193202
BAKE_TARGETS=()
194203

0 commit comments

Comments
 (0)