1- FROM node:22-alpine AS spa-builder
1+ # syntax=docker/dockerfile:1.7
2+
3+ # Build the SPA with the build platform to avoid slow QEMU emulation on arm64
4+ FROM --platform=$BUILDPLATFORM node:22-bookworm-slim AS spa-builder
25
36WORKDIR /app/webapp
47COPY webapp/package*.json ./
5- RUN npm ci
8+ # Speed up and stabilize npm installs in CI
9+ # - no-audit/no-fund: skip network calls
10+ # - no-progress: cleaner logs
11+ # - cache mount: reuse npm cache between builds
12+ RUN --mount=type=cache,target=/root/.npm \
13+ npm ci --no-audit --no-fund --no-progress
614COPY webapp/ ./
715RUN npm run build
816
@@ -14,22 +22,32 @@ RUN adduser -D -g '' ackuser
1422WORKDIR /app
1523COPY go.mod go.sum ./
1624ENV GOTOOLCHAIN=auto
17- RUN go mod download && go mod verify
25+ # Cache Go modules and build cache between builds
26+ RUN --mount=type=cache,target=/go/pkg/mod \
27+ --mount=type=cache,target=/root/.cache/go-build \
28+ go mod download && go mod verify
1829COPY backend/ ./backend/
1930
2031RUN mkdir -p backend/cmd/community/web/dist
2132COPY --from=spa-builder /app/webapp/dist ./backend/cmd/community/web/dist
2233
34+ # Cross-compile per target platform
35+ ARG TARGETOS
36+ ARG TARGETARCH
2337ARG VERSION="dev"
2438ARG COMMIT="unknown"
2539ARG BUILD_DATE="unknown"
2640
27- RUN CGO_ENABLED=0 GOOS=linux go build \
41+ RUN --mount=type=cache,target=/go/pkg/mod \
42+ --mount=type=cache,target=/root/.cache/go-build \
43+ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
2844 -a -installsuffix cgo \
2945 -ldflags="-w -s -X main.Version=${VERSION} -X main.Commit=${COMMIT} -X main.BuildDate=${BUILD_DATE}" \
3046 -o ackify ./backend/cmd/community
3147
32- RUN CGO_ENABLED=0 GOOS=linux go build \
48+ RUN --mount=type=cache,target=/go/pkg/mod \
49+ --mount=type=cache,target=/root/.cache/go-build \
50+ CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
3351 -a -installsuffix cgo \
3452 -ldflags="-w -s" \
3553 -o migrate ./backend/cmd/migrate
0 commit comments