|
1 | | -# celld Worker runtime. Same Maple Worker sources as Cloudflare; no alchemy. |
2 | | -# Build from repo root: docker build -f deploy/celld-self-host/docker/Dockerfile.celld . |
| 1 | +# celld Worker runtime. Production graph only: api + electric-sync + alerting |
| 2 | +# (+ clickhouse-cli / db for the migrate job). Build from repo root: |
| 3 | +# docker build -f deploy/celld-self-host/docker/Dockerfile.celld . |
| 4 | + |
3 | 5 | FROM oven/bun:1.4.0 AS base |
4 | 6 | WORKDIR /app |
5 | 7 |
|
| 8 | +FROM base AS pruner |
| 9 | +COPY . . |
| 10 | +RUN bunx turbo prune \ |
| 11 | + @maple/api \ |
| 12 | + @maple/alerting \ |
| 13 | + @maple/electric-sync \ |
| 14 | + @maple/clickhouse-cli \ |
| 15 | + --docker --out-dir /app/out |
| 16 | + |
| 17 | +FROM base AS deps |
| 18 | +COPY --from=pruner /app/out/json/ ./ |
| 19 | +COPY --from=pruner /app/out/bun.lock ./bun.lock |
| 20 | +COPY bunfig.toml ./ |
| 21 | +COPY patches ./patches |
| 22 | +# turbo prune keeps the root package.json, including oxlint/alchemy/knip. |
| 23 | +# Those are not Worker runtime. Drop them before bun install. |
| 24 | +RUN bun -e 'const fs=require("fs"); const p=JSON.parse(fs.readFileSync("package.json","utf8")); p.devDependencies={}; p.scripts={}; fs.writeFileSync("package.json", JSON.stringify(p,null,2));' |
| 25 | +RUN bun install --ignore-scripts || bun install --ignore-scripts |
| 26 | + |
| 27 | +FROM deps AS build |
| 28 | +COPY --from=pruner /app/out/full/ ./ |
| 29 | +# `out/full` restores the original root package.json; strip tooling again. |
| 30 | +RUN bun -e 'const fs=require("fs"); const p=JSON.parse(fs.readFileSync("package.json","utf8")); p.devDependencies={}; p.scripts={}; fs.writeFileSync("package.json", JSON.stringify(p,null,2));' |
| 31 | +# Re-install with full sources so workspace bins (tsdown) resolve, then emit |
| 32 | +# dist/ for packages whose package.json exports point at dist/, not src/. |
| 33 | +RUN bun install --ignore-scripts || bun install --ignore-scripts |
| 34 | +RUN bun run --cwd lib/clickhouse-builder build && \ |
| 35 | + bun run --cwd packages/effect-sdk build |
| 36 | + |
| 37 | +# Drop workspace devDependencies (wrangler/workerd/miniflare/vitest). |
| 38 | +# Postgres migrate uses packages/db/scripts/migrate-pg.ts (drizzle-orm), not drizzle-kit. |
| 39 | +FROM build AS prod |
| 40 | +RUN rm -rf node_modules && bun install --production --ignore-scripts |
| 41 | + |
| 42 | +FROM oven/bun:1.4.0-slim AS runtime |
| 43 | +WORKDIR /app |
| 44 | + |
6 | 45 | ARG CELLD_VERSION=v0.4.0 |
7 | | -ARG TARGETARCH=arm64 |
| 46 | +ARG TARGETARCH |
| 47 | +ARG ESBUILD_VERSION=0.24.2 |
8 | 48 |
|
9 | 49 | RUN apt-get update \ |
10 | 50 | && apt-get install -y --no-install-recommends ca-certificates curl gzip \ |
11 | 51 | && rm -rf /var/lib/apt/lists/* |
12 | 52 |
|
13 | 53 | RUN set -euo pipefail; \ |
14 | | - case "$TARGETARCH" in \ |
15 | | - amd64) asset=celld-x86_64-unknown-linux-gnu.gz ;; \ |
16 | | - arm64) asset=celld-aarch64-unknown-linux-gnu.gz ;; \ |
17 | | - *) echo "unsupported TARGETARCH=$TARGETARCH" >&2; exit 1 ;; \ |
| 54 | + arch="${TARGETARCH:-}"; \ |
| 55 | + if [ -z "$arch" ]; then \ |
| 56 | + case "$(uname -m)" in \ |
| 57 | + aarch64|arm64) arch=arm64 ;; \ |
| 58 | + x86_64|amd64) arch=amd64 ;; \ |
| 59 | + *) echo "unsupported arch $(uname -m)" >&2; exit 1 ;; \ |
| 60 | + esac; \ |
| 61 | + fi; \ |
| 62 | + case "$arch" in \ |
| 63 | + amd64) asset=celld-x86_64-unknown-linux-gnu.gz; plat=linux-x64 ;; \ |
| 64 | + arm64) asset=celld-aarch64-unknown-linux-gnu.gz; plat=linux-arm64 ;; \ |
| 65 | + *) echo "unsupported TARGETARCH=$arch" >&2; exit 1 ;; \ |
18 | 66 | esac; \ |
19 | 67 | curl -fsSL "https://github.com/denoland/celld/releases/download/${CELLD_VERSION}/${asset}" \ |
20 | 68 | | gzip -d > /usr/local/bin/celld; \ |
21 | 69 | chmod +x /usr/local/bin/celld; \ |
22 | | - celld --version |
23 | | - |
24 | | -COPY package.json bun.lock bunfig.toml turbo.json ./ |
25 | | -COPY apps ./apps |
26 | | -COPY packages ./packages |
27 | | -COPY lib ./lib |
28 | | -COPY patches ./patches |
29 | | - |
30 | | -ARG ESBUILD_VERSION=0.24.2 |
31 | | -RUN set -euo pipefail; \ |
32 | | - case "$TARGETARCH" in \ |
33 | | - amd64) plat=linux-x64 ;; \ |
34 | | - arm64) plat=linux-arm64 ;; \ |
35 | | - *) echo "unsupported TARGETARCH=$TARGETARCH" >&2; exit 1 ;; \ |
36 | | - esac; \ |
37 | 70 | curl -fsSL "https://registry.npmjs.org/@esbuild/${plat}/-/${plat}-${ESBUILD_VERSION}.tgz" \ |
38 | 71 | | tar -xz -C /tmp; \ |
39 | 72 | install -m 0755 /tmp/package/bin/esbuild /usr/local/bin/esbuild; \ |
| 73 | + rm -rf /tmp/package; \ |
| 74 | + celld --version; \ |
40 | 75 | esbuild --version |
41 | 76 |
|
42 | | -# Workspace install can flake on npm (pglite/alchemy are unused at celld runtime). |
43 | | -RUN bun install || bun install |
44 | | - |
| 77 | +COPY --from=prod /app /app |
45 | 78 | COPY deploy/celld-self-host/docker/entrypoint-celld.sh /entrypoint-celld.sh |
46 | 79 | RUN chmod +x /entrypoint-celld.sh |
47 | 80 |
|
|
0 commit comments