deploy(v2): h5 build with base /v2/h5, admin dockerfile & nginx route, shared compose

This commit is contained in:
yeuimu
2026-09-01 16:26:22 +08:00
parent 60992cb3d9
commit 007ad2c831
9 changed files with 241 additions and 22 deletions
+4 -3
View File
@@ -1,4 +1,5 @@
# InkReach Admin - Vite build served by nginx
# InkReach Admin (v2) - Vite build served by nginx
# v2 部署本地化:与现网共用 official.inkreach.ccSPA 路径挂 /v2/admin/ 下
FROM node:20-alpine AS build
WORKDIR /app
RUN corepack enable
@@ -16,7 +17,7 @@ COPY apps/admin apps/admin
RUN pnpm --filter @inkreach/admin exec vite build
FROM nginx:1.27-alpine
COPY --from=build /app/apps/admin/dist /usr/share/nginx/html/admin
COPY --from=build /app/apps/admin/dist /usr/share/nginx/html/v2/admin
COPY deploy/nginx/admin.conf /etc/nginx/conf.d/default.conf
COPY deploy/h5 /usr/share/nginx/html/h5
COPY deploy/h5 /usr/share/nginx/html/v2/h5
EXPOSE 80
+75
View File
@@ -0,0 +1,75 @@
# v2 部署(refactor/v2 分支):与现网 deploy 项目完全隔离(独立库/独立卷/独立网络),
# 对外复用 official.inkreach.cc 域名,由现网 nginx 按路径分流:
# https://official.inkreach.cc/v2/admin/ -> 本栈 adminSPA
# https://official.inkreach.cc/v2-api/ -> 本栈 api(去掉前缀后转发)
# 本栈两容器挂到外部网络 inkreach-shared,与 deploy-admin-1 互通(别名 v2-api / v2-admin)。
name: deploy-v2
services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: inkreach
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: inkreach
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U inkreach -d inkreach"]
interval: 10s
timeout: 5s
retries: 10
networks:
- default
api:
build:
context: ..
dockerfile: deploy/api.Dockerfile
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 3001
DATABASE_URL: postgresql://inkreach:${POSTGRES_PASSWORD}@postgres:5432/inkreach
JWT_SECRET: ${JWT_SECRET}
CORS_ORIGINS: "*"
# 激活 product-family 聚合公开读路径(现网 v1 未设置,保持旧行为,便于对比)
PUBLIC_DETAIL_FROM_FAMILY: "true"
volumes:
- uploads:/app/uploads
networks:
default:
shared:
aliases:
- v2-api
admin:
build:
context: ..
dockerfile: deploy/admin.Dockerfile
args:
VITE_API_BASE: /v2-api/
restart: unless-stopped
depends_on:
- api
volumes:
- ./nginx/admin.v2.conf:/etc/nginx/conf.d/default.conf:ro
networks:
default:
shared:
aliases:
- v2-admin
networks:
default:
shared:
external: true
name: inkreach-shared
volumes:
pgdata:
uploads:
+1 -1
View File
@@ -1,2 +1,2 @@
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>印美达POD供应链</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/h5/static/index.149e085d.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/h5/static/js/chunk-vendors.6234e216.js></script><script src=/h5/static/js/index.c5073ea1.js></script></body></html>
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/v2/h5/static/index.149e085d.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/v2/h5/static/js/chunk-vendors.6234e216.js></script><script src=/v2/h5/static/js/index.e79d1a25.js></script></body></html>
File diff suppressed because one or more lines are too long
+35
View File
@@ -0,0 +1,35 @@
# v2 部署本地化:这个 nginx 容器只负责把 /v2/admin/ 下的 SPA 静态文件吐出去
# 对外分流由现网 deploy-admin-1 的 nginx 完成(/v2/admin/ 原样透传、/v2-api/ 转发到 v2 api
server {
listen 80;
server_name _;
client_max_body_size 10m;
root /usr/share/nginx/html;
location = /v2 {
return 301 /v2/admin/;
}
location /v2/admin/ {
try_files $uri $uri/ /v2/admin/index.html;
}
# v2 版 H5(构建时 router.base 必须为 /v2/h5/,产物放 /usr/share/nginx/html/v2/h5
location = /v2/h5 {
return 301 /v2/h5/;
}
location = /v2/h5/index.html {
add_header Cache-Control "no-cache";
}
location /v2/h5/ {
try_files $uri $uri/ /v2/h5/index.html;
}
location / {
return 404;
}
}