# 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.

# Node >=22.12.0 required by Vite 8 (engines field); 22.11 fails the build.
FROM node:22.12.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;"]
