From dccab97041d390a1e912942bd1e50b679fa198ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=A6=82=E5=A8=81?= Date: Tue, 30 Sep 2025 14:40:56 +0800 Subject: [PATCH] build --- docker-compose.yml | 4 ++-- frontend/nginx.conf | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 24545a2..5f51cf9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,9 +19,9 @@ services: - ./frontend/dist:/usr/share/nginx/html # 挂载前端构建文件 - ./frontend/nginx.conf:/etc/nginx/conf.d/default.conf # 挂载 Nginx 配置 ports: - - "8001:80" # 将 Nginx 的 80 端口映射到主机的 1337 端口 + - "8001:80" # 将 Nginx 的 80 depends_on: - - workflow-server # 确保 Sanic 服务先启动 + - workflow-server networks: workflow: driver: bridge \ No newline at end of file diff --git a/frontend/nginx.conf b/frontend/nginx.conf index e69de29..9f7ea14 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -0,0 +1,32 @@ +server { + listen 80; + + client_max_body_size 20M; + + gzip on; + gzip_min_length 1k; + gzip_comp_level 9; + gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; + gzip_vary on; + gzip_disable "MSIE [1-6]\."; + + location / { + root /usr/share/nginx/html; # 前端构建文件的位置 + index index.html index.htm; + try_files $uri $uri/ /index.html; # 支持前端路由 + } + + location /api { # 假设 API 路径是 /api + proxy_pass http://workflow-server:8080; # 将请求代理到 Sanic 服务 + proxy_http_version 1.1; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + } + + location /docs { # 假设 API 路径是 /api + proxy_pass http://workflow-server:8080/docs; # 将请求代理到 Sanic 服务 + proxy_http_version 1.1; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + } +} \ No newline at end of file