test-backend/test-server-cloud/test-cloud-nacos/Dockerfile

46 lines
1.2 KiB
Docker
Raw Permalink 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.

# ============================================
# Nacos 微服务 — 多阶段构建SB 2.7.18 独立编译)
# Nacos 使用 Spring Boot 2.7.18 作 parent
# 与主项目SB 3.5.5)不在同一 reactor需单独编译
# ============================================
# ---- Stage 1: 编译 ----
FROM maven:3.9-eclipse-temurin-17 AS builder
WORKDIR /build
# 只复制 nacos 模块(独立编译,不依赖项目内其他模块)
COPY test-server-cloud/test-cloud-nacos/pom.xml ./
# 下载依赖
RUN mvn dependency:go-offline -B || true
# 复制 nacos 源码
COPY test-server-cloud/test-cloud-nacos/src ./src
# 编译 nacos 模块
RUN mvn package -Dmaven.test.skip=true
# ---- 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
# 从编译阶段复制 nacos jar
COPY --from=builder /build/target/*.jar app.jar
# 启动脚本(根据环境变量生成 application.properties
COPY test-server-cloud/test-cloud-nacos/startup.sh /app/startup.sh
RUN chmod +x /app/startup.sh
EXPOSE 8848
ENV JAVA_OPTS="-Xms512m -Xmx512m"
ENTRYPOINT ["/app/startup.sh"]