Use Iranian npm mirror and rewrite package-lock URLs
npm ci ignores registry config when lockfile points at registry.npmjs.org; rewrite resolved URLs to mirror.iranserver.com before install. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+18
-9
@@ -1,19 +1,28 @@
|
||||
# میرور npm برای سرورهای ایران
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
# مخزن npm ایرانی (قابل تغییر با --build-arg)
|
||||
ARG NPM_REGISTRY=https://mirror.iranserver.com/npm/
|
||||
|
||||
FROM node:22-alpine AS builder
|
||||
# حتماً دوباره با default تعریف شود؛ وگرنه بعد از FROM خالی میماند
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
ARG NPM_REGISTRY=https://mirror.iranserver.com/npm/
|
||||
WORKDIR /app
|
||||
|
||||
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm config set fetch-retries 5 \
|
||||
&& npm config set fetch-retry-mintimeout 20000 \
|
||||
&& npm config set fetch-retry-maxtimeout 120000 \
|
||||
&& npm ci --no-audit --no-fund \
|
||||
&& echo "npm ci done via $NPM_CONFIG_REGISTRY"
|
||||
|
||||
# npm ci از URLهای داخل package-lock استفاده میکند؛ باید میرور ایرانی شود
|
||||
RUN set -eux; \
|
||||
mirror="$(echo "${NPM_REGISTRY}" | sed 's:/*$::')"; \
|
||||
sed -i \
|
||||
-e "s|https://registry.npmjs.org|${mirror}|g" \
|
||||
-e "s|https://registry.npmmirror.com|${mirror}|g" \
|
||||
package-lock.json; \
|
||||
npm config set registry "${mirror}/"; \
|
||||
npm config set fetch-retries 5; \
|
||||
npm config set fetch-retry-mintimeout 20000; \
|
||||
npm config set fetch-retry-maxtimeout 120000; \
|
||||
echo "Using npm registry: ${mirror}"; \
|
||||
npm ci --no-audit --no-fund; \
|
||||
echo "npm ci done"
|
||||
|
||||
COPY prisma ./prisma
|
||||
COPY prisma.config.ts ./
|
||||
|
||||
Reference in New Issue
Block a user