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:
lzh
2026-04-28 14:40:47 +08:00
parent e783d40a31
commit 2fa613fd44
6 changed files with 503 additions and 6 deletions

60
Dockerfile Normal file
View File

@@ -0,0 +1,60 @@
# ==============================
# 1⃣ 构建阶段
# ==============================
FROM node:20-alpine AS builder
WORKDIR /app
# ------------------------------
# npm / pnpm registry 配置
# ------------------------------
RUN npm config set registry https://registry.npmmirror.com && \
echo "registry=https://registry.npmmirror.com" > ~/.npmrc
# pnpm registry 默认指向 1Panel 内部的 Verdaccio与 vben 前端共用)
# 如果 Jenkins 容器不在 1panel-network 网络里,可以通过 build-arg 覆盖:
# docker build --build-arg PNPM_REGISTRY=https://registry.npmmirror.com ...
ARG PNPM_REGISTRY=http://1Panel-verdaccio-Ynee:4873/
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable && corepack prepare pnpm@10.22.0 --activate
RUN pnpm config set registry $PNPM_REGISTRY
RUN pnpm config set store-dir /pnpm/store
# ------------------------------
# 复制源码
# ------------------------------
COPY package.json pnpm-lock.yaml turbo.json pnpm-workspace.yaml ./
COPY packages packages
COPY apps apps
COPY internal internal
# ------------------------------
# 安装依赖 + 构建
# network-concurrency 限制并发下载,降低 CI 带宽占用
# ------------------------------
RUN --mount=type=cache,id=pnpm-store,target=/pnpm/store \
pnpm install --frozen-lockfile --network-concurrency 2
# 限制 turbo 并发与 Node 内存,避免在 8GB 服务器上 OOM
ENV NODE_OPTIONS="--max-old-space-size=1024 --expose-gc"
ENV UV_THREADPOOL_SIZE=2
RUN pnpm exec turbo build --filter=@vben/web-antd --concurrency=1
# ==============================
# 2⃣ 运行阶段
# ==============================
FROM nginx:alpine
# 移除默认配置
RUN rm /etc/nginx/conf.d/default.conf
# 复制自定义 Nginx 配置(含 /admin-api 反代到后端 gateway
COPY apps/web-antd/nginx.conf /etc/nginx/conf.d/default.conf
# 复制构建产物
COPY --from=builder /app/apps/web-antd/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]