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:
2026-08-05 20:54:35 +03:30
co-authored by Cursor
parent 5ed1b83457
commit 5e973d7f2c
3 changed files with 23 additions and 10 deletions
+4
View File
@@ -8,6 +8,10 @@ POSTGRES_DB=fabric_trade
POSTGRES_PORT=5432
API_PORT=3000
RUN_SEED=false
# مخزن npm ایرانی برای بیلد Docker
NPM_REGISTRY=https://mirror.iranserver.com/npm/
# اگر Bake/buildx ارور داد:
COMPOSE_BAKE=false
JWT_SECRET="fabric-trade-dev-secret-change-me"
JWT_EXPIRES_IN="7d"
+18 -9
View File
@@ -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 ./
+1 -1
View File
@@ -22,7 +22,7 @@ services:
context: .
dockerfile: Dockerfile
args:
NPM_REGISTRY: ${NPM_REGISTRY:-https://registry.npmmirror.com}
NPM_REGISTRY: ${NPM_REGISTRY:-https://mirror.iranserver.com/npm/}
container_name: fabric_trade_api
restart: unless-stopped
depends_on: