Skip to content

build(docker): pin base stage to $BUILDPLATFORM for cross-compilation#89

Merged
RedStar071 merged 1 commit into
mainfrom
build/pin-buildplatform
Jul 3, 2026
Merged

build(docker): pin base stage to $BUILDPLATFORM for cross-compilation#89
RedStar071 merged 1 commit into
mainfrom
build/pin-buildplatform

Conversation

@RedStar071

@RedStar071 RedStar071 commented Jul 3, 2026

Copy link
Copy Markdown
Member

Cosa cambia

Pinna lo stage base del Dockerfile a --platform=$BUILDPLATFORM, come indicato nella sezione cross-compilation della guida Docker: lo stage di build (pnpm install + pnpm run build + prisma:generate) gira sempre sull'architettura nativa del builder, mai sotto emulazione, indipendentemente dalla strategia di runner usata in CI. Lo stage runner (finale) resta senza pin, quindi continua a targettare la piattaforma di build effettiva — dove infatti viene già rieseguito pnpm install --prod, che ricompila correttamente eventuali binding nativi per quella architettura.

Con i runner Blacksmith nativi per-arch introdotti in wolfstar-project/.github#35 questo è oggi un no-op (BUILDPLATFORM coincide già con la piattaforma target in ogni job della matrix), ma allinea il Dockerfile alla pratica raccomandata e lo mette al riparo nel caso si torni in futuro a un builder singolo multi-platform.

https://claude.ai/code/session_01Xv1EAagQkhuCRGY584Kuua


View with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is enabled.

T-Rex T-Rex Logs

What T-Rex did

  • Executed environment checks for Docker and container tooling to verify local execution capabilities; Docker is not installed and no usable local container builders are available.
  • Compared the base image handling across commits to validate platform binding; the pre-change state lacked a platform directive and resolved to linux/arm64 with native_builder_execution=no, while the post-change state adds --platform and resolves to linux/amd64 with native_builder_execution=yes and target_emulation_risk=no.

View all artifacts

T-Rex Ran code and verified through T-Rex

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant BuildKit
participant Base as base stage<br/>--platform=$BUILDPLATFORM
participant Builder as builder stage
BuildKit->>Base: Pull node:24-alpine for BUILDPLATFORM
Base->>Builder: FROM base
Builder->>Builder: pnpm install + prisma:generate + build
Base->>Runner: FROM base
Runner->>Runner: pnpm install --prod on inherited platform
Runner-->>BuildKit: Final image uses inherited base platform
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant BuildKit
participant Base as base stage<br/>--platform=$BUILDPLATFORM
participant Builder as builder stage
BuildKit->>Base: Pull node:24-alpine for BUILDPLATFORM
Base->>Builder: FROM base
Builder->>Builder: pnpm install + prisma:generate + build
Base->>Runner: FROM base
Runner->>Runner: pnpm install --prod on inherited platform
Runner-->>BuildKit: Final image uses inherited base platform
Loading

Fix All in Claude Code Fix All in Cursor Fix All in Cursor Cloud Agents

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
Dockerfile:52
**Final stage remains pinned**
`runner` is still `FROM base`, so it reuses the stage declared on line 7 with `--platform=$BUILDPLATFORM`; the final image no longer targets Docker's default target platform when `BUILDPLATFORM != TARGETPLATFORM`. Docker's cross-compilation example keeps only the build stage pinned and starts the runtime stage from a fresh target-platform base, so this change makes `pnpm install --prod` run on the builder architecture and can publish the wrong-architecture runtime image.

Reviews (1): Last reviewed commit: "build(docker): pin base stage to $BUILDP..." | Re-trigger Greptile

Per the Docker multi-platform guide's cross-compilation section, pin the
base/builder stage to the builder's native platform so the pnpm install
and build steps never run under emulation, regardless of which runner
strategy builds the image. The runner (final) stage is left unpinned so
it always targets the actual build platform.

Claude-Session: https://claude.ai/code/session_01Xv1EAagQkhuCRGY584Kuua
@RedStar071
RedStar071 merged commit 3a9721c into main Jul 3, 2026
8 checks passed
@RedStar071
RedStar071 deleted the build/pin-buildplatform branch July 3, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant