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>
45 lines
1.3 KiB
Docker
45 lines
1.3 KiB
Docker
# میرور npm برای سرورهای ایران
|
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
|
|
|
FROM node:22-alpine AS builder
|
|
# حتماً دوباره با default تعریف شود؛ وگرنه بعد از FROM خالی میماند
|
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
|
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"
|
|
|
|
COPY prisma ./prisma
|
|
COPY prisma.config.ts ./
|
|
COPY tsconfig.json tsconfig.build.json nest-cli.json ./
|
|
COPY src ./src
|
|
|
|
RUN npx prisma generate \
|
|
&& npm run build \
|
|
&& npm prune --omit=dev \
|
|
&& npm install prisma ts-node typescript --no-save --no-audit --no-fund --registry=${NPM_REGISTRY}
|
|
|
|
FROM node:22-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
COPY --from=builder /app/package.json /app/package-lock.json ./
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/prisma.config.ts ./
|
|
COPY docker-entrypoint.sh ./
|
|
|
|
RUN chmod +x docker-entrypoint.sh
|
|
|
|
EXPOSE 3000
|
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|