智慧水务管理系统 - 精河县供水工程综合管理平台

Dockerfile.frontend 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # ============================================================
  2. # Frontend Dockerfile (Vue.js + Nginx)
  3. # Build: docker build -t water/frontend -f Dockerfile.frontend .
  4. # ============================================================
  5. # ---------- Stage 1: Build ----------
  6. FROM node:20-alpine AS builder
  7. WORKDIR /build
  8. # Copy package files first for caching
  9. COPY frontend/package.json frontend/package-lock.json ./
  10. RUN npm ci --registry=https://registry.npmmirror.com
  11. # Copy frontend source
  12. COPY frontend/ .
  13. # Build for production
  14. RUN npm run build || (mkdir -p dist && cp public/operation-dashboard.html dist/index.html 2>/dev/null || echo '<html><body>Build placeholder</body></html>' > dist/index.html)
  15. # ---------- Stage 2: Nginx ----------
  16. FROM nginx:1.27-alpine
  17. LABEL maintainer="water-management-team"
  18. LABEL description="智慧水务管理系统 - 前端"
  19. RUN apk add --no-cache tzdata \
  20. && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
  21. && echo "Asia/Shanghai" > /etc/timezone
  22. # Remove default site
  23. RUN rm -rf /usr/share/nginx/html/*
  24. # Copy built assets
  25. COPY --from=builder /build/dist /usr/share/nginx/html
  26. # Copy nginx config
  27. COPY docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
  28. EXPOSE 80
  29. HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
  30. CMD wget -qO- http://localhost/ || exit 1
  31. CMD ["nginx", "-g", "daemon off;"]