fix(docker): align Dockerfile with web-antdv-next monorepo layout (from feat branch)
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
This commit is contained in:
parent
1014469e11
commit
34645d741f
41
Dockerfile
41
Dockerfile
@ -1,30 +1,47 @@
|
||||
# BuildFlow Web (Vben Admin - web-antd) 多阶段构建
|
||||
# BuildFlow Web (web-antdv-next / @vben/web-antdv-next) 多阶段构建
|
||||
# 第一阶段:Node 22 构建 SPA 产物;第二阶段:Nginx 托管静态资源
|
||||
# base 镜像走 Harbor Proxy Cache(dockerhub-proxy → docker.io),避免公网拉取超时
|
||||
FROM node:22-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# 全局装 pnpm (与项目对齐)
|
||||
RUN npm install -g pnpm@9
|
||||
# 装 git + 设 CI=true:lefthook 的 prepare 钩子(is-ci || lefthook install)在 CI 环境
|
||||
# 会因 is-ci 短路跳过;docker build 无 .git 目录,lefthook install 会 fatal
|
||||
RUN apk add --no-cache git
|
||||
ENV CI=true
|
||||
|
||||
# 先拷依赖清单利用层缓存
|
||||
# 全局装 pnpm(与本地 11.x 对齐;corepack 在 alpine 上不可靠)
|
||||
RUN npm install -g pnpm@11
|
||||
|
||||
# npm 包源走阿里 npmmirror(国内最稳,避免 registry.npmjs.org 拉取 error 23)
|
||||
# 调大 fetch 超时与重试:npmmirror 带宽有限,默认超时会致 1622 包 install 中断
|
||||
RUN pnpm config set registry https://registry.npmmirror.com \
|
||||
&& pnpm config set fetch-timeout 600000 \
|
||||
&& pnpm config set fetch-retries 5 \
|
||||
&& pnpm config set fetch-retry-factor 2 \
|
||||
&& pnpm config set fetch-retry-mintimeout 10000 \
|
||||
&& pnpm config set fetch-retry-maxtimeout 60000
|
||||
|
||||
# 先拷依赖清单利用层缓存(pnpm workspace + turbo 需要这些清单文件齐备)
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
|
||||
COPY apps/web-antd/package.json ./apps/web-antd/package.json
|
||||
|
||||
# 拷贝 internal/scripts (turbo/vsh 工具链需要)
|
||||
COPY internal/ ./internal/
|
||||
COPY scripts/ ./scripts/
|
||||
COPY apps/web-antdv-next/package.json ./apps/web-antdv-next/package.json
|
||||
|
||||
# 拷贝其余 packages 的 package.json(workspace 依赖解析需要),但不拷 node_modules
|
||||
COPY packages/ ./packages/
|
||||
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# 拷贝全部源码
|
||||
COPY . .
|
||||
|
||||
# 构建 web-antd 变体 (质量门禁: lint + typecheck 内含于 build)
|
||||
RUN pnpm build:antd
|
||||
# 构建 web-antdv-next 变体(turbo 按 workspace 名过滤;质量门禁内含 typecheck)
|
||||
RUN pnpm run build --filter=@vben/web-antdv-next...
|
||||
|
||||
# ---- 运行阶段: nginx 托管静态资源 ----
|
||||
# ---- 运行阶段:Nginx 托管静态资源 ----
|
||||
FROM nginx:1.27-alpine AS runtime
|
||||
COPY apps/web-antd/nginx.conf /etc/nginx/conf.d/default.conf 2>/dev/null || true
|
||||
COPY --from=builder /app/apps/web-antd/dist /usr/share/nginx/html
|
||||
COPY apps/web-antdv-next/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=builder /app/apps/web-antdv-next/dist /usr/share/nginx/html
|
||||
EXPOSE 80
|
||||
HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD wget -q --spider http://127.0.0.1/ || exit 1
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user