forked from v-checha/nestjs-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (30 loc) · 868 Bytes
/
Dockerfile
File metadata and controls
45 lines (30 loc) · 868 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
43
44
45
FROM node:18-alpine AS builder
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy the rest of the app
COPY . .
# Generate Prisma client
RUN npx prisma generate
# Build the app
RUN npm run build
# Production stage
FROM node:18-alpine AS production
WORKDIR /app
# Copy package.json and package-lock.json
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy Prisma schema
COPY prisma ./prisma/
# Copy built app from builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
# Expose port
EXPOSE 3000
# Set NODE_ENV to production
ENV NODE_ENV=production
# Run migrations and start the app
CMD ["/bin/sh", "-c", "npx prisma migrate deploy && npm run db:seed && node dist/src/main.js"]