forked from paperclipai/paperclip
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
107 lines (85 loc) · 4.66 KB
/
Copy pathDockerfile
File metadata and controls
107 lines (85 loc) · 4.66 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# ── Stage 1: base ─────────────────────────────────────────────
FROM node:22-trixie-slim AS base
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl git tini \
&& rm -rf /var/lib/apt/lists/*
RUN corepack enable
# ── Stage 2: deps ─────────────────────────────────────────────
# Install all dependencies (dev + prod) using lockfile.
# This layer is cached unless a package.json or lockfile changes.
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml .npmrc ./
COPY cli/package.json cli/
COPY server/package.json server/
COPY ui/package.json ui/
COPY desktop/package.json desktop/
COPY packages/shared/package.json packages/shared/
COPY packages/db/package.json packages/db/
COPY packages/adapter-utils/package.json packages/adapter-utils/
COPY packages/adapters/claude-local/package.json packages/adapters/claude-local/
COPY packages/adapters/codex-local/package.json packages/adapters/codex-local/
COPY packages/adapters/cursor-local/package.json packages/adapters/cursor-local/
COPY packages/adapters/gemini-local/package.json packages/adapters/gemini-local/
COPY packages/adapters/openclaw-gateway/package.json packages/adapters/openclaw-gateway/
COPY packages/adapters/opencode-local/package.json packages/adapters/opencode-local/
COPY packages/adapters/pi-local/package.json packages/adapters/pi-local/
COPY packages/plugins/sdk/package.json packages/plugins/sdk/
COPY packages/plugins/create-paperclip-plugin/package.json packages/plugins/create-paperclip-plugin/
COPY packages/plugins/examples/plugin-authoring-smoke-example/package.json packages/plugins/examples/plugin-authoring-smoke-example/
COPY packages/plugins/examples/plugin-file-browser-example/package.json packages/plugins/examples/plugin-file-browser-example/
COPY packages/plugins/examples/plugin-hello-world-example/package.json packages/plugins/examples/plugin-hello-world-example/
COPY packages/plugins/examples/plugin-kitchen-sink-example/package.json packages/plugins/examples/plugin-kitchen-sink-example/
RUN pnpm install --frozen-lockfile
# ── Stage 3: build ────────────────────────────────────────────
FROM base AS build
WORKDIR /app
COPY --from=deps /app /app
COPY . .
RUN pnpm -r build \
&& test -f server/dist/index.js || (echo "ERROR: server build output missing" && exit 1)
# Note: no prod prune — tsx is in devDependencies but needed at runtime
# as the Node ESM loader. Image size is controlled by selective COPY below.
# ── Stage 4: production ───────────────────────────────────────
# Distroless-style minimal image. No shell, no package manager,
# no build tools — only the Node runtime and built artifacts.
FROM node:22-trixie-slim AS production
LABEL org.opencontainers.image.source="https://github.com/paperclipinc/paperclip"
LABEL org.opencontainers.image.description="Paperclip — AI company orchestration platform"
LABEL org.opencontainers.image.vendor="Paperclip Inc."
LABEL org.opencontainers.image.licenses="MIT"
# Minimal runtime deps: tini for PID 1, curl for healthcheck, git for agent runtimes
RUN apt-get update \
&& apt-get install -y --no-install-recommends tini curl git ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
RUN corepack enable
# Agent runtimes — pinned versions for reproducibility
RUN npm install --global --omit=dev \
@anthropic-ai/claude-code@latest \
@openai/codex@latest \
opencode-ai \
&& npm cache clean --force \
&& rm -rf /tmp/*
RUN mkdir -p /paperclip && chown node:node /paperclip
WORKDIR /app
# Copy built app — tsx transpiles workspace TypeScript at runtime,
# so source files must be present alongside dist output.
COPY --chown=node:node --from=build /app /app
ENV NODE_ENV=production \
HOME=/paperclip \
HOST=0.0.0.0 \
PORT=3100 \
SERVE_UI=true \
PAPERCLIP_HOME=/paperclip \
PAPERCLIP_INSTANCE_ID=default \
PAPERCLIP_CONFIG=/paperclip/instances/default/config.json \
PAPERCLIP_DEPLOYMENT_MODE=authenticated \
PAPERCLIP_DEPLOYMENT_EXPOSURE=private
VOLUME ["/paperclip"]
EXPOSE 3100
USER node
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD curl -fsS http://localhost:3100/api/health || exit 1
ENTRYPOINT ["tini", "--"]
CMD ["node", "--import", "./server/node_modules/tsx/dist/loader.mjs", "server/dist/index.js"]