| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- # ============================================================
- # Frontend Dockerfile (Vue.js + Nginx)
- # Build: docker build -t water/frontend -f Dockerfile.frontend .
- # ============================================================
-
- # ---------- Stage 1: Build ----------
- FROM node:20-alpine AS builder
-
- WORKDIR /build
-
- # Copy package files first for caching
- COPY frontend/package.json frontend/package-lock.json ./
-
- RUN npm ci --registry=https://registry.npmmirror.com
-
- # Copy frontend source
- COPY frontend/ .
-
- # Build for production
- 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)
-
- # ---------- Stage 2: Nginx ----------
- FROM nginx:1.27-alpine
-
- LABEL maintainer="water-management-team"
- LABEL description="智慧水务管理系统 - 前端"
-
- RUN apk add --no-cache tzdata \
- && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone
-
- # Remove default site
- RUN rm -rf /usr/share/nginx/html/*
-
- # Copy built assets
- COPY --from=builder /build/dist /usr/share/nginx/html
-
- # Copy nginx config
- COPY docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
-
- EXPOSE 80
-
- HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
- CMD wget -qO- http://localhost/ || exit 1
-
- CMD ["nginx", "-g", "daemon off;"]
|