fix: docker镜像修复

This commit is contained in:
Cassianvale
2025-03-07 14:59:03 +08:00
parent 96791877f4
commit d263ddbbcc
4 changed files with 35 additions and 9 deletions

View File

@@ -20,11 +20,17 @@ RUN npm run build
FROM nginx:stable-alpine as production-stage
# 复制自定义nginx配置如需要
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf.template
# 从构建阶段复制构建结果到nginx服务目录
COPY --from=build-stage /app/dist /usr/share/nginx/html
# 创建启动脚本
RUN echo '#!/bin/sh \n\
envsubst "\$BACKEND_URL" < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf \n\
nginx -g "daemon off;"' > /docker-entrypoint.sh && \
chmod +x /docker-entrypoint.sh
# 暴露80端口
EXPOSE 80
@@ -32,5 +38,5 @@ EXPOSE 80
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:80 || exit 1
# 设定Nginx是否以守护进程的方式启动
CMD ["nginx", "-g", "daemon off;"]
# 设定启动命令
CMD ["/docker-entrypoint.sh"]