Files
operacle--checkcle/docker/Dockerfile.frontend
T
2026-07-13 12:31:02 +08:00

22 lines
754 B
Docker

FROM node:20-alpine AS build
WORKDIR /app
# Install dependencies
COPY application/package.json application/package-lock.json ./
RUN npm ci
# Copy source and build
COPY application/. .
RUN npm run build
FROM nginx:1.27-alpine
RUN rm -rf /usr/share/nginx/html/*
COPY --from=build /app/dist /usr/share/nginx/html
# SPA fallback + static asset caching
RUN printf 'server {\n listen 80;\n server_name _;\n root /usr/share/nginx/html;\n index index.html;\n location / { try_files $uri $uri/ /index.html; }\n location ~* \\.(?:js|css|png|jpg|jpeg|gif|svg|ico|woff2?)$ { expires 7d; add_header Cache-Control "public, max-age=604800, immutable"; try_files $uri =404; }\n}\n' > /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx","-g","daemon off;"]