-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
40 lines (30 loc) · 1.19 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Use an official Node.js runtime as the base image
FROM node:18 AS builder
# Install pnpm and set the working directory inside the container
RUN npm install -g pnpm && mkdir -p /app
WORKDIR /app
# Copy package.json, pnpm-lock.yaml, and prisma directory to the working directory
COPY package.json pnpm-lock.yaml prisma ./
# Install the app dependencies
RUN pnpm install
# Copy the rest of the application code
COPY . .
# Run the prisma generator and build the application
RUN pnpm run prisma:gen && pnpm run build
# Stage 2: A minimal Docker image with node and compiled app
FROM node:18
# Install pnpm and set the working directory inside the container
RUN npm install -g pnpm && mkdir -p /app
WORKDIR /app
# Copy the necessary files from the builder stage
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/tsconfig.* ./
COPY --from=builder /app/src/common ./src/common
# Expose the port that your NestJS app will listen on
EXPOSE 3000
# Start the application in production mode
CMD ["pnpm", "run", "start:prod"]