-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (33 loc) · 1.01 KB
/
Copy pathDockerfile
File metadata and controls
44 lines (33 loc) · 1.01 KB
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
# Stage 1: Build
FROM node:20-slim AS builder
WORKDIR /app
# Install dependencies
COPY package*.json ./
COPY prisma ./prisma/
RUN npm install
# Copy source and build
COPY . .
RUN npm run build
# Stage 2: Run
FROM node:20-slim
WORKDIR /app
# Install curl for healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
# Copy production dependencies
COPY package*.json ./
COPY prisma ./prisma/
RUN npm install --omit=dev
# Copy built assets
COPY --from=builder /app/dist ./dist
# Prisma engine and generated client are needed
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
# Need prisma for the auto-migration in src/index.ts
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3002
ENV HOST=0.0.0.0
EXPOSE 3002
# Startup script ensures DB is ready (handled in src/index.ts via execSync)
CMD ["npm", "start"]