diff --git a/dockerfile-captain.edge b/dockerfile-captain.edge index f53e8bb..a7c0db8 100644 --- a/dockerfile-captain.edge +++ b/dockerfile-captain.edge @@ -1,10 +1,10 @@ -FROM node:22-alpine -RUN apk add --update --no-cache make gcc g++ git curl openssl openssh +# Build stage runs on the host platform to avoid QEMU SIGILL issues with Node.js 22 on arm64 +FROM --platform=$BUILDPLATFORM node:22-alpine AS builder +RUN apk add --update --no-cache make gcc g++ git curl openssl WORKDIR /usr/src/app COPY . ./ - # Build backend code RUN npm ci && \ npm run build && \ @@ -12,6 +12,13 @@ RUN npm ci && \ npm cache clean --force && \ mv ./edge-override.json ./config-override.json +# Final stage uses the target platform's Node.js runtime +FROM node:22-alpine +RUN apk add --update --no-cache git curl openssl openssh + +WORKDIR /usr/src/app +COPY --from=builder /usr/src/app . + # This quick hack invalidates the cache. ADD https://www.google.com /time.now diff --git a/dockerfile-captain.release b/dockerfile-captain.release index 2481167..6b733fc 100644 --- a/dockerfile-captain.release +++ b/dockerfile-captain.release @@ -1,5 +1,6 @@ -FROM node:22-alpine -RUN apk add --update --no-cache make gcc g++ git curl openssl openssh +# Build stage runs on the host platform to avoid QEMU SIGILL issues with Node.js 22 on arm64 +FROM --platform=$BUILDPLATFORM node:22-alpine AS builder +RUN apk add --update --no-cache make gcc g++ git curl openssl WORKDIR /usr/src/app COPY . ./ @@ -9,7 +10,14 @@ RUN npm ci && \ npm run build && \ npm ci --omit=dev && \ npm cache clean --force - + +# Final stage uses the target platform's Node.js runtime +FROM node:22-alpine +RUN apk add --update --no-cache git curl openssl openssh + +WORKDIR /usr/src/app +COPY --from=builder /usr/src/app . + ENV NODE_ENV production ENV PORT 3000 EXPOSE 3000