-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Dockerfile
40 lines (29 loc) · 979 Bytes
/
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
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
COPY prisma ./prisma/
# Install the app dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Run the prisma generator
RUN npm run prisma:gen
# Build the application
RUN npm run build
# Stage 2: A minimal Docker image with node and compiled app
FROM node:18
# Set the working directory inside the container
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/tsconfig.* ./
COPY --from=builder /app/common ./common
# Expose the port that your NestJS app will listen on
EXPOSE 3000
# Start the application in production mode
CMD ["npm", "run", "start:prod"]