修复工作

This commit is contained in:
2025-09-30 20:56:55 +08:00
parent 6dba13713f
commit 9e36a84354
3 changed files with 10 additions and 19 deletions

View File

@@ -22,8 +22,8 @@ RUN npm run build:prod
# 运行阶段
FROM nginx:1.25-alpine
# 安装curl用于健康检查
RUN apk add --no-cache curl
# 安装curl和envsubst用于健康检查和环境变量替换
RUN apk add --no-cache curl gettext
# 删除默认nginx配置
RUN rm -rf /etc/nginx/conf.d/*
@@ -37,9 +37,5 @@ COPY --from=builder /app/dist /usr/share/nginx/html
# 暴露端口
EXPOSE 80
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD curl -f http://localhost:80 || exit 1
# 启动Nginx
CMD ["nginx", "-g", "daemon off;"]
# 使用envsubst替换环境变量然后启动Nginx
CMD sh -c "envsubst '\$NGINX_PORT' < /etc/nginx/conf.d/default.conf > /tmp/nginx.conf && mv /tmp/nginx.conf /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"