-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
47 lines (34 loc) · 1012 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
41
42
43
44
45
46
47
# Step 1: Builder Stage
FROM node:20-alpine AS builder
# Set the working directory
WORKDIR /app
# Install OpenSSL and other build dependencies
RUN apk add --no-cache openssl
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the Prisma schema and generate the Prisma client
COPY prisma ./prisma
COPY .env .env
RUN npx prisma generate
RUN npx prisma db push
# Copy the application code
COPY . .
# Build the application
RUN npm run build
# Step 2: Production Stage
FROM node:20-alpine AS production
# Set the working directory
WORKDIR /app
# Install OpenSSL in the production stage
RUN apk add --no-cache openssl
# Copy only the necessary files from the builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.env .env
# Expose the application's port
EXPOSE 8080
# Start the application in production mode
CMD ["node", "dist/main"]