Fix npm registry ARG so builds use npmmirror by default
ARG after FROM was empty without an explicit default, so npm ci hit the slow/blocked official registry. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+9
-8
@@ -1,17 +1,19 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# میرور npm برای سرورهای ایران
|
||||||
|
|
||||||
# میرور npm برای سرورهای ایران (قابل تغییر با --build-arg)
|
|
||||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||||
|
|
||||||
FROM node:22-alpine AS builder
|
FROM node:22-alpine AS builder
|
||||||
ARG NPM_REGISTRY
|
# حتماً دوباره با default تعریف شود؛ وگرنه بعد از FROM خالی میماند
|
||||||
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# openssl از قبل داخل node:alpine هست؛ apk را حذف کردیم چون CDN آلپاین روی خیلی از سرورها TLS error میدهد
|
|
||||||
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 ci
|
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"
|
||||||
|
|
||||||
COPY prisma ./prisma
|
COPY prisma ./prisma
|
||||||
COPY prisma.config.ts ./
|
COPY prisma.config.ts ./
|
||||||
@@ -21,9 +23,8 @@ COPY src ./src
|
|||||||
RUN npx prisma generate \
|
RUN npx prisma generate \
|
||||||
&& npm run build \
|
&& npm run build \
|
||||||
&& npm prune --omit=dev \
|
&& npm prune --omit=dev \
|
||||||
&& npm install prisma ts-node typescript --no-save --registry=${NPM_REGISTRY}
|
&& npm install prisma ts-node typescript --no-save --no-audit --no-fund --registry=${NPM_REGISTRY}
|
||||||
|
|
||||||
# Production image — بدون apk / بدون npm دوباره
|
|
||||||
FROM node:22-alpine AS runner
|
FROM node:22-alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
NPM_REGISTRY: ${NPM_REGISTRY:-https://registry.npmmirror.com}
|
||||||
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