XuqmGroup-Server/Dockerfile
XuqmGroup eb8bc70ff5 feat(deploy): 优化版本管理和多租户合并逻辑
- 修改 readCurrentVersion 方法优先读取镜像内的 /app/VERSION 文件
- 添加对宿主机挂载目录 VERSION 文件的兼容性支持
- 移除 bumpVersionFile 方法,不再在更新后写入版本号
- 重构多租户合并逻辑,优化数据库查询和更新操作
- 简化孤儿数据修复逻辑,直接更新为保留租户ID
- 在 Dockerfile 中复制 VERSION 文件到镜像内部
- 在 Jenkinsfile 中添加自动递增构建号功能
2026-05-27 19:25:50 +08:00

52 行
1.9 KiB
Docker

ARG SERVICE_MODULE=tenant-service
FROM --platform=linux/amd64 maven:3.9.9-eclipse-temurin-21 AS build
ARG SERVICE_MODULE
WORKDIR /workspace
# Copy only pom files first — layer cached until any pom.xml changes
COPY pom.xml ./pom.xml
COPY maven-settings.xml ./maven-settings.xml
COPY common/pom.xml ./common/pom.xml
COPY im-sdk/pom.xml ./im-sdk/pom.xml
COPY tenant-service/pom.xml ./tenant-service/pom.xml
COPY im-service/pom.xml ./im-service/pom.xml
COPY push-service/pom.xml ./push-service/pom.xml
COPY update-service/pom.xml ./update-service/pom.xml
COPY demo-service/pom.xml ./demo-service/pom.xml
COPY file-service/pom.xml ./file-service/pom.xml
COPY license-service/pom.xml ./license-service/pom.xml
# Pre-download dependencies using BuildKit cache mount — persisted across builds
RUN --mount=type=cache,target=/root/.m2 \
mvn -s /workspace/maven-settings.xml -pl ${SERVICE_MODULE} -am \
dependency:go-offline -q
# Copy source — invalidates only the compile layer, not the deps layer
COPY common ./common
COPY im-sdk ./im-sdk
COPY tenant-service ./tenant-service
COPY im-service ./im-service
COPY push-service ./push-service
COPY update-service ./update-service
COPY demo-service ./demo-service
COPY file-service ./file-service
COPY license-service ./license-service
RUN --mount=type=cache,target=/root/.m2 \
mvn -s /workspace/maven-settings.xml -pl ${SERVICE_MODULE} -am -DskipTests package
# Use Alpine-based JRE — ~100MB smaller than jammy
FROM --platform=linux/amd64 eclipse-temurin:21-jre-alpine
WORKDIR /app
ARG SERVICE_MODULE
# curl is required by update-service (MI store upload uses ProcessBuilder curl to handle
# Expect:100-continue and force HTTP/1.1 for large multipart uploads)
RUN apk add --no-cache curl docker-cli docker-compose
COPY --from=build /workspace/${SERVICE_MODULE}/target/${SERVICE_MODULE}-0.1.0-SNAPSHOT.jar /app/app.jar
COPY VERSION /app/VERSION
ENTRYPOINT ["java", "-jar", "/app/app.jar"]