The multi-arch Docker build previously ran npm ci + npm run build for each target platform despite producing identical static assets. Add an overridable site-dist stage to the Dockerfile that CI replaces via --build-context site-dist=./dist. The workflow now builds the site once natively with Node.js on the runner, then the multi-arch step only packages the pre-built dist into nginx.
29 lines
632 B
Docker
29 lines
632 B
Docker
## Builder
|
|
FROM --platform=$BUILDPLATFORM node:24.13.1-alpine AS builder
|
|
|
|
WORKDIR /src
|
|
|
|
ARG VITE_BUILD_HASH
|
|
ARG VITE_IS_RELEASE_TAG=false
|
|
ENV VITE_BUILD_HASH=$VITE_BUILD_HASH
|
|
ENV VITE_IS_RELEASE_TAG=$VITE_IS_RELEASE_TAG
|
|
|
|
COPY .npmrc package.json package-lock.json /src/
|
|
RUN npm ci --ignore-scripts
|
|
COPY . /src/
|
|
ENV NODE_OPTIONS=--max_old_space_size=4096
|
|
RUN npm run build
|
|
|
|
## Dist
|
|
FROM scratch AS site-dist
|
|
COPY --from=builder /src/dist /
|
|
|
|
## App
|
|
FROM nginx:1.29.5-alpine
|
|
|
|
COPY --from=site-dist / /app
|
|
COPY docker-nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
RUN rm -rf /usr/share/nginx/html \
|
|
&& ln -s /app /usr/share/nginx/html
|