-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (43 loc) · 1.51 KB
/
Dockerfile
File metadata and controls
61 lines (43 loc) · 1.51 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
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY yarn.lock* ./
# Install dependencies
RUN yarn install --frozen-lockfile
# Copy source code
COPY . .
# Generate Prisma Client
# Note: prisma generate doesn't need DATABASE_URL, but prisma.config.ts requires it
# So we set a dummy value just for the build stage
ENV DATABASE_URL=postgresql://dummy:dummy@dummy:5432/dummy
RUN npx prisma generate
# Build application
RUN yarn build
# Production stage
FROM node:20-alpine AS production
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY yarn.lock* ./
# Install only production dependencies
RUN yarn install --frozen-lockfile --production && \
yarn cache clean
# Copy built application from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/prisma ./prisma
# Copy Prisma schema for migrations
COPY --from=builder /app/prisma/schema.prisma ./prisma/schema.prisma
# Copy seed-admin.js for production seeding
COPY --from=builder /app/prisma/seed-admin.js ./prisma/seed-admin.js
# Copy public assets (logo, etc.)
COPY --from=builder /app/public ./public
# Expose port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/api/v1/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start application
CMD ["sh", "-c", "npx prisma migrate deploy && yarn start:prod"]