test-backend/test-server-cloud/test-system-cloud-start/Dockerfile

53 lines
1.8 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================
# System Cloud 微服务 — 多阶段构建
# Stage 1: Maven 编译全项目SpringCloud profile
# Stage 2: JRE 运行
# ============================================
# ---- Stage 1: 编译 ----
FROM maven:3.9-eclipse-temurin-17 AS builder
WORKDIR /build
# 先复制 pom.xml利用 Docker 缓存加速依赖下载
COPY pom.xml ./
COPY ghb-base-core/pom.xml ghb-base-core/
COPY ghb-module-system/pom.xml ghb-module-system/
COPY ghb-module-system/ghb-system-api/pom.xml ghb-module-system/ghb-system-api/
COPY ghb-module-system/ghb-system-biz/pom.xml ghb-module-system/ghb-system-biz/
COPY ghb-module-system/ghb-system-start/pom.xml ghb-module-system/ghb-system-start/
COPY ghb-module-business/pom.xml ghb-module-business/
COPY ghb-server-cloud/pom.xml ghb-server-cloud/
COPY test-server-cloud/test-cloud-gateway/pom.xml test-server-cloud/test-cloud-gateway/
COPY test-server-cloud/test-system-cloud-start/pom.xml test-server-cloud/test-system-cloud-start/
COPY ghb-server-cloud/ghb-demo-cloud-start/pom.xml ghb-server-cloud/ghb-demo-cloud-start/
COPY test-server-cloud/test-cloud-nacos/pom.xml test-server-cloud/test-cloud-nacos/
# 下载依赖pom 不变时缓存)
RUN mvn dependency:go-offline -B -P SpringCloud,dev || true
# 复制全部源码
COPY . .
# 编译全项目SpringCloud profile跳过测试
RUN mvn package -P SpringCloud,dev -Dmaven.test.skip=true -T 1C
# ---- Stage 2: 运行 ----
FROM eclipse-temurin:17-jre
LABEL maintainer="ghb-base deploy"
ENV TZ=Asia/Shanghai
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
WORKDIR /app
# 从编译阶段复制 system-cloud jar
COPY --from=builder /build/test-server-cloud/test-system-cloud-start/target/*.jar app.jar
EXPOSE 7001
ENV JAVA_OPTS="-Xms512m -Xmx512m"
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]