devperf/frontend/Dockerfile
zyc 17696f9049
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m2s
perf: Nginx 开启 gzip 压缩和静态资源缓存,加速首次加载
- gzip 压缩 JS/CSS/JSON 等资源(676KB→226KB)
- /assets/ 静态文件设置 1 年缓存(文件名含 hash)
- index.html 设置 no-cache 确保更新及时

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 11:43:15 +08:00

16 lines
431 B
Docker

FROM node:22-slim AS builder
WORKDIR /app
ARG VITE_API_BASE_URL=http://localhost:3200
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
COPY package.json package-lock.json* ./
RUN npm ci || npm install
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist/ /usr/share/nginx/html/
# Nginx config: gzip + cache + SPA fallback
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]