-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (39 loc) · 1.64 KB
/
Dockerfile
File metadata and controls
50 lines (39 loc) · 1.64 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
# ---- Base stage ----
FROM node:18-alpine as base
# Set working directory
WORKDIR /app/customer-service
# Disable interactive prompts and enable Corepack
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
COREPACK_ENABLE_STRICT=0
RUN corepack enable \
&& corepack prepare pnpm@10.10.0 --activate
# ---- Builder stage ----
FROM base AS builder
WORKDIR /app/customer-service
# Copy manifests and generate dependencies
COPY customer-service/package.json customer-service/pnpm-lock.yaml /app/customer-service/
COPY customer-service/nest-cli.json customer-service/tsconfig*.json /app/customer-service/
# This copies both schema.prisma and migrations folder
COPY customer-service/prisma /app/customer-service/prisma/
# Install deps & generate client
RUN pnpm install --frozen-lockfile \
&& pnpm prisma generate
# Copy source, build
COPY customer-service/src /app/customer-service/src/
RUN pnpm build
# ---- Final stage: runtime ----
FROM base AS runtime
WORKDIR /app/customer-service
# Copy built artifacts from builder
COPY --from=builder /app/customer-service/node_modules /app/customer-service/node_modules/
COPY --from=builder /app/customer-service/dist /app/customer-service/dist/
COPY --from=builder /app/customer-service/prisma /app/customer-service/prisma/
COPY --from=builder /app/customer-service/package.json /app/customer-service/
COPY --from=builder /app/customer-service/pnpm-lock.yaml /app/customer-service/
# Health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
# Expose port
EXPOSE 3000
# Start the application
CMD ["sh", "-c", "pnpm prisma migrate deploy && pnpm start:prod"]