fix(devops): web Dockerfile 补 mkdir public,修复无 public 目录时容器构建失败
This commit is contained in:
@@ -1,17 +1,30 @@
|
||||
FROM node:22-slim AS build
|
||||
RUN corepack enable
|
||||
WORKDIR /app
|
||||
# npm/corepack registry(可经 build arg 覆盖):部分区域 registry.npmjs.org 不可达,部署时指向镜像
|
||||
# (如 registry.npmmirror.com,整源镜像 npmjs 且保留 integrity,与 --frozen-lockfile 兼容)。
|
||||
ARG NPM_REGISTRY=https://registry.npmjs.org
|
||||
ENV npm_config_registry=$NPM_REGISTRY
|
||||
# corepack 默认硬编码从 npmjs 下载 pnpm 本体;此处改指同一镜像。镜像不提供 npm 签名密钥,
|
||||
# 关掉签名校验(下载的 pnpm tarball 仍按内容哈希校验,安装的依赖仍按 lockfile integrity 校验)。
|
||||
ENV COREPACK_NPM_REGISTRY=$NPM_REGISTRY
|
||||
ENV COREPACK_INTEGRITY_KEYS=0
|
||||
RUN corepack enable
|
||||
# pnpm-workspace.yaml 必须在 install 前就位:它携带 minimumReleaseAgeExclude(豁免新发布包的
|
||||
# 供应链策略)、onlyBuiltDependencies/allowBuilds(构建脚本白名单)。缺它则容器内 install 看不到
|
||||
# 这些策略,会误拒近期发布的依赖(如 @xyflow/*)而失败——与宿主行为不一致。
|
||||
COPY package.json pnpm-lock.yaml* pnpm-workspace.yaml ./
|
||||
RUN pnpm install --frozen-lockfile || pnpm install
|
||||
# pnpm 11 不读 npm_config_registry env,须用 --registry 显式指定镜像(lockfile v9 仅存 integrity,
|
||||
# 不含绝对 URL,故换源不破坏 --frozen-lockfile)。
|
||||
RUN pnpm install --frozen-lockfile --registry="$NPM_REGISTRY" || pnpm install --registry="$NPM_REGISTRY"
|
||||
COPY . .
|
||||
# NEXT_PUBLIC_* 在 Next 构建期内联进浏览器 bundle——必须在 `pnpm build` 前用 build ARG 注入。
|
||||
# 默认 http://localhost:8000 供 dev;生产经 compose build args 传公网 API 基址。
|
||||
ARG NEXT_PUBLIC_API_BASE=http://localhost:8000
|
||||
ENV NEXT_PUBLIC_API_BASE=$NEXT_PUBLIC_API_BASE
|
||||
RUN pnpm build
|
||||
# 本项目 public/ 为空目录(不入 git,git archive 构建上下文里不存在);确保它存在,
|
||||
# 否则下方 run 阶段 `COPY --from=build /app/public` 会因源缺失而失败。
|
||||
RUN mkdir -p /app/public
|
||||
|
||||
FROM node:22-slim AS run
|
||||
WORKDIR /app
|
||||
|
||||
Reference in New Issue
Block a user