Files
urbanLifeline/docker/example/Dockerfile.serv
2025-12-28 18:30:17 +08:00

37 lines
1.2 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.

# ====================================
# 后端服务镜像 - School News Serv
# 直接从主机复制构建好的JAR包
# 注意使用前需要先执行build.sh构建JAR包
# ====================================
FROM school-news-base-serv:latest
# 设置工作目录
WORKDIR /app
# 1. 复制不经常变化的文件
# 复制启动脚本
COPY schoolNewsServ/docker/start.sh /app/start.sh
# 复制爬虫脚本(基础镜像已安装依赖)
COPY schoolNewsCrawler/ /app/crawler/
# 复制默认配置文件
COPY schoolNewsServ/admin/src/main/resources/application.yml /app/config/application.yml.template
COPY schoolNewsServ/admin/src/main/resources/log4j2-spring.xml /app/config/log4j2-spring.xml.template
# 2. 设置脚本权限和创建目录
RUN chmod +x /app/start.sh && \
mkdir -p /app/logs
# 3. 最后复制JAR包这行变化最频繁放在最后
# 注意这里假设JAR包已经通过build.sh构建在target目录下
COPY schoolNewsServ/admin/target/admin-*.jar /app/app.jar
# 暴露端口
EXPOSE 8081
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8081/schoolNewsServ/actuator/health || exit 1
# 启动应用
ENTRYPOINT ["/app/start.sh"]