-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
78 lines (56 loc) · 2.34 KB
/
Dockerfile
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: Base build stage for all packages
FROM node:18-alpine AS builder
RUN npm install -g pnpm
WORKDIR /app
# Copy workspace configuration and root dependencies
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
# Copy all package.json files
COPY packages/app/package.json ./packages/app/
COPY packages/types/package.json ./packages/types/
COPY packages/workers/package.json ./packages/workers/
# Install all dependencies
RUN pnpm install
# Copy source code
COPY packages/app ./packages/app
COPY .env ./packages/app/
COPY packages/types ./packages/types
COPY packages/workers ./packages/workers
# Build all packages
RUN pnpm --filter types... build && \
pnpm --filter app... build && \
pnpm --filter workers... build
# Stage 2: Production image for app
FROM node:18-alpine AS app
RUN npm install -g pnpm && \
apk add --no-cache netcat-openbsd
WORKDIR /app
# Copy workspace config and root dependencies
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
# Copy built packages from builder
COPY --from=builder /app/packages/types/package.json ./packages/types/
COPY --from=builder /app/packages/types/dist ./packages/types/dist
COPY --from=builder /app/packages/app/package.json ./packages/app/
COPY --from=builder /app/packages/app/drizzle ./packages/app/drizzle
COPY --from=builder /app/packages/app/drizzle.config.ts ./packages/app/
COPY --from=builder /app/packages/app/build ./packages/app/build
# Install dependencies including drizzle-kit for migrations
RUN pnpm install --filter app... --filter types && \
pnpm add -w drizzle-kit
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
EXPOSE 3000
ENTRYPOINT ["/docker-entrypoint.sh"]
# Stage 3: Production image for workers
FROM node:18-alpine AS worker
RUN npm install -g pnpm
WORKDIR /app
# Copy workspace config and root dependencies
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
# Copy built packages from builder
COPY --from=builder /app/packages/types/package.json ./packages/types/
COPY --from=builder /app/packages/types/dist ./packages/types/dist
COPY --from=builder /app/packages/workers/package.json ./packages/workers/
COPY --from=builder /app/packages/workers/dist ./packages/workers/dist
# Install production dependencies only
RUN pnpm install --prod --filter workers... --filter types
CMD ["pnpm", "--filter", "workers", "run", "start"]