Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (43 loc) · 1.25 KB
/
Copy pathDockerfile
File metadata and controls
62 lines (43 loc) · 1.25 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Build stage
FROM node:20.19-alpine AS builder
WORKDIR /app
# Copy package files first for better caching
COPY package*.json ./
# Install ALL dependencies (including devDependencies for build)
RUN npm ci
# Copy prisma schema and generate client
COPY prisma ./prisma/
COPY prisma.config.ts ./
RUN npx prisma generate
# Copy all source files
COPY tsconfig*.json ./
COPY nest-cli.json ./
COPY src ./src/
# Build the application
RUN npm run build || (echo "Build failed" && exit 1)
# Verify build output exists and show structure
RUN ls -la dist/ && ls -la dist/src/main.js || (echo "main.js not found in dist/src" && exit 1)
# Production stage
FROM node:20.19-alpine AS production
WORKDIR /app
# Install curl for healthcheck
RUN apk add --no-cache curl
# Copy package files
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy prisma files for client
COPY prisma ./prisma/
COPY prisma.config.ts ./
# Re-generate Prisma client in production context
RUN npx prisma generate
# Copy built application from builder
COPY --from=builder /app/dist ./dist
# Verify dist exists
RUN ls -la dist/
# Expose port
EXPOSE 3000
# Set production environment
ENV NODE_ENV=production
# Start the application
CMD ["node", "dist/src/main.js"]