- 将健康检查命令从`/photography-api --health-check`更新为使用新的脚本`/usr/local/bin/health-check.sh` - 在Dockerfile中添加`wget`作为运行时依赖 - 确保健康检查脚本具有执行权限 此更改提升了健康检查的可靠性和灵活性。
This commit is contained in:
@ -45,8 +45,8 @@ FROM alpine:3.19
|
||||
# 配置镜像源加速
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
# 安装运行时依赖 (包含SQLite动态库)
|
||||
RUN apk add --no-cache ca-certificates tzdata sqlite
|
||||
# 安装运行时依赖 (包含SQLite动态库和wget用于健康检查)
|
||||
RUN apk add --no-cache ca-certificates tzdata sqlite wget
|
||||
|
||||
# 创建非root用户
|
||||
RUN addgroup -g 1001 -S appgroup && \
|
||||
@ -61,10 +61,12 @@ COPY --from=builder /app/configs /configs
|
||||
COPY --from=builder /app/scripts /scripts
|
||||
COPY --from=builder /app/pkg/migration /pkg/migration
|
||||
COPY --from=builder /app/etc /etc
|
||||
COPY --from=builder /app/health-check.sh /usr/local/bin/health-check.sh
|
||||
|
||||
# 设置目录权限
|
||||
# 设置目录权限和脚本权限
|
||||
RUN mkdir -p /app && \
|
||||
chown -R appuser:appgroup /app
|
||||
chown -R appuser:appgroup /app && \
|
||||
chmod +x /usr/local/bin/health-check.sh
|
||||
|
||||
# 设置时区
|
||||
ENV TZ=Asia/Shanghai
|
||||
@ -80,7 +82,7 @@ EXPOSE 8080
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD ["/usr/local/bin/photography-api", "--health-check"]
|
||||
CMD /usr/local/bin/health-check.sh
|
||||
|
||||
# 启动应用
|
||||
ENTRYPOINT ["/usr/local/bin/photography-api"]
|
||||
Reference in New Issue
Block a user