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:
@@ -8,6 +8,10 @@ POSTGRES_DB=fabric_trade
|
|||||||
POSTGRES_PORT=5432
|
POSTGRES_PORT=5432
|
||||||
API_PORT=3000
|
API_PORT=3000
|
||||||
RUN_SEED=false
|
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_SECRET="fabric-trade-dev-secret-change-me"
|
||||||
JWT_EXPIRES_IN="7d"
|
JWT_EXPIRES_IN="7d"
|
||||||
|
|||||||
+18
-9
@@ -1,19 +1,28 @@
|
|||||||
# میرور npm برای سرورهای ایران
|
# مخزن npm ایرانی (قابل تغییر با --build-arg)
|
||||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
ARG NPM_REGISTRY=https://mirror.iranserver.com/npm/
|
||||||
|
|
||||||
FROM node:22-alpine AS builder
|
FROM node:22-alpine AS builder
|
||||||
# حتماً دوباره با default تعریف شود؛ وگرنه بعد از FROM خالی میماند
|
ARG NPM_REGISTRY=https://mirror.iranserver.com/npm/
|
||||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm config set fetch-retries 5 \
|
|
||||||
&& npm config set fetch-retry-mintimeout 20000 \
|
# npm ci از URLهای داخل package-lock استفاده میکند؛ باید میرور ایرانی شود
|
||||||
&& npm config set fetch-retry-maxtimeout 120000 \
|
RUN set -eux; \
|
||||||
&& npm ci --no-audit --no-fund \
|
mirror="$(echo "${NPM_REGISTRY}" | sed 's:/*$::')"; \
|
||||||
&& echo "npm ci done via $NPM_CONFIG_REGISTRY"
|
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 ./prisma
|
||||||
COPY prisma.config.ts ./
|
COPY prisma.config.ts ./
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
NPM_REGISTRY: ${NPM_REGISTRY:-https://registry.npmmirror.com}
|
NPM_REGISTRY: ${NPM_REGISTRY:-https://mirror.iranserver.com/npm/}
|
||||||
container_name: fabric_trade_api
|
container_name: fabric_trade_api
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user