提交
This commit is contained in:
1 parent
5b3edb1700
commit
74e5a0f0cf
30 files changed
+9036
-7974
No files matched your search
@@ -413,12 +413,15 @@ docker compose up -d
|
||||
### 发版方打包时 pip / pnpm 很慢或超时
|
||||
|
||||
- 已默认 **阿里云 PyPI** + **npmmirror**,并启用 BuildKit 缓存。
|
||||
- 若前端构建在 `corepack prepare pnpm@...` 报错(请求 `registry.npmjs.org` 失败),请更新到含 `COREPACK_NPM_REGISTRY` 的 Dockerfile,或手动指定:
|
||||
- 默认 **npmmirror**(`https://registry.npmmirror.com`)。**国内 Intel / Linux 机器不要设 `NPM_REGISTRY=https://registry.npmjs.org`**,该地址在国内常 ETIMEDOUT。
|
||||
- 若 npmmirror 不稳定,可换其它国内源:
|
||||
```bash
|
||||
NPM_REGISTRY=https://registry.npmmirror.com ./scripts/package-docker-deploy.sh v1.0.0
|
||||
NPM_REGISTRY=https://mirrors.cloud.tencent.com/npm/ ./scripts/package-docker-deploy.sh v1.0.0
|
||||
# 或
|
||||
NPM_REGISTRY=https://repo.huaweicloud.com/repository/npm/ ./scripts/package-docker-deploy.sh v1.0.0
|
||||
```
|
||||
- **在 Mac(M 芯片)上交叉构建 `linux/amd64` 很慢**(后端 pip 常见 15~40 分钟),日志会长时间不动,**不要误按 Ctrl+C**。
|
||||
- **推荐**:把仓库放到 **Linux x86 云主机**(与甲方同架构),在该机器执行 `./scripts/package-docker-deploy.sh`,通常 5~15 分钟完成。
|
||||
- 安装 pnpm 失败时 Dockerfile 会自动回退为 tarball 直装;`pnpm install` 出现 ETIMEDOUT 时会重试,日志可能长时间不动,**不要误按 Ctrl+C**。
|
||||
- **在 Mac(M 芯片)上交叉构建 `linux/amd64` 很慢**(后端 pip 常见 15~40 分钟);**Intel Linux 同架构构建**通常 5~15 分钟,推荐在发版机上直接执行 `./scripts/package-docker-deploy.sh v1.0.0`(无需设 `NPM_REGISTRY`)。
|
||||
|
||||
默认已使用阿里云 PyPI(`mirrors.aliyun.com`)。若需改用清华源:
|
||||
|
||||
|
||||
@@ -5,18 +5,35 @@ ARG NGINX_IMAGE=docker.m.daocloud.io/library/nginx:1.27-alpine
|
||||
FROM ${NODE_IMAGE} AS builder
|
||||
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
ARG PNPM_VERSION=9.15.4
|
||||
ARG NODE_MAX_OLD_SPACE_SIZE=4096
|
||||
# corepack 默认走 registry.npmjs.org,国内/受限网络会失败;须显式指定镜像
|
||||
ENV COREPACK_NPM_REGISTRY=${NPM_REGISTRY}
|
||||
ENV NODE_OPTIONS="--max-old-space-size=${NODE_MAX_OLD_SPACE_SIZE}"
|
||||
ENV NODE_ENV=production
|
||||
# 构建阶段须安装 devDependencies(vite 等);勿设 NODE_ENV=production
|
||||
ENV HUSKY=0
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||
# 国内机器勿用 registry.npmjs.org;先走镜像元数据,失败再直装 tarball
|
||||
RUN set -eux; \
|
||||
npm config set registry "${NPM_REGISTRY}"; \
|
||||
npm config set fetch-retries 5; \
|
||||
npm config set fetch-retry-mintimeout 60000; \
|
||||
npm config set fetch-retry-maxtimeout 600000; \
|
||||
npm config set fetch-timeout 600000; \
|
||||
if ! npm install -g "pnpm@${PNPM_VERSION}"; then \
|
||||
echo "npm 元数据安装 pnpm 失败,尝试 tarball: ${NPM_REGISTRY}/pnpm/-/pnpm-${PNPM_VERSION}.tgz"; \
|
||||
npm install -g "${NPM_REGISTRY}/pnpm/-/pnpm-${PNPM_VERSION}.tgz"; \
|
||||
fi; \
|
||||
pnpm --version
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY web-admin/package.json web-admin/pnpm-lock.yaml ./
|
||||
RUN pnpm config set registry "${NPM_REGISTRY}" \
|
||||
# BuildKit 缓存 pnpm store;提高 fetch 重试与超时,缓解 npmmirror ETIMEDOUT
|
||||
RUN --mount=type=cache,id=zkxw-pnpm-store,target=/root/.local/share/pnpm/store \
|
||||
pnpm config set registry "${NPM_REGISTRY}" \
|
||||
&& pnpm config set fetch-retries 5 \
|
||||
&& pnpm config set fetch-retry-mintimeout 60000 \
|
||||
&& pnpm config set fetch-retry-maxtimeout 600000 \
|
||||
&& pnpm config set network-timeout 600000 \
|
||||
&& pnpm install --frozen-lockfile
|
||||
|
||||
COPY web-admin/ .
|
||||
|
||||
Reference in new issue
Block a user