-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (46 loc) · 2.34 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (46 loc) · 2.34 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
FROM oven/bun:1 AS base
WORKDIR /app
# ── Builder ───────────────────────────────────────────────────────────────────
FROM base AS builder
RUN apt-get update && \
apt-get install -y build-essential python3 && \
rm -rf /var/lib/apt/lists/*
# Install dependencies (layer-cached separately from source)
COPY package.json bun.lock* turbo.json ./
COPY packages/ ./packages/
COPY apps/api/package.json ./apps/api/
COPY apps/client/package.json ./apps/client/
COPY apps/landing/package.json ./apps/landing/
RUN bun install
# Copy source
COPY apps/api ./apps/api
COPY apps/client ./apps/client
COPY ecosystem.config.js ./ecosystem.config.js
# Build API
RUN cd apps/api && bunx prisma generate && bun run build
# Build client (output: standalone is hardcoded in next.config.ts, safe for dev too)
RUN cd apps/client && bun run build
# ── API production deps ───────────────────────────────────────────────────────
# Install outside the workspace root so bun doesn't hoist to /app/node_modules
WORKDIR /api-prod
COPY apps/api/package.json ./
RUN bun install --production
# Overlay the Prisma-generated client from the workspace build
RUN cp -r /app/node_modules/.prisma ./node_modules/ && \
cp -r /app/node_modules/@prisma/client/. ./node_modules/@prisma/client/
WORKDIR /app
# ── Runner ────────────────────────────────────────────────────────────────────
FROM node:22-slim AS runner
WORKDIR /app
RUN npm install -g pm2
# API
COPY --from=builder /app/apps/api/dist ./apps/api/dist
COPY --from=builder /api-prod/node_modules ./apps/api/node_modules
COPY --from=builder /app/apps/api/package.json ./apps/api/package.json
# Client (Next.js standalone)
COPY --from=builder /app/apps/client/.next/standalone ./apps/client/
COPY --from=builder /app/apps/client/.next/static ./apps/client/.next/static
COPY --from=builder /app/apps/client/public ./apps/client/public
COPY --from=builder /app/ecosystem.config.js ./ecosystem.config.js
EXPOSE 3000 5003
CMD ["pm2-runtime", "ecosystem.config.js"]