This commit is contained in:
+9
-12
@@ -1,7 +1,6 @@
|
||||
FROM node:20-alpine AS base
|
||||
|
||||
ENV TZ=Asia/Tehran
|
||||
ENV NODE_ENV=production
|
||||
|
||||
RUN apk add --no-cache tzdata
|
||||
RUN corepack enable
|
||||
@@ -10,14 +9,16 @@ WORKDIR /app
|
||||
|
||||
|
||||
# -----------------------
|
||||
# Install ALL dependencies (important for build)
|
||||
# Install ALL dependencies (dev + prod) for the build
|
||||
# -----------------------
|
||||
FROM base AS deps
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
# IMPORTANT: force devDependencies inclusion
|
||||
RUN yarn install --frozen-lockfile --production=false
|
||||
# NODE_ENV must not be "production" here — otherwise devDependencies
|
||||
# (e.g. @nestjs/cli) are skipped and "nest build" fails.
|
||||
ENV NODE_ENV=development
|
||||
RUN yarn install --frozen-lockfile
|
||||
|
||||
|
||||
# -----------------------
|
||||
@@ -27,17 +28,12 @@ FROM base AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=development
|
||||
|
||||
COPY package.json yarn.lock nest-cli.json tsconfig.json tsconfig.build.json ./
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY src ./src
|
||||
|
||||
# 🔥 GUARANTEE nest CLI exists (fixes your error)
|
||||
RUN yarn add -D @nestjs/cli
|
||||
|
||||
# 🔥 SAFETY CHECK (optional but helpful)
|
||||
RUN npx nest --version
|
||||
|
||||
# Build
|
||||
RUN yarn build \
|
||||
&& mkdir -p dist/config \
|
||||
&& cp src/config/swagger.json dist/config/
|
||||
@@ -50,6 +46,7 @@ FROM base AS prod-deps
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
|
||||
ENV NODE_ENV=production
|
||||
RUN yarn install --frozen-lockfile --production=true
|
||||
|
||||
|
||||
@@ -72,4 +69,4 @@ USER appuser
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "dist/main"]
|
||||
CMD ["node", "dist/main"]
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user