Build on the developer machine without Docker, commit dist/, and run on the server with Dockerfile.dist plus compose env_file. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
996 B
Docker
33 lines
996 B
Docker
# ایمیج اجرا: dist از گیت میآید، فقط dependencyهای production نصب میشود
|
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
|
|
|
FROM node:22-alpine
|
|
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
|
|
|
COPY package.json package-lock.json ./
|
|
COPY prisma ./prisma
|
|
COPY prisma.config.ts ./
|
|
|
|
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 ci --omit=dev --no-audit --no-fund; \
|
|
npm install prisma ts-node typescript --no-save --no-audit --no-fund --registry="${mirror}"; \
|
|
npx prisma generate
|
|
|
|
# بیلد لوکال که داخل گیت است
|
|
COPY dist ./dist
|
|
COPY docker-entrypoint.sh ./
|
|
RUN chmod +x docker-entrypoint.sh
|
|
|
|
EXPOSE 3000
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|