-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.prod
More file actions
42 lines (30 loc) · 926 Bytes
/
Dockerfile.prod
File metadata and controls
42 lines (30 loc) · 926 Bytes
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
# Stage 1: Build the application
FROM node:21-alpine AS builder
# Create app directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install all dependencies to build the application
RUN npm install
# Copy the rest of the application source code
COPY . .
# Generate the Prisma database client
RUN npx prisma generate
# Build the application
RUN npm run build
# Stage 2: Create a smaller image for production
FROM node:21-alpine
# Create app directory
WORKDIR /app
# Copy only the necessary files from the build stage
COPY --from=builder /app/package*.json /app/
COPY --from=builder /app/dist /app/dist
COPY --from=builder /app/prisma /app/prisma
COPY --from=builder /app/node_modules /app/node_modules
# Expose the API port
EXPOSE 9000
# Use the custom entrypoint script
COPY entrypoint.sh /app/
ENTRYPOINT ["/app/entrypoint.sh"]
# Run the application
CMD ["node", "dist/main.js"]