-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (27 loc) · 956 Bytes
/
Dockerfile
File metadata and controls
40 lines (27 loc) · 956 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
# --- Stage 1: Build the application ---
FROM node:22-alpine AS builder
WORKDIR /usr/src/app
# Copy package files and prisma schema
COPY package*.json ./
COPY prisma ./prisma/
# Install ALL dependencies (including dev dependencies)
RUN npm install
# Explicitly generate the Prisma client to create all the necessary types
RUN npx prisma generate
# Copy the rest of your source code
COPY . .
# Build the TypeScript project
RUN npm run build
# Remove development dependencies to prepare for the final image
RUN npm prune --production
# --- Stage 2: Create the final, lightweight image ---
FROM node:22-alpine
WORKDIR /usr/src/app
# Copy only the necessary files from the 'builder' stage
COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/prisma ./prisma
# Expose the port your app will run on
EXPOSE 3000
# Start the server
CMD [ "node", "dist/server.js" ]