Multi-stage Dockerfile: node:22.13.1-alpine3.21 builds the Vite bundle, nginx:1.27.4-alpine3.21-slim serves dist/ on container :80. Compose maps host :4422 to container :80 with a wget healthcheck and unless-stopped restart policy. nginx.conf serves Vite's content-addressed /assets/ as immutable, caches images for 30d, falls back to index.html for SPA routes, and sets X-Frame-Options / X-Content-Type-Options / Referrer-Policy / Permissions-Policy headers. Server tokens off. .dockerignore keeps the build context lean (no node_modules, dist, .git, archive, or compose files). Pin to image digests in Portainer's stack editor for full lock. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
19 lines
633 B
Docker
19 lines
633 B
Docker
# syntax=docker/dockerfile:1.7
|
|
# Pin both stages to specific Alpine-based releases. Recommend layering
|
|
# `@sha256:<digest>` in Portainer's stack editor for full digest pinning.
|
|
|
|
FROM node:22.11.0-alpine3.20 AS build
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci --no-audit --no-fund
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
FROM nginx:1.27.2-alpine3.20 AS runtime
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
EXPOSE 80
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget -q --spider http://127.0.0.1/ || exit 1
|
|
CMD ["nginx", "-g", "daemon off;"]
|