-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
78 lines (61 loc) · 2.03 KB
/
Copy pathDockerfile
File metadata and controls
78 lines (61 loc) · 2.03 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# ---------- Stage 1: build ----------
FROM oven/bun:1-debian AS builder
RUN apt-get update && apt-get install -y curl python3 python3-pip && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy package/lock files to cache dependencies
COPY frontend/package.json frontend/bun.lock* ./frontend/
COPY backend/package.json backend/bun.lock* ./backend/
COPY worker/package.json worker/bun.lock* ./worker/
# Frontend dependencies
WORKDIR /app/frontend
RUN bun install
# Backend dependencies
WORKDIR /app/backend
RUN bun install
# Worker dependencies
WORKDIR /app/worker
RUN bun install
# Copy source code
WORKDIR /app
COPY frontend ./frontend
COPY backend ./backend
COPY worker ./worker
# Build Frontend
WORKDIR /app/frontend
RUN bun run build
# Build Backend
WORKDIR /app/backend
RUN bunx prisma generate
RUN bun run build
# ---------- Stage 2: runtime ----------
FROM oven/bun:1-debian AS runner
RUN apt-get update && apt-get install -y curl python3 python3-pip && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Backend: only compiled dist + prod deps + prisma client
COPY --from=builder /app/backend/dist ./backend/dist
COPY --from=builder /app/backend/node_modules ./backend/node_modules
COPY --from=builder /app/backend/package.json ./backend/package.json
COPY --from=builder /app/backend/prisma ./backend/prisma
# Frontend: only the build output (adjust if backend serves it from elsewhere)
COPY --from=builder /app/frontend/dist ./frontend/dist
# Worker: needs source since it isn't built
COPY --from=builder /app/worker ./worker
RUN echo '#!/bin/bash\n\
echo "Starting Backend server..."\n\
cd /app/backend && bun dist/index.js &\n\
\n\
echo "Starting Worker process..."\n\
cd /app/worker && bun index.ts &\n\
\n\
wait -n\n\
exit $?' > /app/start.sh && chmod +x /app/start.sh
EXPOSE 3000
CMD ["/app/start.sh"]