# Glyphh Runtime — generated by `glyphh docker init`
# Start:  docker compose up -d --wait
# Stop:   docker compose down
# Logs:   docker compose logs -f runtime

services:
  db:
    image: pgvector/pgvector:pg16
    container_name: glyphh-db
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-postgres}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
      POSTGRES_DB: ${POSTGRES_DB:-glyphh_runtime}
    ports:
      - "${DB_PORT:-5432}:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

  runtime:
    image: ghcr.io/glyphh-ai/glyphh-runtime:latest
    container_name: glyphh-runtime
    ports:
      - "${GLYPHH_PORT:-8002}:8002"
    environment:
      - DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-postgres}:${POSTGRES_PASSWORD:-postgres}@db:5432/${POSTGRES_DB:-glyphh_runtime}
      - PORT=8002
      - LOG_LEVEL=${LOG_LEVEL:-INFO}
    depends_on:
      db:
        condition: service_healthy
    volumes:
      - ${HOME}/.glyphh:/home/glyphh/.glyphh:ro
    healthcheck:
      test: ["CMD-SHELL", "python -c \"import urllib.request; urllib.request.urlopen('http://localhost:8002/health')\""]
      interval: 10s
      timeout: 5s
      retries: 30
      start_period: 30s
    restart: unless-stopped

volumes:
  pgdata:
