-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (27 loc) · 870 Bytes
/
Dockerfile
File metadata and controls
38 lines (27 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 简单的Dockerfile - 使用现有jar文件
FROM eclipse-temurin:17-jre
# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 创建非root用户
RUN groupadd -r appuser && useradd -r -g appuser appuser
WORKDIR /app
# 复制jar文件
COPY ./target/java-ai-starter-*.jar app.jar
# 复制启动脚本
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# 创建必要的目录
RUN mkdir -p /app/logs /app/config && \
chown -R appuser:appuser /app
# 切换到非root用户
USER appuser
# 健康检查
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/api/v1/status || exit 1
# 暴露端口
EXPOSE 8080
# 入口点
ENTRYPOINT ["docker-entrypoint.sh"]
# 默认命令
CMD ["java", "-jar", "app.jar"]