# Vulcan CI server stack, distributed via get.vulcan-ci.io.
#
# Required configuration — export these, or put them in an .env file
# next to this compose file:
#   VULCAN_JWT_SECRET     token-signing secret (e.g. `openssl rand -hex 32`)
#   VULCAN_DB_PASSWORD    PostgreSQL password for the vulcan database user
#   VULCAN_WORKER_TOKEN   worker API token (wk_...) for automata → forge auth

services:
  forge:
    image: ghcr.io/vulcan-ci/vulcan-forge-backend:latest
    container_name: vulcan-forge
    ports:
      - "7079:7079"   # forge-backend API
      - "7080:7080"   # forge-ui (web)
      - "7081:7081"   # wall display
    environment:
      DATABASE_URL: "postgresql://vulcan:${VULCAN_DB_PASSWORD:?set VULCAN_DB_PASSWORD}@postgres:5432/vulcan"
      SERVER_PORT: "7079"
      JWT_SECRET: "${VULCAN_JWT_SECRET:?set VULCAN_JWT_SECRET (e.g. openssl rand -hex 32)}"
      RUST_LOG: "info"
    depends_on:
      postgres:
        condition: service_healthy
    networks:
      - vulcan
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://localhost:7079/health || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 15s

  automata:
    image: ghcr.io/vulcan-ci/vulcan-automata:latest
    container_name: vulcan-automata
    environment:
      FORGE_API_URL: "http://forge:7079"
      FORGE_API_TOKEN: "${VULCAN_WORKER_TOKEN:?set VULCAN_WORKER_TOKEN (worker token, wk_...)}"
      RUST_LOG: "info"
    depends_on:
      forge:
        condition: service_healthy
    networks:
      - vulcan

  postgres:
    image: postgres:16-bookworm
    container_name: vulcan-postgres
    environment:
      POSTGRES_DB: vulcan
      POSTGRES_USER: vulcan
      POSTGRES_PASSWORD: "${VULCAN_DB_PASSWORD:?set VULCAN_DB_PASSWORD}"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - vulcan
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U vulcan -d vulcan"]
      interval: 5s
      timeout: 3s
      retries: 10
      start_period: 5s

networks:
  vulcan:
    driver: bridge

volumes:
  postgres_data:
