# NOTE: This Compose file defines a SINGLE-REPLICA topology. # Do not use `docker compose up --scale server=N` — the SQLite default supports # only one writer and the published host ports collide. Multi-replica deployments # require the Helm chart with PostgreSQL and leader election (deploy/helm/codex-lb). services: server: build: context: . dockerfile: Dockerfile env_file: - .env.local ports: - "2455:2455" - "1455:1455" command: # uvicorn directly (not `fastapi run`) so --ws-max-size matches the # websocket ingress budget that app.cli applies in production. - uvicorn - app.main:app - --host - 0.0.0.0 - --port - "2455" - --reload - --ws-max-size - "134217728" volumes: - codex-lb-data:/var/lib/codex-lb develop: watch: - action: sync path: ./app target: /app/app - action: rebuild path: ./pyproject.toml - action: rebuild path: ./uv.lock - action: rebuild path: ./Dockerfile restart: unless-stopped frontend: build: context: ./frontend dockerfile_inline: | FROM oven/bun:1.3.14-alpine WORKDIR /app COPY package.json bun.lock ./ RUN bun install --frozen-lockfile COPY . . CMD ["bun", "run", "dev", "--host", "0.0.0.0"] ports: - "5173:5173" environment: API_PROXY_TARGET: http://server:2455 develop: watch: - action: sync path: ./frontend target: /app ignore: - node_modules/ - action: rebuild path: ./frontend/package.json - action: rebuild path: ./frontend/bun.lock postgres: image: postgres:18-alpine profiles: ["postgres"] entrypoint: - sh - -ceu - | if [ -f /var/lib/postgresql/PG_VERSION ]; then echo >&2 "Detected a pre-Postgres-18 data directory at /var/lib/postgresql." echo >&2 "Run: docker compose --profile postgres-upgrade run --rm postgres-upgrade" echo >&2 "Refusing to start postgres:18-alpine before the named volume is upgraded." exit 1 fi if [ -f /var/lib/postgresql/data/PG_VERSION ]; then pg_major="$$(cat /var/lib/postgresql/data/PG_VERSION)" if [ "$$pg_major" != "18" ]; then echo >&2 "Detected a nested Postgres $$pg_major data directory at /var/lib/postgresql/data." echo >&2 "Run pg_upgrade against that data directory before starting postgres:18-alpine." echo >&2 "For the default Compose volume layout, run: docker compose --profile postgres-upgrade run --rm postgres-upgrade" exit 1 fi fi if [ "$#" -eq 0 ]; then set -- postgres fi exec docker-entrypoint.sh "$@" - codex-lb-postgres-entrypoint-guard environment: POSTGRES_USER: codex_lb POSTGRES_PASSWORD: codex_lb POSTGRES_DB: codex_lb ports: - "5432:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U codex_lb -d codex_lb"] interval: 10s timeout: 5s retries: 5 volumes: - codex-lb-postgres-data:/var/lib/postgresql restart: unless-stopped postgres-upgrade: image: pgautoupgrade/pgautoupgrade:18-alpine@sha256:55e168827ad48713ebc415bfefea83330a80ca7e81a1bcc11cc0bb7a3a531bde profiles: ["postgres-upgrade"] environment: POSTGRES_USER: codex_lb POSTGRES_PASSWORD: codex_lb POSTGRES_DB: codex_lb PGAUTO_ONESHOT: "yes" volumes: - codex-lb-postgres-data:/var/lib/postgresql restart: "no" volumes: codex-lb-data: name: codex-lb-data codex-lb-postgres-data: name: codex-lb-postgres-data