29 lines
822 B
Docker
29 lines
822 B
Docker
# syntax=docker/dockerfile:1.7
|
|
ARG NODE_VERSION=20.15.0
|
|
FROM node:${NODE_VERSION}-alpine AS build
|
|
WORKDIR /app
|
|
|
|
# Install deps first for better caching
|
|
COPY package*.json ./
|
|
RUN npm ci || npm install
|
|
|
|
# Build
|
|
COPY . .
|
|
ENV NODE_ENV=production
|
|
# Limit Node heap during build to avoid OOM on small builders
|
|
ENV NODE_OPTIONS=--max-old-space-size=512
|
|
RUN npm run build
|
|
|
|
# ---- Runtime (Nginx) ----
|
|
FROM nginx:1.27-alpine AS runtime
|
|
# Remove default site content
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
# SPA config (history fallback)
|
|
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
|
|
# Static assets
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
EXPOSE 80
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD wget -qO- http://localhost/ >/dev/null 2>&1 || exit 1
|
|
CMD ["nginx", "-g", "daemon off;"]
|