Skip to content

Commit a3bcd2e

Browse files
committed
build(deploy): self-host from published images
1 parent f26f3cc commit a3bcd2e

8 files changed

Lines changed: 114 additions & 46 deletions

File tree

‎.env.hub.example‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Builder hub environment. Copy this to .env.hub (never committed) and fill in every
22
# line marked "Secret" with its own random value: openssl rand -hex 32
33

4+
# --- Docker Compose ----------------------------------------------------------
5+
# The published images deploy/compose.yml runs: rc (newest release candidate),
6+
# latest (newest stable), main (every merge), an exact version or a commit sha.
7+
BUILDER_VERSION=rc
8+
49
# --- Database (required) -----------------------------------------------------
510
# Postgres 17. Docker Compose starts one with these values.
611
DB_HOST=127.0.0.1
@@ -89,8 +94,9 @@ PRODUCT_HELLO_WORDING=
8994
# Agents run in sidecars. By default the hub starts them as local processes.
9095
# Most local sidecars running at once.
9196
# SIDECAR_LOCAL_MAX_ACTIVE=16
92-
# Optional Docker sidecars: build the image with `bun run docker:sidecar`, then set it.
93-
# deploy/compose.docker-sidecars.yml sets them for the hub container.
97+
# Optional Docker sidecars. deploy/compose.docker-sidecars.yml sets them for the hub
98+
# container, with the published sidecar image at BUILDER_VERSION. From source, build
99+
# it with `bun run docker:sidecar` and set:
94100
# SIDECAR_IMAGE=corbits-builder-sidecar:local
95101
# SIDECAR_DOCKER_HOST=unix:///var/run/docker.sock
96102
# The group owning the Docker socket for deploy/compose.docker-sidecars.yml: 0 on Docker Desktop.

‎README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ Set up Builder on this machine with the corbits-builder-install skill. Use Docke
4141
**With Docker.**
4242

4343
```sh
44-
git clone https://github.com/corbitsdev/corbits-builder.git
45-
cd corbits-builder
46-
cp .env.hub.example .env.hub # fill in each line marked Secret
47-
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml up -d --build
44+
mkdir builder && cd builder
45+
base=https://raw.githubusercontent.com/corbitsdev/corbits-builder/main
46+
curl -fsSLO "$base/deploy/compose.yml"
47+
curl -fsSL "$base/.env.hub.example" -o .env.hub # fill in each line marked Secret
48+
docker compose --env-file .env.hub -f compose.yml up -d
4849
```
4950

5051
Open http://localhost:8000. Ports, logs and running on a server are in

‎deploy/compose.build.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Builds the hub from this checkout instead of pulling the published image:
2+
# docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml -f deploy/compose.build.yml up -d --build
3+
x-build: &build
4+
image: corbits-builder-hub:local
5+
build:
6+
context: .
7+
dockerfile: deploy/Dockerfile
8+
target: hub
9+
10+
services:
11+
hub: *build
12+
setup: *build

‎deploy/compose.docker-sidecars.yml‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
# Lets the hub also start sidecars as containers on the host's Docker daemon:
22
# docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml -f deploy/compose.docker-sidecars.yml up -d
3-
# Build the image on that daemon first with `bun run docker:sidecar`.
3+
# `sidecar-image` pulls SIDECAR_IMAGE onto that daemon before the hub starts;
4+
# `docker compose pull` refreshes it after a channel change.
5+
# From source, `bun run docker:sidecar` builds corbits-builder-sidecar:local;
6+
# set SIDECAR_IMAGE to that.
47
# Access to the socket is root on the host.
58
services:
9+
sidecar-image:
10+
image: ${SIDECAR_IMAGE:-ghcr.io/corbitsdev/corbits-builder-sidecar:${BUILDER_VERSION:-rc}}
11+
entrypoint: ["true"]
12+
restart: "no"
613
hub:
14+
depends_on:
15+
sidecar-image:
16+
condition: service_completed_successfully
717
environment:
8-
SIDECAR_IMAGE: ${SIDECAR_IMAGE:-corbits-builder-sidecar:local}
18+
SIDECAR_IMAGE: ${SIDECAR_IMAGE:-ghcr.io/corbitsdev/corbits-builder-sidecar:${BUILDER_VERSION:-rc}}
919
SIDECAR_DOCKER_HOST: unix:///var/run/docker.sock
1020
# The group that owns the socket inside the container: 0 on Docker Desktop,
1121
# the host's docker group id (`getent group docker`) on Linux.

