| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- # ============================================================
- # Multi-stage Dockerfile for wm-base (核心基础服务)
- # Build: docker build -t water/wm-base --build-arg MODULE=wm-base .
- # ============================================================
-
- # ---------- Stage 1: Build ----------
- FROM maven:3.9-eclipse-temurin-17 AS builder
-
- WORKDIR /build
-
- # Copy parent POM and all module POMs first (dependency caching)
- COPY pom.xml ./
- COPY wm-common/pom.xml wm-common/
- COPY wm-gateway/pom.xml wm-gateway/
- COPY wm-base/pom.xml wm-base/
- COPY wm-iot/pom.xml wm-iot/
- COPY wm-data-engine/pom.xml wm-data-engine/
- COPY wm-bpm/pom.xml wm-bpm/
- COPY wm-bpm-engine/pom.xml wm-bpm-engine/
- COPY wm-production/pom.xml wm-production/
- COPY wm-revenue/pom.xml wm-revenue/
- COPY wm-patrol/pom.xml wm-patrol/
- COPY wm-bi/pom.xml wm-bi/
- COPY wm-notify/pom.xml wm-notify/
- COPY wm-job/pom.xml wm-job/
- COPY wm-dispatch/pom.xml wm-dispatch/
- COPY wm-system/pom.xml wm-system/
- COPY wm-mobile-app/pom.xml wm-mobile-app/
- COPY wm-config/pom.xml wm-config/
- COPY wm-dma/pom.xml wm-dma/
-
- # Download dependencies (cached layer)
- RUN mvn dependency:go-offline -B 2>/dev/null || true
-
- # Copy all source code
- COPY . .
-
- # Build the target module and its dependencies
- ARG MODULE=wm-base
- RUN mvn clean package -pl ${MODULE} -am -DskipTests -B
-
- # ---------- Stage 2: Runtime ----------
- FROM eclipse-temurin:17-jre-alpine
-
- LABEL maintainer="water-management-team"
- LABEL description="智慧水务管理系统 - 应用服务"
-
- RUN apk add --no-cache curl tzdata \
- && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
- && echo "Asia/Shanghai" > /etc/timezone
-
- WORKDIR /app
-
- ARG MODULE=wm-base
- ARG PORT=8081
-
- COPY --from=builder /build/${MODULE}/target/${MODULE}-*.jar app.jar
-
- EXPOSE ${PORT}
-
- # Health check
- HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
- CMD curl -sf http://localhost:${PORT}/actuator/health || exit 1
-
- ENTRYPOINT ["java", "-Xms256m", "-Xmx512m", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
|