Skip to content

fix(ci): add linux/arm64 Docker build with QEMU optimization#76

Merged
AnsoCode merged 1 commit into
developfrom
feat/arm64-docker-build
Mar 24, 2026
Merged

fix(ci): add linux/arm64 Docker build with QEMU optimization#76
AnsoCode merged 1 commit into
developfrom
feat/arm64-docker-build

Conversation

@AnsoCode

Copy link
Copy Markdown
Collaborator

Problem

Adding platforms: linux/amd64,linux/arm64 to the Docker publish workflow caused the job to hit the 6-hour GitHub Actions timeout and fail.

Root cause — two issues combined:

  1. docker-publish.yml was missing setup-qemu-action entirely. Without it, multi-platform builds hang indefinitely rather than failing fast.
  2. The Dockerfile ran npm install (full dev dependency tree including 3 native C++ modules: bcrypt, better-sqlite3, node-pty) entirely under QEMU ARM64 emulation — ~10-20x slower than native. Compiling those three modules under QEMU alone can take several hours.

Minutes impact: A 6-hour timeout on the free GitHub plan = 360 minutes consumed per failed run (18% of the 2,000 free monthly Linux minutes).

Solution

docker-publish.yml

  • Add docker/setup-qemu-action@v3 (was missing)
  • Add platforms: linux/amd64,linux/arm64 to the build-push step

Dockerfile — cross-compilation optimization

Stage Platform What runs
Stage 1 (frontend-builder) $BUILDPLATFORM (amd64, native) npm install + vite build
Stage 2 (backend-builder) $BUILDPLATFORM (amd64, native) npm install + tsc
Stage 3 (final) $TARGETPLATFORM (arm64 via QEMU) npm ci --omit=dev only

TypeScript output is platform-agnostic JS — safe to compile on amd64 and copy to arm64. Only the production npm ci --omit=dev runs under QEMU, compiling the 3 native modules for the correct target architecture.

Estimated build time: ~15–30 min (vs 6+ hours / timeout before)

Changes

  • .github/workflows/docker-publish.yml — add QEMU setup, add platforms
  • Dockerfile--platform=$BUILDPLATFORM on builder stages, lean production install in final stage

- Add docker/setup-qemu-action@v3 to docker-publish.yml (was missing,
  causing multi-platform builds to hang indefinitely)
- Add platforms: linux/amd64,linux/arm64 to build-push-action step
- Optimize Dockerfile with --platform=$BUILDPLATFORM on builder stages
  so TypeScript compilation runs at native amd64 speed; only the lean
  npm ci --omit=dev step runs under QEMU in the final stage, compiling
  the three native modules (bcrypt, better-sqlite3, node-pty) for the
  correct target architecture — reduces arm64 build time from 6+ hours
  to ~15-30 minutes
@AnsoCode
AnsoCode force-pushed the feat/arm64-docker-build branch from 9d2d812 to 059961a Compare March 24, 2026 11:45
@AnsoCode
AnsoCode merged commit 278f7f1 into develop Mar 24, 2026
6 checks passed
@AnsoCode
AnsoCode deleted the feat/arm64-docker-build branch March 24, 2026 11:50
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