-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile.collector
More file actions
80 lines (67 loc) · 3.15 KB
/
Copy pathDockerfile.collector
File metadata and controls
80 lines (67 loc) · 3.15 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
79
80
# syntax=docker/dockerfile:1.7
#
# Pathlight collector runtime image.
#
# Multi-stage: builder installs workspace deps + runs tsc for the collector
# and its @pathlight/db workspace dependency; final stage copies only the
# built JS + the migrations + runtime node_modules, leaving TypeScript
# tooling out.
#
# Build context is the monorepo root so npm workspaces resolve cleanly.
# ---------- Stage 1: deps ----------
FROM node:22-slim AS deps
WORKDIR /app
# Copy only package manifests for a cacheable npm ci. Workspaces that the
# collector doesn't need (sdk, eval, cli, web) are included here because
# npm ci walks the workspace graph, but their install cost is low.
COPY package.json package-lock.json turbo.json ./
COPY packages/collector/package.json ./packages/collector/
COPY packages/db/package.json ./packages/db/
COPY packages/sdk/package.json ./packages/sdk/
COPY packages/eval/package.json ./packages/eval/
COPY packages/cli/package.json ./packages/cli/
COPY packages/fix/package.json ./packages/fix/
COPY packages/keys/package.json ./packages/keys/
COPY packages/openclaw-plugin/package.json ./packages/openclaw-plugin/
COPY apps/web/package.json ./apps/web/
RUN npm ci --ignore-scripts
# ---------- Stage 2: build ----------
FROM node:22-slim AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/package.json /app/package-lock.json /app/turbo.json ./
# Copy source for only the workspaces the collector touches. db / keys /
# fix are direct deps; sdk is a transitive dep via @pathlight/fix.
COPY packages/db ./packages/db
COPY packages/sdk ./packages/sdk
COPY packages/keys ./packages/keys
COPY packages/fix ./packages/fix
COPY packages/collector ./packages/collector
RUN npx turbo build --filter=@pathlight/collector
# ---------- Stage 3: runtime ----------
FROM node:22-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production
ENV DATABASE_URL=file:/data/pathlight.db
ENV PORT=4100
# Runtime needs node_modules (with workspace symlinks), the built collector
# JS, the built db package, and the raw Drizzle migrations.
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
COPY --from=builder /app/packages/collector/package.json ./packages/collector/
COPY --from=builder /app/packages/collector/dist ./packages/collector/dist
COPY --from=builder /app/packages/db/package.json ./packages/db/
COPY --from=builder /app/packages/db/dist ./packages/db/dist
COPY --from=builder /app/packages/db/drizzle ./packages/db/drizzle
COPY --from=builder /app/packages/sdk/package.json ./packages/sdk/
COPY --from=builder /app/packages/sdk/dist ./packages/sdk/dist
COPY --from=builder /app/packages/keys/package.json ./packages/keys/
COPY --from=builder /app/packages/keys/dist ./packages/keys/dist
COPY --from=builder /app/packages/fix/package.json ./packages/fix/
COPY --from=builder /app/packages/fix/dist ./packages/fix/dist
# SQLite file lives on a mounted volume so data survives container restarts.
VOLUME ["/data"]
EXPOSE 4100
# The collector runs its own migrations on startup (see packages/collector/src/index.ts),
# so the container is ready the moment /health returns 200.
CMD ["node", "packages/collector/dist/index.js"]