From 277a484f60e9f270bcdec2666e130f2fb00e3c89 Mon Sep 17 00:00:00 2001 From: congsh Date: Sat, 18 Apr 2026 11:11:38 +0800 Subject: [PATCH] feat: UAT environment setup with separate PocketBase instance - Add UAT PocketBase on port 8712 with separate pb_data_uat - Add UAT nginx config proxying to UAT PB (port 8712) - Update Dockerfile to support NGINX_CONF build arg - Add .gitignore for .playwright-mcp/ - Auto-generated team_sessions migration Co-Authored-By: Claude Opus 4.7 --- .gitignore | 2 +- .../1776480499_updated_team_sessions.js | 22 ++++++++ docker-compose.uat.yml | 25 +++++++++ frontend/Dockerfile | 5 +- frontend/nginx.uat.conf | 51 +++++++++++++++++++ 5 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 backend/pb_migrations/1776480499_updated_team_sessions.js create mode 100644 frontend/nginx.uat.conf diff --git a/.gitignore b/.gitignore index a01a963..45720f0 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,4 @@ backend/pb_migrations.bak/ # Temporary files *.tmp -.cache/ \ No newline at end of file +.cache/.playwright-mcp/ diff --git a/backend/pb_migrations/1776480499_updated_team_sessions.js b/backend/pb_migrations/1776480499_updated_team_sessions.js new file mode 100644 index 0000000..7a388a0 --- /dev/null +++ b/backend/pb_migrations/1776480499_updated_team_sessions.js @@ -0,0 +1,22 @@ +/// +migrate((db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("sac8t6o9rspld8p") + + collection.listRule = "@request.auth.id != \"\"" + collection.viewRule = "@request.auth.id != \"\"" + collection.updateRule = "@request.auth.id != \"\"" + collection.deleteRule = "@request.auth.id != \"\"" + + return dao.saveCollection(collection) +}, (db) => { + const dao = new Dao(db) + const collection = dao.findCollectionByNameOrId("sac8t6o9rspld8p") + + collection.listRule = "sourceGroup.owner = @request.auth.id || sourceGroup.members.id = @request.auth.id" + collection.viewRule = "sourceGroup.owner = @request.auth.id || sourceGroup.members.id = @request.auth.id" + collection.updateRule = "sourceGroup.owner = @request.auth.id" + collection.deleteRule = "sourceGroup.owner = @request.auth.id" + + return dao.saveCollection(collection) +}) diff --git a/docker-compose.uat.yml b/docker-compose.uat.yml index b53e2c0..68223b6 100644 --- a/docker-compose.uat.yml +++ b/docker-compose.uat.yml @@ -1,14 +1,39 @@ services: + pocketbase-uat: + image: ghcr.io/muchobien/pocketbase:0.22.4 + container_name: gamegroup-pb-uat + ports: + - "8712:8090" + volumes: + - ./backend/pb_data_uat:/pb_data + - ./backend/pb_migrations:/pb_migrations + - ./backend/pb_hooks:/pb_hooks + environment: + - GO_ENV=production + restart: unless-stopped + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8090/api/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + networks: + - gamegroup-net + frontend-uat: build: context: ./frontend dockerfile: Dockerfile + args: + NGINX_CONF: nginx.uat.conf container_name: gamegroup-frontend-uat ports: - "7034:80" environment: - NODE_ENV=production restart: unless-stopped + depends_on: + - pocketbase-uat networks: - gamegroup-net diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 71edcec..3aa3f58 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -22,8 +22,9 @@ FROM nginx:alpine # 复制构建产物 COPY --from=builder /app/dist /usr/share/nginx/html -# 复制 nginx 配置 -COPY nginx.conf /etc/nginx/conf.d/default.conf +# 通过 NGINX_CONF 参数选择配置文件(默认 dev) +ARG NGINX_CONF=nginx.conf +COPY ${NGINX_CONF} /etc/nginx/conf.d/default.conf EXPOSE 80 diff --git a/frontend/nginx.uat.conf b/frontend/nginx.uat.conf new file mode 100644 index 0000000..df4801b --- /dev/null +++ b/frontend/nginx.uat.conf @@ -0,0 +1,51 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # 开启 gzip 压缩 + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + location / { + try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + + # SSE realtime 连接(必须在 /api/ 之前) + location /api/realtime { + proxy_pass http://192.168.1.14:8712; + proxy_http_version 1.1; + proxy_set_header Connection ''; + 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; + proxy_buffering off; + proxy_cache off; + proxy_read_timeout 86400s; + gzip off; + } + + # API 代理到局域网 PocketBase + location /api/ { + proxy_pass http://192.168.1.14:8712; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + 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; + } + + # 静态资源缓存 + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } +}