Files
par/Dockerfile
mediabot-pt b24ec27905 perf: 优化 CI Docker 镜像构建速度
- 新增 CI 精简 Dockerfile,直接打包 drone 预编译 jar,避免在 Docker 内重复编译(省去 npm ci + mvn 全量编译 ~15min)
- build-docker-image 步骤改用精简 Dockerfile,去掉无效的 docker pull 缓存尝试
- maven-build 步骤优化:动态检测 CPU 核数设置并行度 -T 1C/2C、增加 JVM 内存、添加 --fail-at-end
- .dockerignore 优化:CI Dockerfile 仅需 par-api/target/*.jar,排除所有源码/pom/前端文件
- par-api/Dockerfile 标注为独立多阶段构建版本(本地使用)

参考 mediabot 项目的多阶段构建思路,但将编译前置到 drone host 缓存中,Docker 构建秒级完成
2026-06-29 12:53:33 +08:00

39 lines
1.0 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.

# syntax=docker/dockerfile:1
# PAR Server - CI 专用精简镜像
# 参考 mediabot 的优化思路:Drone 流水线已完成编译,此处仅打包产物
# 完整多阶段构建版本见 par-api/Dockerfile(适用于本地独立构建)
FROM 192.168.31.253/library/eclipse-temurin:21-jre-alpine
ARG VERSION=unknown
ARG BUILD_TIME=unknown
ARG BUILDKIT_INLINE_CACHE=1
LABEL maintainer="PAR Team"
LABEL description="PT Adapter Registry Server"
LABEL version="${VERSION}"
LABEL build-time="${BUILD_TIME}"
# 创建非 root 用户
RUN addgroup -S par && adduser -S par -G par
WORKDIR /app
# 创建静态文件目录
RUN mkdir -p /app/static/configs && chown -R par:par /app
# 直接复制 drone 已构建好的 jar(无需在 Docker 内重新编译)
COPY par-api/target/*.jar app.jar
USER par
# 暴露端口
EXPOSE 8080
# 健康检查
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD wget -qO- http://localhost:8080/health || exit 1
# 启动参数
ENTRYPOINT ["java", "-jar", "app.jar"]