Skip to content

Commit 6caa359

Browse files
tlongwell-blocknpub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehrnpub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta
authored
Add production Docker Compose bundle (#985)
Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co>
1 parent a32681f commit 6caa359

7 files changed

Lines changed: 477 additions & 0 deletions

File tree

‎deploy/compose/.env.example‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Buzz production Docker Compose environment.
2+
# Copy to .env and replace every CHANGE_ME value before running.
3+
# The bootstrap script should generate this file for normal users.
4+
5+
# Image published by the public image pipeline. Use `:main` for pre-release testing. Pin `:sha-<7>` or a semver release tag for production.
6+
BUZZ_IMAGE=ghcr.io/block/buzz:main
7+
8+
# Public host name. Used by compose.caddy.yml and URL-derived settings below.
9+
BUZZ_DOMAIN=buzz.example.com
10+
RELAY_URL=wss://buzz.example.com
11+
BUZZ_MEDIA_BASE_URL=https://buzz.example.com/media
12+
BUZZ_MEDIA_SERVER_DOMAIN=buzz.example.com
13+
BUZZ_CORS_ORIGINS=https://buzz.example.com
14+
15+
# Production defaults. Closed relay mode requires RELAY_OWNER_PUBKEY and a stable relay key.
16+
BUZZ_REQUIRE_AUTH_TOKEN=true
17+
BUZZ_REQUIRE_RELAY_MEMBERSHIP=true
18+
BUZZ_ALLOW_NIP_OA_AUTH=true
19+
BUZZ_AUTO_MIGRATE=true
20+
BUZZ_GIT_CONFORMANCE_PROBE=true
21+
RUST_LOG=buzz_relay=info,buzz_db=info,buzz_auth=info,buzz_pubsub=info,tower_http=info
22+
23+
# Owner identity. Set to a 64-character hex Nostr pubkey.
24+
RELAY_OWNER_PUBKEY=CHANGE_ME_OWNER_PUBKEY_HEX
25+
26+
# Stable secrets. Generate once, keep in .env, and back up securely.
27+
BUZZ_RELAY_PRIVATE_KEY=CHANGE_ME_64_HEX_PRIVATE_KEY
28+
BUZZ_GIT_HOOK_HMAC_SECRET=CHANGE_ME_RANDOM_64_HEX
29+
POSTGRES_DB=buzz
30+
POSTGRES_USER=buzz
31+
POSTGRES_PASSWORD=CHANGE_ME_RANDOM_PASSWORD
32+
REDIS_PASSWORD=CHANGE_ME_RANDOM_PASSWORD
33+
TYPESENSE_API_KEY=CHANGE_ME_RANDOM_API_KEY
34+
BUZZ_S3_ACCESS_KEY=CHANGE_ME_RANDOM_ACCESS_KEY
35+
BUZZ_S3_SECRET_KEY=CHANGE_ME_RANDOM_SECRET_KEY
36+
BUZZ_S3_BUCKET=buzz-media
37+
38+
# Optional host ports. Base compose publishes the relay directly on BUZZ_HTTP_PORT.
39+
BUZZ_HTTP_PORT=3000
40+
41+
# Caddy host ports. Only used with compose.caddy.yml.
42+
CADDY_HTTP_PORT=80
43+
CADDY_HTTPS_PORT=443
44+
45+
# Dev override ports. Only used with compose.dev.yml.
46+
POSTGRES_PORT=5432
47+
REDIS_PORT=6379
48+
TYPESENSE_PORT=8108
49+
MINIO_API_PORT=9000
50+
MINIO_CONSOLE_PORT=9001
51+
ADMINER_PORT=8082
52+
PROMETHEUS_PORT=9090

‎deploy/compose/Caddyfile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{$BUZZ_DOMAIN} {
2+
encode zstd gzip
3+
4+
reverse_proxy relay:3000
5+
}

‎deploy/compose/README.md‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Buzz Docker Compose deployment
2+
3+
This is the single-node/VPS deployment bundle. It is intentionally separate from
4+
the root `docker-compose.yml`, which remains local development infrastructure.
5+
6+
## Quick start
7+
8+
```bash
9+
cd deploy/compose
10+
cp .env.example .env
11+
$EDITOR .env # replace every CHANGE_ME value
12+
./run.sh start
13+
```
14+
15+
For a public VPS with automatic Let's Encrypt certificates:
16+
17+
```bash
18+
cd deploy/compose
19+
BUZZ_COMPOSE_TLS=true ./run.sh start
20+
```
21+
22+
The bootstrap script should eventually replace manual `.env` editing for normal
23+
users. It is responsible for generating stable secrets and, optionally, an owner
24+
keypair.
25+
26+
## Production notes
27+
28+
- Requires Docker Compose v2.24.4 or newer; the TLS override uses Compose's
29+
`!reset` tag to remove the direct relay port when Caddy terminates HTTPS.
30+
- Default `BUZZ_IMAGE` tracks `ghcr.io/block/buzz:main` for early testing. Pin it to `ghcr.io/block/buzz:sha-<7>` or a semver release tag for production once available.
31+
- Keep `BUZZ_RELAY_PRIVATE_KEY`, `BUZZ_GIT_HOOK_HMAC_SECRET`, database/Redis,
32+
Typesense, and S3 secrets stable across restarts.
33+
- `RELAY_OWNER_PUBKEY` is intentionally not prefixed with `BUZZ_`; it must be a
34+
64-character hex Nostr pubkey when closed relay mode is enabled.
35+
- `BUZZ_AUTO_MIGRATE=true` requires an image that includes embedded SQLx
36+
migrations. Do not share this quick start for a fresh public install until PR
37+
#988 is merged and `ghcr.io/block/buzz:main` has been rebuilt from it. Before
38+
then, this bundle is only suitable for instances whose database schema has
39+
already been applied.
40+
- The stack uses Postgres, Redis, Typesense, MinIO, and a git data volume because
41+
those are real Buzz dependencies today. Minimal mode can simplify this later.
42+
43+
Run `./run.sh backup-hint` for the backup checklist.
44+
45+
## Validation
46+
47+
Before sharing an install link publicly, verify a fresh install with:
48+
49+
```bash
50+
cd deploy/compose
51+
cp .env.example .env
52+
$EDITOR .env
53+
./run.sh config
54+
./run.sh start
55+
curl -fsS "http://127.0.0.1:$(grep -E '^BUZZ_HTTP_PORT=' .env | cut -d= -f2-)/_liveness"
56+
./run.sh status
57+
```

‎deploy/compose/compose.caddy.yml‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
services:
2+
relay:
3+
ports: !reset []
4+
5+
caddy:
6+
image: caddy:2-alpine
7+
depends_on:
8+
relay:
9+
condition: service_healthy
10+
environment:
11+
BUZZ_DOMAIN: ${BUZZ_DOMAIN:?set BUZZ_DOMAIN}
12+
ports:
13+
- "${CADDY_HTTP_PORT:-80}:80"
14+
- "${CADDY_HTTPS_PORT:-443}:443"
15+
volumes:
16+
- ./Caddyfile:/etc/caddy/Caddyfile:ro
17+
- buzz-caddy-data:/data
18+
- buzz-caddy-config:/config
19+
restart: unless-stopped
20+
networks:
21+
- buzz-net
22+
23+
volumes:
24+
buzz-caddy-data:
25+
labels:
26+
com.buzz.volume: caddy-data
27+
buzz-caddy-config:
28+
labels:
29+
com.buzz.volume: caddy-config

‎deploy/compose/compose.dev.yml‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
services:
2+
postgres:
3+
ports:
4+
- "${POSTGRES_PORT:-5432}:5432"
5+
6+
redis:
7+
ports:
8+
- "${REDIS_PORT:-6379}:6379"
9+
10+
typesense:
11+
environment:
12+
TYPESENSE_ENABLE_CORS: "true"
13+
ports:
14+
- "${TYPESENSE_PORT:-8108}:8108"
15+
16+
minio:
17+
ports:
18+
- "${MINIO_API_PORT:-9000}:9000"
19+
- "${MINIO_CONSOLE_PORT:-9001}:9001"
20+
21+
adminer:
22+
image: adminer:latest
23+
container_name: buzz-adminer
24+
depends_on:
25+
postgres:
26+
condition: service_healthy
27+
environment:
28+
ADMINER_DEFAULT_SERVER: postgres
29+
ports:
30+
- "${ADMINER_PORT:-8082}:8080"
31+
restart: unless-stopped
32+
networks:
33+
- buzz-net
34+
35+
prometheus:
36+
image: prom/prometheus:latest
37+
container_name: buzz-prometheus
38+
volumes:
39+
- ../../prometheus.yml:/etc/prometheus/prometheus.yml:ro
40+
- buzz-prometheus-data:/prometheus
41+
ports:
42+
- "${PROMETHEUS_PORT:-9090}:9090"
43+
extra_hosts:
44+
- "host.docker.internal:host-gateway"
45+
restart: unless-stopped
46+
networks:
47+
- buzz-net
48+
49+
volumes:
50+
buzz-prometheus-data:
51+
labels:
52+
com.buzz.volume: prometheus

‎deploy/compose/compose.yml‎

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: buzz-prod
2+
3+
services:
4+
relay:
5+
image: ${BUZZ_IMAGE:-ghcr.io/block/buzz:main}
6+
env_file:
7+
- .env
8+
environment:
9+
BUZZ_BIND_ADDR: 0.0.0.0:3000
10+
BUZZ_HEALTH_PORT: "8080"
11+
BUZZ_METRICS_PORT: "9102"
12+
DATABASE_URL: postgres://${POSTGRES_USER:-buzz}:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-buzz}
13+
REDIS_URL: redis://:${REDIS_PASSWORD:?set REDIS_PASSWORD}@redis:6379
14+
TYPESENSE_URL: http://typesense:8108
15+
BUZZ_S3_ENDPOINT: http://minio:9000
16+
BUZZ_S3_ACCESS_KEY: ${BUZZ_S3_ACCESS_KEY:?set BUZZ_S3_ACCESS_KEY}
17+
BUZZ_S3_SECRET_KEY: ${BUZZ_S3_SECRET_KEY:?set BUZZ_S3_SECRET_KEY}
18+
BUZZ_S3_BUCKET: ${BUZZ_S3_BUCKET:-buzz-media}
19+
BUZZ_GIT_REPO_PATH: /data/git
20+
BUZZ_AUTO_MIGRATE: ${BUZZ_AUTO_MIGRATE:-true}
21+
BUZZ_GIT_CONFORMANCE_PROBE: ${BUZZ_GIT_CONFORMANCE_PROBE:-true}
22+
ports:
23+
- "${BUZZ_HTTP_PORT:-3000}:3000"
24+
volumes:
25+
- buzz-git-data:/data/git
26+
depends_on:
27+
postgres:
28+
condition: service_healthy
29+
redis:
30+
condition: service_healthy
31+
typesense:
32+
condition: service_healthy
33+
minio:
34+
condition: service_healthy
35+
minio-init:
36+
condition: service_completed_successfully
37+
# Probe /_readiness over /dev/tcp because the runtime image has bash but no curl/wget/socat.
38+
healthcheck:
39+
test:
40+
[
41+
"CMD-SHELL",
42+
"bash -ec 'exec 3<>/dev/tcp/127.0.0.1/8080; printf \"GET /_readiness HTTP/1.1\\r\\nHost: 127.0.0.1\\r\\nConnection: close\\r\\n\\r\\n\" >&3; grep -q \"200 OK\" <&3'",
43+
]
44+
interval: 10s
45+
timeout: 3s
46+
retries: 12
47+
start_period: 30s
48+
restart: unless-stopped
49+
networks:
50+
- buzz-net
51+
52+
postgres:
53+
image: postgres:18-alpine
54+
environment:
55+
POSTGRES_DB: ${POSTGRES_DB:-buzz}
56+
POSTGRES_USER: ${POSTGRES_USER:-buzz}
57+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD}
58+
PGDATA: /var/lib/postgresql/data/pgdata
59+
volumes:
60+
- buzz-postgres-data:/var/lib/postgresql/data
61+
healthcheck:
62+
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
63+
interval: 5s
64+
timeout: 5s
65+
retries: 12
66+
start_period: 10s
67+
restart: unless-stopped
68+
networks:
69+
- buzz-net
70+
71+
redis:
72+
image: redis:8-alpine
73+
command: ["redis-server", "--appendonly", "yes", "--requirepass", "${REDIS_PASSWORD:?set REDIS_PASSWORD}"]
74+
environment:
75+
REDIS_PASSWORD: ${REDIS_PASSWORD:?set REDIS_PASSWORD}
76+
volumes:
77+
- buzz-redis-data:/data
78+
healthcheck:
79+
test: ["CMD-SHELL", "redis-cli -a \"$${REDIS_PASSWORD}\" ping | grep -q PONG"]
80+
interval: 5s
81+
timeout: 3s
82+
retries: 12
83+
start_period: 5s
84+
restart: unless-stopped
85+
networks:
86+
- buzz-net
87+
88+
typesense:
89+
image: typesense/typesense:30.2
90+
environment:
91+
TYPESENSE_DATA_DIR: /data
92+
TYPESENSE_API_KEY: ${TYPESENSE_API_KEY:?set TYPESENSE_API_KEY}
93+
TYPESENSE_ENABLE_CORS: "false"
94+
volumes:
95+
- buzz-typesense-data:/data
96+
healthcheck:
97+
test:
98+
[
99+
"CMD-SHELL",
100+
"bash -c 'exec 3<>/dev/tcp/127.0.0.1/8108; printf \"GET /health HTTP/1.1\\r\\nHost: 127.0.0.1\\r\\nConnection: close\\r\\n\\r\\n\" >&3; cat <&3 | grep -q ok'",
101+
]
102+
interval: 10s
103+
timeout: 5s
104+
retries: 12
105+
start_period: 15s
106+
restart: unless-stopped
107+
networks:
108+
- buzz-net
109+
110+
minio:
111+
image: minio/minio:RELEASE.2025-09-07T16-13-09Z
112+
command: server /data --console-address ":9001"
113+
environment:
114+
MINIO_ROOT_USER: ${BUZZ_S3_ACCESS_KEY:?set BUZZ_S3_ACCESS_KEY}
115+
MINIO_ROOT_PASSWORD: ${BUZZ_S3_SECRET_KEY:?set BUZZ_S3_SECRET_KEY}
116+
volumes:
117+
- buzz-minio-data:/data
118+
healthcheck:
119+
test: ["CMD", "curl", "-f", "http://127.0.0.1:9000/minio/health/live"]
120+
interval: 5s
121+
timeout: 5s
122+
retries: 12
123+
start_period: 10s
124+
restart: unless-stopped
125+
networks:
126+
- buzz-net
127+
128+
minio-init:
129+
image: minio/mc:RELEASE.2025-08-13T08-35-41Z
130+
depends_on:
131+
minio:
132+
condition: service_healthy
133+
environment:
134+
BUZZ_S3_ACCESS_KEY: ${BUZZ_S3_ACCESS_KEY:?set BUZZ_S3_ACCESS_KEY}
135+
BUZZ_S3_SECRET_KEY: ${BUZZ_S3_SECRET_KEY:?set BUZZ_S3_SECRET_KEY}
136+
BUZZ_S3_BUCKET: ${BUZZ_S3_BUCKET:-buzz-media}
137+
entrypoint: >
138+
/bin/sh -euc '
139+
mc alias set local http://minio:9000 "$${BUZZ_S3_ACCESS_KEY}" "$${BUZZ_S3_SECRET_KEY}"
140+
mc mb --ignore-existing "local/$${BUZZ_S3_BUCKET}"
141+
mc anonymous set none "local/$${BUZZ_S3_BUCKET}"
142+
'
143+
restart: "no"
144+
networks:
145+
- buzz-net
146+
147+
volumes:
148+
buzz-postgres-data:
149+
labels:
150+
com.buzz.volume: postgres
151+
buzz-redis-data:
152+
labels:
153+
com.buzz.volume: redis
154+
buzz-typesense-data:
155+
labels:
156+
com.buzz.volume: typesense
157+
buzz-minio-data:
158+
labels:
159+
com.buzz.volume: minio
160+
buzz-git-data:
161+
labels:
162+
com.buzz.volume: git
163+
164+
networks:
165+
buzz-net:
166+
driver: bridge
167+
labels:
168+
com.buzz.network: production

0 commit comments

Comments
 (0)