build(ci): 新增 CI/CD 配置 + 修复 3 个部署 bug
新增: - Jenkinsfile:master→PROD(172.17.16.14)、release/next→STAGING(172.17.16.7) 镜像推 172.17.16.7:5000/aiot-iot-ui,宿主机暴露 90 - docker-compose.frontend.yml:nginx 容器加入 1panel-network - 根 Dockerfile + apps/web-antd/nginx.conf:与 vben 前端结构对齐 nginx 反代 /admin-api → http://aiot-gateway:48080 修复: - .env.production VITE_GLOB_API_URL 硬编码 127.0.0.1 → /admin-api(走 nginx 反代) - scripts/deploy/Dockerfile 引用不存在的 playground/dist → apps/web-antd/dist 并改用 turbo 单 filter 构建(与根 Dockerfile 一致)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
VITE_BASE=/
|
||||
|
||||
# 请求路径
|
||||
VITE_BASE_URL=http://127.0.0.1:48080
|
||||
# 请求路径(容器部署时走 nginx 反代到后端 gateway,写相对路径即可)
|
||||
VITE_BASE_URL=
|
||||
# 接口地址
|
||||
VITE_GLOB_API_URL=http://127.0.0.1:48080/admin-api
|
||||
VITE_GLOB_API_URL=/admin-api
|
||||
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务
|
||||
VITE_UPLOAD_TYPE=server
|
||||
|
||||
|
||||
64
apps/web-antd/nginx.conf
Normal file
64
apps/web-antd/nginx.conf
Normal file
@@ -0,0 +1,64 @@
|
||||
# 配置 DNS 解析器(使用 Docker 内置 DNS 解析容器名)
|
||||
resolver 127.0.0.11 valid=30s;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
# 开启 gzip 压缩
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
|
||||
gzip_vary on;
|
||||
gzip_disable "MSIE [1-6]\.";
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# API 反向代理到后端服务
|
||||
# 后端容器名为 aiot-gateway,与本前端容器需在同一 Docker 网络(1panel-network)
|
||||
location /admin-api {
|
||||
client_max_body_size 100M;
|
||||
|
||||
proxy_pass http://aiot-gateway:48080/admin-api;
|
||||
|
||||
proxy_connect_timeout 10s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
|
||||
# 后端短暂不可达时尝试一次重试
|
||||
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
|
||||
proxy_next_upstream_tries 2;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# 跨域响应头(仅作兜底,正常同域不会触发)
|
||||
add_header Access-Control-Allow-Origin * always;
|
||||
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS' always;
|
||||
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
return 204;
|
||||
}
|
||||
}
|
||||
|
||||
# SPA 路由刷新兜底
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# 静态资源缓存
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user