Files
triggerdotdev--trigger.dev/docker/docker-compose.yml
T
Eric Allam 6c9f1f197e chore: parameterize docker host ports and wire s2-lite by default (#3642)
## Summary

Two papercuts new contributors hit running this repo locally:

1. Fresh clones default to v1 (Redis-only) realtime streams, so Sessions
and `chat.agent` error with `"S2 configuration is missing"`, even though
the `s2` service is already in `docker/docker-compose.yml` and pre-seeds
a `trigger-local` basin. Wire `REALTIME_STREAMS_S2_*` to it in
`.env.example` so the new-contributor flow just works. (Also drop the s2
healthcheck: the image is distroless, so the `wget` check always reports
unhealthy.)

2. Two clones can't both run `pnpm run docker` because ports, project
name, and container names are all hardcoded. Parameterize every host
port as `${VAR:-default}`, drive the project name via
`COMPOSE_PROJECT_NAME` (with a top-level `name:` field as the default),
prefix container names with `${CONTAINER_PREFIX:-}`, and pass
`--env-file .env` so compose reads the same root `.env` the webapp does.
The "Running multiple instances side by side" block in `.env.example`
lists every overridable knob.

Also split the optional services (`electric-shard-1`, `ch-ui`,
`toxiproxy`, `nginx-h2`, `otel-collector`, `prometheus`, `grafana`) into
`docker-compose.extras.yml` behind a new `pnpm run docker:full` script.
The core stack keeps everything the webapp actually needs to boot:
postgres, redis, electric, minio, clickhouse + migrator, s2-lite.

Defaults match every previous hardcoded value, so existing setups keep
working without touching `.env`.

## Test plan

- [x] `pnpm run docker` on a clean clone brings up the core services on
the standard ports under the `triggerdotdev-docker` project name.
- [x] Setting `COMPOSE_PROJECT_NAME=triggerdotdev-docker-alt` + the
`*_HOST_PORT` overrides in `.env` brings up a second stack alongside the
default one with no port or container-name clashes.
- [x] Webapp boots cleanly against the default `.env.example` values;
`/healthcheck` returns 200, no S2 errors.
- [x] s2-lite basin `trigger-local` accepts an append + read via the
same REST endpoints the webapp uses.
- [x] `pnpm run docker:full` brings up the optional services alongside
the core ones in the same project.
2026-05-18 09:28:58 +00:00

181 lines
5.3 KiB
YAML

# Core local-dev stack: the minimum a contributor needs to boot the webapp.
# For optional services (object store, observability, HTTP/2 proxy, chaos
# tooling, ClickHouse UI, extra electric shard) see ./docker-compose.extras.yml
# and the `pnpm run docker:full` script.
#
# Every host port is overridable via env vars from the root `.env` so multiple
# instances (worktrees, branch experiments) can run side by side. See the
# "Multiple instances" block in `.env.example` for the full set of knobs.
name: triggerdotdev-docker
volumes:
database-data:
database-data-alt:
redis-data:
minio-data:
clickhouse-data:
clickhouse-logs:
networks:
app_network:
external: false
services:
database:
container_name: ${CONTAINER_PREFIX:-}database
build:
context: .
dockerfile: Dockerfile.postgres
restart: always
volumes:
- ${DB_VOLUME:-database-data}:/var/lib/postgresql/data/
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
networks:
- app_network
ports:
- "${POSTGRES_HOST_PORT:-5432}:5432"
command:
- -c
- listen_addresses=*
- -c
- wal_level=logical
- -c
- shared_preload_libraries=pg_partman_bgw
redis:
container_name: ${CONTAINER_PREFIX:-}redis
image: redis:7@sha256:3e1b24a1a8f24ff926b15e5ace8c38a03e5657fb66e1fc7e5188e315aa5fa094
restart: always
volumes:
- redis-data:/data
networks:
- app_network
ports:
- "${REDIS_HOST_PORT:-6379}:6379"
# S3-compatible API for the local object store (large payloads / packet
# offload). Host :${MINIO_API_HOST_PORT:-9005} = S3 API,
# host :${MINIO_CONSOLE_HOST_PORT:-9006} = web console. The webapp only
# routes to it when the OBJECT_STORE_* env vars are set (see .env.example).
minio:
container_name: ${CONTAINER_PREFIX:-}minio
image: minio/minio:latest@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e
restart: always
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
volumes:
- minio-data:/data
ports:
- "${MINIO_API_HOST_PORT:-9005}:9000"
- "${MINIO_CONSOLE_HOST_PORT:-9006}:9001"
networks:
- app_network
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 5s
timeout: 5s
retries: 5
start_period: 5s
minio-init:
image: minio/mc:latest@sha256:a7fe349ef4bd8521fb8497f55c6042871b2ae640607cf99d9bede5e9bdf11727
depends_on:
minio:
condition: service_healthy
networks:
- app_network
entrypoint: /bin/sh
command:
- -c
- |
mc alias set local http://minio:9000 minioadmin minioadmin
mc mb -p local/packets || true
restart: "no"
electric:
container_name: ${CONTAINER_PREFIX:-}electric
image: electricsql/electric:1.2.4@sha256:20da3d0b0e74926c5623392db67fd56698b9e374c4aeb6cb5cadeb8fea171c36
restart: always
environment:
DATABASE_URL: postgresql://postgres:postgres@database:5432/postgres?sslmode=disable
ELECTRIC_INSECURE: true
ELECTRIC_ENABLE_INTEGRATION_TESTING: true
networks:
- app_network
ports:
- "${ELECTRIC_HOST_PORT:-3060}:3000"
depends_on:
- database
clickhouse:
image: clickhouse/clickhouse-server:25.6.2@sha256:97f0fe0f8729569e8c9d11069acee23abadeade4889f56ca3dc3df069f28cb85
restart: always
container_name: ${CONTAINER_PREFIX:-}clickhouse
ulimits:
nofile:
soft: 262144
hard: 262144
environment:
CLICKHOUSE_USER: default
CLICKHOUSE_PASSWORD: password
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
ports:
- "${CLICKHOUSE_HTTP_HOST_PORT:-8123}:8123"
- "${CLICKHOUSE_TCP_HOST_PORT:-9000}:9000"
volumes:
- clickhouse-data:/var/lib/clickhouse
- clickhouse-logs:/var/log/clickhouse-server
- ./config/clickhouse-disable-system-logs.xml:/etc/clickhouse-server/config.d/disable-system-logs.xml:ro
networks:
- app_network
healthcheck:
test:
[
"CMD",
"clickhouse-client",
"--host",
"localhost",
"--port",
"9000",
"--user",
"default",
"--password",
"password",
"--query",
"SELECT 1",
]
interval: "3s"
timeout: "5s"
retries: "5"
start_period: "10s"
clickhouse_migrator:
build:
context: ../internal-packages/clickhouse
dockerfile: ./Dockerfile
depends_on:
clickhouse:
condition: service_healthy
networks:
- app_network
command: ["goose", "${GOOSE_COMMAND:-up}"]
# s2-lite: open-source S2 (https://s2.dev) for local realtime streams v2.
# The image is distroless (no shell), so a `wget` / `curl` healthcheck
# always reports unhealthy even when the API is responding. No other
# service depends on this one, so the healthcheck is omitted.
s2:
image: ghcr.io/s2-streamstore/s2:latest@sha256:d6ded5ca7dd619fa7c946f06e39a98f9c95c6883c8bb884e5eaa129f232c920c
command: ["lite", "--init-file", "/s2-spec.json"]
volumes:
- ./config/s2-spec.json:/s2-spec.json:ro
ports:
- "${S2_HOST_PORT:-4566}:80"
networks:
- app_network