fix(web): 烤入所有 nginx 配置,按 APP_ENV 运行时切换,彻底解决 staging/prod 配置错乱 #1853
Reference in New Issue
Block a user
Delete Branch "fix/nginx-config-per-env"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
web Dockerfile 通过
ARG NGINX_CONF在构建时烤入单个 nginx 配置。但 CI 从 develop 分支构建时始终使用nginx-staging.conf,导致生产镜像内的默认 nginx 配置指向xiaoxia-api-staging:8000,在生产环境容器重启后出现 502。修复方案
nginx-entrypoint.sh,容器启动时根据APP_ENV环境变量 symlink 正确的配置到/etc/nginx/conf.d/default.confNGINX_CONF构建参数APP_ENV=staging/production效果
变更文件
infra/docker/web.Dockerfile— 烤入 3 份 nginx 配置 + entrypointinfra/docker/web-artifact.Dockerfile— 同步修改infra/docker/nginx-entrypoint.sh— 新增,运行时配置选择器.gitea/workflows/ci-pipeline.yml— 移除 NGINX_CONF 参数infra/docker/deploy-production-registry.sh— 添加 APP_ENV=productioninfra/docker/deploy-staging-registry.sh— 添加 APP_ENV=staging,移除 volume 挂载infra/docker/deploy-staging.sh— 移除 WEB_NGINX_CONFinfra/docker/compose.yml— NGINX_ENV → APP_ENV🚀 预览环境已部署
🗑️ 预览环境已清理
PR #1853 已关闭或合并,对应的预览环境已被清理。