fix: 修复 Drone 配置和 nginx 多环境支持
All checks were successful
continuous-integration/drone/push Build is passing

- 分离测试/生产环境的前端镜像构建
- nginx 配置使用 BACKEND_HOST 变量区分环境
- 生产环境添加独立的 Docker network
- 生产环境使用独立的密钥配置 (xxx_prod)
- 修复前端空白问题:确保前后端在同一 network
This commit is contained in:
2026-01-24 17:15:12 +08:00
parent 6c6c48cf71
commit b6b5ac61af
3 changed files with 36 additions and 13 deletions

View File

@@ -13,9 +13,15 @@ RUN npm run build
# 生产镜像
FROM nginx:alpine
# 后端服务地址(通过 build-arg 传入,构建时替换)
ARG BACKEND_HOST=platform-backend-test
COPY --from=builder /app/dist /usr/share/nginx/html
COPY deploy/nginx/frontend.conf /etc/nginx/conf.d/default.conf
# 在构建时替换后端地址(只替换 BACKEND_HOST 变量)
RUN sed -i "s/\${BACKEND_HOST}/${BACKEND_HOST}/g" /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -14,9 +14,9 @@ server {
}
# API 代理到后端
# 使用 Docker 容器名称,通过 Docker DNS 解析
# 使用环境变量 BACKEND_HOST,通过 Docker DNS 解析
location /api/ {
set $backend platform-backend-test:8000;
set $backend ${BACKEND_HOST}:8000;
proxy_pass http://$backend/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;