Files
major_tom/Containerfile
Le Serjant 587fd210a2
Some checks failed
CI / build (pull_request) Failing after 1m13s
Deploy / deploy (push) Failing after 55s
Fix #13: optimize deploy with multi-stage Containerfile
Move the WASM build into a multi-stage Containerfile so the emscripten
compilation happens inside the Docker build. This eliminates the separate
container action step, enables Docker layer caching for faster rebuilds,
and makes the Containerfile self-contained.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 14:47:56 +00:00

36 lines
1010 B
Docker

# JNR Web — multi-stage build: compile WASM then serve static files
#
# Build:
# podman build -t jnr-web .
# docker build -t jnr-web .
#
# Run locally:
# podman run --rm -p 8080:80 jnr-web
# Then visit http://localhost:8080
#
# Deploy to k3s:
# podman save jnr-web | sudo k3s ctr images import -
# sudo k3s kubectl apply -f k8s/
# ── Stage 1: Build WASM artifacts ──
FROM docker.io/emscripten/emsdk:3.1.51 AS builder
WORKDIR /src
COPY Makefile ./
COPY include/ include/
COPY src/ src/
COPY assets/ assets/
COPY web/ web/
RUN make web
# ── Stage 2: Serve static files ──
FROM docker.io/joseluisq/static-web-server:2
COPY --from=builder /src/dist-web/ /public/
# Disable the default cache-control headers which cache .js for 1 year.
# The .js and .wasm files must always be fetched together (EM_ASM address
# table in JS must match the compiled WASM), so aggressive caching causes
# "No EM_ASM constant found" errors after redeployments.
ENV SERVER_CACHE_CONTROL_HEADERS=false