-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
48 lines (34 loc) · 1.01 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
41
42
43
44
45
46
47
48
# Use a smaller base image for building the application
FROM node:20-alpine AS builder
WORKDIR /usr/src/app
# Install dependencies
COPY package*.json ./
RUN npm ci
# Copy prisma schema
COPY prisma ./prisma/
# Generate Prisma client
RUN npx prisma generate
# Copy the rest of the application code
COPY . .
# Build the TypeScript code
RUN npm run build
# Use a lighter base image for the final stage
FROM node:20-alpine
WORKDIR /usr/src/app
# Copy package.json and package-lock.json
COPY package*.json ./
# Copy prisma schema and generated client
COPY prisma ./prisma/
COPY --from=builder /usr/src/app/node_modules/.prisma ./node_modules/.prisma
# Copy built application
COPY --from=builder /usr/src/app/dist ./dist
# Copy the .env file
COPY .env .env
# Install only production dependencies
RUN npm ci --only=production && npm cache clean --force
# Generate Prisma client again in the final stage
RUN npx prisma generate
# Expose the port the app runs on
EXPOSE 5000
# Command to run the application
CMD ["npm", "start"]