2026-08-05 21:00:13 +03:30
|
|
|
# میرور کامل و سازگار با ساختار registry.npmjs.org
|
|
|
|
|
# (mirror.iranserver.com/npm ناقص است و خیلی پکیجها 404 میدهد)
|
|
|
|
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
2026-08-05 20:37:59 +03:30
|
|
|
|
2026-08-05 20:26:39 +03:30
|
|
|
FROM node:22-alpine AS builder
|
2026-08-05 21:00:13 +03:30
|
|
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
2026-08-05 20:26:39 +03:30
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-08-05 20:37:59 +03:30
|
|
|
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
|
|
|
|
|
2026-08-05 20:26:39 +03:30
|
|
|
COPY package.json package-lock.json ./
|
2026-08-05 20:54:35 +03:30
|
|
|
|
2026-08-05 21:00:13 +03:30
|
|
|
# npm ci از URLهای resolved داخل lockfile استفاده میکند
|
2026-08-05 20:54:35 +03:30
|
|
|
RUN set -eux; \
|
|
|
|
|
mirror="$(echo "${NPM_REGISTRY}" | sed 's:/*$::')"; \
|
|
|
|
|
sed -i \
|
|
|
|
|
-e "s|https://registry.npmjs.org|${mirror}|g" \
|
2026-08-05 21:00:13 +03:30
|
|
|
-e "s|https://mirror.iranserver.com/npm|${mirror}|g" \
|
2026-08-05 20:54:35 +03:30
|
|
|
package-lock.json; \
|
2026-08-05 21:00:13 +03:30
|
|
|
npm config set registry "${mirror}"; \
|
2026-08-05 20:54:35 +03:30
|
|
|
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"
|
2026-08-05 20:26:39 +03:30
|
|
|
|
|
|
|
|
COPY prisma ./prisma
|
|
|
|
|
COPY prisma.config.ts ./
|
|
|
|
|
COPY tsconfig.json tsconfig.build.json nest-cli.json ./
|
|
|
|
|
COPY src ./src
|
|
|
|
|
|
2026-08-05 20:37:59 +03:30
|
|
|
RUN npx prisma generate \
|
|
|
|
|
&& npm run build \
|
|
|
|
|
&& npm prune --omit=dev \
|
2026-08-05 20:49:49 +03:30
|
|
|
&& npm install prisma ts-node typescript --no-save --no-audit --no-fund --registry=${NPM_REGISTRY}
|
2026-08-05 20:26:39 +03:30
|
|
|
|
|
|
|
|
FROM node:22-alpine AS runner
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
|
2026-08-05 20:37:59 +03:30
|
|
|
COPY --from=builder /app/package.json /app/package-lock.json ./
|
|
|
|
|
COPY --from=builder /app/node_modules ./node_modules
|
2026-08-05 20:26:39 +03:30
|
|
|
COPY --from=builder /app/dist ./dist
|
2026-08-05 20:37:59 +03:30
|
|
|
COPY --from=builder /app/prisma ./prisma
|
|
|
|
|
COPY --from=builder /app/prisma.config.ts ./
|
2026-08-05 20:26:39 +03:30
|
|
|
COPY docker-entrypoint.sh ./
|
|
|
|
|
|
2026-08-05 20:37:59 +03:30
|
|
|
RUN chmod +x docker-entrypoint.sh
|
2026-08-05 20:26:39 +03:30
|
|
|
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|