‎deploy/compose.yml‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Run from the repo root with `--project-directory .` so compose keeps the
2-
# repo-named project and resolves paths from the root, and `--env-file .env.hub`
3-
# so the values below interpolate from it:
1+
# Runs the published images. Pass `--env-file .env.hub` so the values below,
2+
# BUILDER_VERSION among them, interpolate from it. From a checkout, run from the
3+
# repo root with `--project-directory .`; anywhere else, keep .env.hub beside
4+
# this file:
45
# docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml up -d
6+
# deploy/compose.build.yml builds the images from source instead.
57
x-hub: &hub
6-
build:
7-
context: .
8-
dockerfile: deploy/Dockerfile
9-
target: hub
8+
image: ghcr.io/corbitsdev/corbits-builder-hub:${BUILDER_VERSION:-rc}
109
env_file: .env.hub
1110
environment:
1211
DB_HOST: db
@@ -42,8 +41,6 @@ services:
4241
timeout: 3s
4342
retries: 30
4443
hub:
45-
# No image name: Compose tags it after the project, so two checkouts never
46-
# share one image.
4744
<<: *hub
4845
ports:
4946
- "127.0.0.1:${PORT:-8000}:${PORT:-8000}"

‎docs/SELF_HOST.md‎

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,23 @@ in [DEV.md](https://github.com/corbitsdev/corbits-builder/blob/main/docs/DEV.md)
55
You need Docker with Compose and an API key or subscription login for at least
66
one [model provider](#models).
77

8-
`deploy/compose.yml` runs Postgres 17 and the hub, which applies the
9-
migrations, then serves the API and the UI. Run every compose command from the
10-
repo root.
8+
`deploy/compose.yml` runs Postgres 17 and the published hub image, which
9+
applies the migrations, then serves the API and the UI. It needs no clone.
1110

12-
## Configure
11+
## Install
1312

1413
```sh
15-
cp .env.hub.example .env.hub
14+
mkdir builder && cd builder
15+
base=https://raw.githubusercontent.com/corbitsdev/corbits-builder/main
16+
curl -fsSLO "$base/deploy/compose.yml"
17+
curl -fsSL "$base/.env.hub.example" -o .env.hub
1618
```
1719

20+
Replace `main` with a release tag (`v<version>`) to pin these files to that
21+
release. Every command below runs from this folder.
22+
23+
## Configure
24+
1825
Give each secret `.env.hub` marks its own random value, for example from
1926
`openssl rand -hex 32`; Builder refuses to start without them. Losing or
2027
changing the encryption keys makes stored provider keys unreadable. Every other
@@ -26,6 +33,11 @@ people open, and `HUB_PUBLIC_URL`, `HUB_API_ORIGIN` and `UI_PUBLIC_URL` when
2633
they differ from it. If a port is taken, `PORT` moves Builder (default `8000`)
2734
and `DB_PORT` the database (default `5433`).
2835

36+
`BUILDER_VERSION` picks the published images
37+
(`ghcr.io/corbitsdev/corbits-builder-hub` and `-sidecar`): `rc` (default, the
38+
newest release candidate), `latest` (the newest stable release), `main` (every
39+
merge), an exact version such as `0.1.0-rc.1`, or a full commit sha.
40+
2941
## Models
3042

3143
Connect a provider in the UI under **Settings → Providers**, or set its key in
@@ -47,18 +59,23 @@ How profiles map models to roles is in
4759
## Run it
4860

4961
```sh
50-
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml up -d --build # start or update
51-
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml logs -f hub # follow the logs
52-
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml down # stop, keep the data
62+
docker compose --env-file .env.hub -f compose.yml up -d # start
63+
docker compose --env-file .env.hub -f compose.yml logs -f hub # follow the logs
64+
docker compose --env-file .env.hub -f compose.yml down # stop, keep the data
5365
```
5466

5567
Open http://localhost:8000 (or your `PORT`), create an account, then add a
5668
provider under **Settings → Providers**, or set a provider key in `.env.hub` before
5769
starting. With one provider, projects run on its profile; with several, each
5870
person picks one under **Settings → Profiles**
5971
([how the choice works](https://github.com/corbitsdev/corbits-builder/blob/main/docs/DEV.md#model-profile-choice)).
60-
To update, pull the new commits and start it again; the hub applies new
61-
migrations as it starts.
72+
To update, or to switch channel after changing `BUILDER_VERSION`, pull the
73+
images and start it again; the hub applies new migrations as it starts:
74+
75+
```sh
76+
docker compose --env-file .env.hub -f compose.yml pull
77+
docker compose --env-file .env.hub -f compose.yml up -d
78+
```
6279

6380
Login with ChatGPT and Login with xAI finish by sending the browser to
6481
`localhost:1455` and `localhost:1456`, so they work only when the browser runs
@@ -73,22 +90,34 @@ To create a machine account and workspace without the UI, set the
7390
`BOOTSTRAP_*` values in `.env.hub` and run the `setup` service once:
7491

7592
```sh
76-
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml --profile setup run --rm setup
93+
docker compose --env-file .env.hub -f compose.yml --profile setup run --rm setup
7794
```
7895

96+
## From source
97+
98+
In a clone, `deploy/compose.build.yml` builds the hub image from the checkout
99+
instead of pulling it. Run from the repo root with `.env.hub` there:
100+
101+
```sh
102+
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml -f deploy/compose.build.yml up -d --build
103+
```
104+
105+
`bun run docker:up` runs the same.
106+
79107
## Sidecars in Docker
80108

81109
Agents run in sidecars. By default the hub starts them as processes beside
82110
itself, inside the hub container. With `SIDECAR_IMAGE` set, it can also
83111
start them as containers on the Docker daemon at `SIDECAR_DOCKER_HOST`.
84112

85113
```sh
86-
docker build -f deploy/Dockerfile --target sidecar -t corbits-builder-sidecar:local .
87-
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml -f deploy/compose.docker-sidecars.yml up -d --build
114+
curl -fsSLO https://raw.githubusercontent.com/corbitsdev/corbits-builder/main/deploy/compose.docker-sidecars.yml
115+
docker compose --env-file .env.hub -f compose.yml -f compose.docker-sidecars.yml up -d
88116
```
89117

90-
- Build the image on the daemon the hub uses; the hub checks that it exists
91-
when it starts.
118+
- Compose pulls the sidecar image for your `BUILDER_VERSION` before the hub
119+
starts, and `docker compose pull` refreshes it with the hub. From source, `bun run docker:sidecar` builds
120+
`corbits-builder-sidecar:local`; set `SIDECAR_IMAGE` to it in `.env.hub`.
92121
- `deploy/compose.docker-sidecars.yml` mounts `/var/run/docker.sock` into the hub and
93122
adds the socket's group (`DOCKER_SOCKET_GID`: `0` on Docker Desktop, the
94123
host's `docker` group id on Linux). Access to that socket is root on the

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"start": "exec bun --env-file=.env.hub --conditions=intx-src apps/hub/src/server.ts",
2525
"db:migrate": "bun --env-file=.env.hub --conditions=intx-src apps/hub/src/migrate.ts",
2626
"db:generate": "bun --conditions=intx-src ./node_modules/drizzle-kit/bin.cjs generate --config=apps/hub/drizzle.config.ts",
27-
"docker:up": "docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml up -d --build",
27+
"docker:up": "docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml -f deploy/compose.build.yml up -d --build",
2828
"docker:sidecar": "docker build -f deploy/Dockerfile --target sidecar -t corbits-builder-sidecar:local .",
2929
"auth:bootstrap": "bun --env-file=.env.hub --conditions=intx-src apps/hub/src/setup.ts",
3030
"auth:emulate": "bun --env-file=.env.hub scripts/google-emulate.ts",

‎skills/corbits-builder-install/SKILL.md‎

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: corbits-builder-install
3-
description: Gets Builder running on this machine, from finding or cloning the checkout to the person signing up and connecting a model provider. Use whenever someone wants to install, set up, run, start, self-host or try Builder (Corbits Builder, corbitsdev/corbits-builder), with Docker Compose or with their own Postgres, or when a Builder checkout won't start. For driving projects through Builder's API once it runs, use operate-corbits-builder instead.
3+
description: Gets Builder running on this machine, from downloading the Compose files or cloning the checkout to the person signing up and connecting a model provider. Use whenever someone wants to install, set up, run, start, self-host or try Builder (Corbits Builder, corbitsdev/corbits-builder), with Docker Compose or with their own Postgres, or when a Builder checkout won't start. For driving projects through Builder's API once it runs, use operate-corbits-builder instead.
44
---
55

66
# Install Builder
@@ -17,13 +17,7 @@ instead.
1717
- **Keep an existing `.env.hub`.** Its keys already encrypt stored data; new ones
1818
lock Builder out of it.
1919

20-
## 1. Find the checkout
21-
22-
Work from the root of a Builder checkout (a folder with `deploy/compose.yml`).
23-
If the current folder is not one, ask where it is, or clone
24-
`https://github.com/corbitsdev/corbits-builder.git` where the person chooses.
25-
26-
## 2. Choose a path
20+
## 1. Choose a path
2721

2822
Suggest Docker Compose if `docker info` succeeds, otherwise their own Postgres 17. Let the person decide.
2923

@@ -32,6 +26,25 @@ Suggest Docker Compose if `docker info` succeeds, otherwise their own Postgres 1
3226
| Docker Compose | Docker with Compose | `http://localhost:8000` |
3327
| Own Postgres | Bun 1.4.4, Postgres 17 | `http://localhost:5173` |
3428

29+
## 2. Get the files
30+
31+
**Docker Compose** runs published images and needs no clone. In a folder the
32+
person chooses (or the one holding their existing `compose.yml`), download
33+
what is missing:
34+
35+
```sh
36+
base=https://raw.githubusercontent.com/corbitsdev/corbits-builder/main
37+
curl -fsSLO "$base/deploy/compose.yml"
38+
curl -fsSL "$base/.env.hub.example" -o .env.hub.example
39+
```
40+
41+
In a Builder checkout, download nothing: use `--project-directory . -f deploy/compose.yml`
42+
wherever the steps below say `-f compose.yml`.
43+
44+
**Own Postgres** runs from a Builder checkout (a folder with `deploy/compose.yml`
45+
and `package.json`). If the current folder is not one, ask where it is, or clone
46+
`https://github.com/corbitsdev/corbits-builder.git` where the person chooses.
47+
3548
## 3. Write `.env.hub` and `.env.web`
3649

3750
If `.env.hub` exists, keep it. Otherwise `cp .env.hub.example .env.hub` and fill each
@@ -50,9 +63,9 @@ and `DB_PORT` (5433) the Compose database's. If a port is taken, set `PORT` or
5063
## 4. Start Builder
5164

5265
**Docker Compose**:
53-
`docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml up -d --build`
54-
builds and starts Builder and Postgres. It is up when the hub logs `Hub ready`
55-
(`docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml logs hub`).
66+
`docker compose --env-file .env.hub -f compose.yml up -d`
67+
pulls and starts Builder and Postgres. It is up when the hub logs `Hub ready`
68+
(`docker compose --env-file .env.hub -f compose.yml logs hub`).
5669

5770
**Own Postgres**
5871
([CONTRIBUTING.md](https://github.com/corbitsdev/corbits-builder/blob/main/CONTRIBUTING.md),
@@ -78,8 +91,8 @@ Wait for them to confirm before you call it done.
7891
**Docker Compose**:
7992

8093
```sh
81-
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml stop # stop, keep everything
82-
docker compose --env-file .env.hub --project-directory . -f deploy/compose.yml down # remove containers, keep data
94+
docker compose --env-file .env.hub -f compose.yml stop # stop, keep everything
95+
docker compose --env-file .env.hub -f compose.yml down # remove containers, keep data
8396
```
8497

8598
`down -v` also deletes every account, project and stored key; run it only when

0 commit comments

Comments
 (0)