# Upgrade overlay — one-shot database upgrade service.
#
# Usage:
#   # Preview changes (dry-run):
#   docker compose -f docker-compose.yml -f docker-compose.postgres.yml -f docker-compose.upgrade.yml run --rm upgrade --dry-run
#
#   # Apply upgrade:
#   docker compose -f docker-compose.yml -f docker-compose.postgres.yml -f docker-compose.upgrade.yml run --rm upgrade
#
#   # Check status:
#   docker compose -f docker-compose.yml -f docker-compose.postgres.yml -f docker-compose.upgrade.yml run --rm upgrade --status
#
# The upgrade service runs goclaw upgrade and exits. Use --rm to auto-remove the container.

services:
  upgrade:
    image: ghcr.io/nextlevelbuilder/goclaw:latest
    build:
      context: .
      dockerfile: Dockerfile
      args:
        ENABLE_OTEL: "false"
    env_file:
      - path: .env
        required: false
    environment:
      - GOCLAW_POSTGRES_DSN=postgres://${POSTGRES_USER:-goclaw}:${POSTGRES_PASSWORD:-goclaw}@postgres:5432/${POSTGRES_DB:-goclaw}?sslmode=disable
      - GOCLAW_CONFIG=/app/data/config.json
      - GOCLAW_MIGRATIONS_DIR=/app/migrations
      - GOCLAW_ENCRYPTION_KEY=${GOCLAW_ENCRYPTION_KEY:-}
    volumes:
      - goclaw-data:/app/data
    depends_on:
      postgres:
        condition: service_healthy
    entrypoint: ["/app/goclaw"]
    command: ["upgrade"]
    restart: "no"
