-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (42 loc) · 1.63 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (42 loc) · 1.63 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
# ---- Builder Stage ----
FROM node:20-alpine AS builder
WORKDIR /app
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy workspace files
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
COPY packages/ ./packages/
COPY apps/control-service/ ./apps/control-service/
COPY tsconfig.json ./
# Install all dependencies
RUN pnpm install --frozen-lockfile
# Build packages in dependency order
RUN pnpm --filter shared build 2>/dev/null || true
RUN pnpm --filter core build 2>/dev/null || true
RUN pnpm --filter auth build 2>/dev/null || true
RUN pnpm --filter audit build 2>/dev/null || true
RUN pnpm --filter governance build 2>/dev/null || true
RUN pnpm --filter orchestrator build 2>/dev/null || true
RUN pnpm --filter control-service build 2>/dev/null || true
# ---- Production Stage ----
FROM node:20-alpine AS runner
WORKDIR /app
# Create non-root user
RUN addgroup -S cku && adduser -S cku -G cku
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Copy workspace config
COPY --from=builder /app/pnpm-workspace.yaml /app/package.json /app/pnpm-lock.yaml ./
# Copy only production packages
COPY --from=builder /app/packages/ ./packages/
COPY --from=builder /app/apps/control-service/ ./apps/control-service/
# Install production deps only
RUN pnpm install --prod --frozen-lockfile
# Copy database migrations
COPY db/ ./db/
# Use non-root user
USER cku
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD wget -qO- http://localhost:8080/health || exit 1
CMD ["node", "--experimental-specifier-resolution=node", "apps/control-service/src/index.ts"]