添加 CI/CD 构建配置与部署文件

- deploy/Dockerfile:多阶段构建,node:24-alpine(阿里镜像)构建
  dist,nginx:alpine 作为成品镜像;构建上下文为仓库根目录
- deploy/nginx.conf:Vue Router history 模式 SPA 配置,含 gzip
  压缩和 /assets/ 长期缓存
- deploy/compose.yaml:以 zhican-admin:latest 启动服务,对外暴露
  12801 端口
- .teamcity/pipeline.yaml:main 分支触发,build/deploy 独立 step

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
SkyJourney
2026-04-08 17:36:10 +08:00
co-authored by Claude Sonnet 4.6
parent c8a18c9ec3
commit a6afbcffeb
4 changed files with 107 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
# 构建上下文为仓库根目录
# docker build -f deploy/Dockerfile -t zhican-admin:latest .
# ────────────────────────────────────────────
# Stage 1: 构建阶段
# ────────────────────────────────────────────
FROM node:24-alpine AS builder
WORKDIR /app
# 配置阿里 npm 镜像,加速依赖安装
RUN npm config set registry https://registry.npmmirror.com
# 安装 pnpm 并配置镜像
RUN npm install -g pnpm && pnpm config set registry https://registry.npmmirror.com
# 优先复制依赖描述文件,利用 Docker 层缓存
COPY zhican/admin/package.json zhican/admin/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# 复制源码并构建
COPY zhican/admin/ .
RUN pnpm run build
# ────────────────────────────────────────────
# Stage 2: 成品阶段
# ────────────────────────────────────────────
FROM nginx:alpine AS runner
# 移除默认站点配置
RUN rm /etc/nginx/conf.d/default.conf
# 注入自定义 nginx 配置
COPY deploy/nginx.conf /etc/nginx/conf.d/zhican-admin.conf
# 拷贝构建产物
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]