This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
coverage
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
*.md
|
||||||
|
todo.mdb
|
||||||
+19
-54
@@ -1,79 +1,44 @@
|
|||||||
# Stage 1: Base
|
# Stage 1: Base
|
||||||
FROM node:22-alpine AS base
|
FROM node:22-alpine AS base
|
||||||
|
|
||||||
# Install timezone support
|
# Use Alpine mirror
|
||||||
RUN apk add --no-cache tzdata
|
RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirror.de.velop.ir/alpine|g' /etc/apk/repositories
|
||||||
RUN cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && echo "Asia/Tehran" > /etc/timezone
|
|
||||||
|
# Configure npm registry mirror
|
||||||
|
ENV NPM_CONFIG_REGISTRY=https://package-mirror.liara.ir/repository/npm/
|
||||||
|
RUN npm config set registry https://package-mirror.liara.ir/repository/npm/
|
||||||
|
|
||||||
|
RUN apk add --no-cache tzdata
|
||||||
|
|
||||||
|
ENV TZ=Asia/Tehran
|
||||||
|
|
||||||
# Set workdir for clarity
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Stage 2: Dependencies
|
# Stage 2: Dependencies (full install for build)
|
||||||
FROM base AS deps
|
FROM base AS deps
|
||||||
WORKDIR /temp-deps
|
WORKDIR /temp-deps
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci --ignore-scripts
|
RUN npm ci
|
||||||
|
|
||||||
# Stage 3: Build
|
# Stage 3: Build
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY . ./
|
COPY . .
|
||||||
COPY --from=deps /temp-deps/node_modules ./node_modules
|
COPY --from=deps /temp-deps/node_modules ./node_modules
|
||||||
RUN if [ -f package.json ] && grep -q '"build":' package.json; then npm run build; fi
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 4: Runner
|
# Stage 4: Runner
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . ./
|
COPY package*.json ./
|
||||||
COPY --from=builder --chown=appuser:appgroup /build/ ./
|
RUN npm ci --omit=dev && npm cache clean --force
|
||||||
RUN chown -R appuser:appgroup /app
|
|
||||||
|
COPY --from=builder --chown=appuser:appgroup /build/dist ./dist
|
||||||
|
|
||||||
USER appuser
|
USER appuser
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
EXPOSE 4000
|
EXPOSE 4000
|
||||||
|
|
||||||
CMD ["npm", "start"]
|
CMD ["node", "--max-old-space-size=2048", "dist/src/main"]
|
||||||
|
|
||||||
# # Stage 1: Build Stage
|
|
||||||
# FROM node:22-alpine AS base
|
|
||||||
|
|
||||||
# RUN npm install -g corepack@latest
|
|
||||||
# RUN corepack enable && corepack prepare pnpm@9 --activate
|
|
||||||
|
|
||||||
# # Install tzdata to support timezone settings
|
|
||||||
# RUN apk add --no-cache tzdata
|
|
||||||
|
|
||||||
# # Set the timezone to Asia/Tehran
|
|
||||||
# RUN cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && echo "Asia/Tehran" > /etc/timezone
|
|
||||||
|
|
||||||
|
|
||||||
# FROM base AS deps
|
|
||||||
# WORKDIR /temp-deps
|
|
||||||
# COPY package*.json pnpm-lock.yaml ./
|
|
||||||
# RUN pnpm install --frozen-lockfile --loglevel info
|
|
||||||
|
|
||||||
|
|
||||||
# FROM base AS builder
|
|
||||||
# WORKDIR /build
|
|
||||||
# COPY . ./
|
|
||||||
# COPY --from=deps /temp-deps/node_modules ./node_modules
|
|
||||||
# RUN if [ -f package.json ] && grep -q '"build":' package.json; then pnpm run build; fi
|
|
||||||
# RUN pnpm install --prod --frozen-lockfile --loglevel info
|
|
||||||
|
|
||||||
# FROM base AS runner
|
|
||||||
# RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
||||||
# WORKDIR /app
|
|
||||||
|
|
||||||
# COPY . ./
|
|
||||||
# COPY --from=builder --chown=appuser:appgroup /build/ ./
|
|
||||||
|
|
||||||
# RUN chown -R appuser:appgroup /app
|
|
||||||
|
|
||||||
# USER appuser
|
|
||||||
|
|
||||||
# ENV NODE_ENV=production
|
|
||||||
# EXPOSE 3000
|
|
||||||
|
|
||||||
# CMD ["npm", "start"]
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
"start": "nest start dist/main",
|
"start": "nest start dist/main",
|
||||||
"start:dev": "nest start --watch",
|
"start:dev": "nest start --watch",
|
||||||
"start:debug": "nest start --debug --watch",
|
"start:debug": "nest start --debug --watch",
|
||||||
"start:prod": "node --max-old-space-size=2048 dist/main",
|
"start:prod": "node --max-old-space-size=2048 dist/src/main",
|
||||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
|
|||||||
Reference in New Issue
Block a user