feat: add multi-stage Dockerfile for full build with martial-tool
- Add Dockerfile.fullbuild: multi-stage build that compiles martial-tool - Rename Dockerfile to Dockerfile.quick for quick builds (pre-built jar) - Update docker-compose.yml to use parent directory context - Update README with new deployment instructions
This commit is contained in:
50
Dockerfile.fullbuild
Normal file
50
Dockerfile.fullbuild
Normal file
@@ -0,0 +1,50 @@
|
||||
# ============================================
|
||||
# 武术赛事管理系统 - 完整构建 Dockerfile
|
||||
# 包含 martial-tool 编译 + martial-master 编译
|
||||
# ============================================
|
||||
|
||||
# 构建阶段:使用 Maven + JDK 镜像
|
||||
FROM maven:3.9-eclipse-temurin-17 AS builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# 复制 martial-tool(BladeX 框架)
|
||||
COPY martial-tool /build/martial-tool
|
||||
|
||||
# 编译 martial-tool 并安装到本地仓库
|
||||
RUN cd /build/martial-tool && \
|
||||
mvn clean install -DskipTests -q
|
||||
|
||||
# 复制 martial-master(后端项目)
|
||||
COPY martial-master /build/martial-master
|
||||
|
||||
# 编译 martial-master
|
||||
RUN cd /build/martial-master && \
|
||||
mvn clean package -DskipTests -q
|
||||
|
||||
# ============================================
|
||||
# 运行阶段:使用轻量级 JRE 镜像
|
||||
# ============================================
|
||||
FROM eclipse-temurin:17-jre-jammy
|
||||
|
||||
LABEL maintainer="JohnSion"
|
||||
LABEL description="武术比赛管理系统后端服务"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 从构建阶段复制 JAR 文件
|
||||
COPY --from=builder /build/martial-master/target/blade-api.jar /app/blade-api.jar
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 8123
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=60s --retries=3 \
|
||||
CMD curl -f http://localhost:8123/actuator/health || exit 1
|
||||
|
||||
# JVM 参数配置
|
||||
ENV JAVA_OPTS="-Xms512m -Xmx1024m -XX:+UseG1GC"
|
||||
ENV SPRING_PROFILE="dev"
|
||||
|
||||
# 启动命令
|
||||
CMD ["sh", "-c", "java ${JAVA_OPTS} -jar /app/blade-api.jar --spring.profiles.active=${SPRING_PROFILE}"]
|
||||
Reference in New Issue
Block a user