# Construct Docker Compose Example
# 
# Quick start:
#   1. Copy this file and set your API key
#   2. Run: docker compose up -d
#   3. Access gateway at http://localhost:42617
#
# For more info: https://github.com/KumihoIO/construct-os

services:
  construct:
    image: ghcr.io/kumihoio/construct-os:latest
    # For ARM64 environments where the distroless image exits immediately,
    # switch to the Debian compatibility image instead:
    # image: ghcr.io/kumihoio/construct-os:debian
    # Or build locally (distroless, no shell):
    # build: .
    # Or build the Debian variant (includes bash, git, curl):
    # build:
    #   context: .
    #   dockerfile: Dockerfile.debian
    container_name: construct
    restart: unless-stopped
    
    environment:
      # Required: Your LLM provider API key
      - API_KEY=${API_KEY:-}
      # Or use the prefixed version:
      # - CONSTRUCT_API_KEY=${CONSTRUCT_API_KEY:-}
      
      # Optional: LLM provider (default: openrouter)
      # Options: openrouter, openai, anthropic, ollama
      - PROVIDER=${PROVIDER:-openrouter}
      
      # Allow public bind inside Docker (required for container networking)
      - CONSTRUCT_ALLOW_PUBLIC_BIND=true
      # Default gateway port inside container
      - CONSTRUCT_GATEWAY_PORT=${CONSTRUCT_GATEWAY_PORT:-42617}
      
      # Optional: Model override
      # - CONSTRUCT_MODEL=anthropic/claude-sonnet-4-20250514
      
    volumes:
      # Persist workspace and config (must match WORKDIR/HOME in Dockerfile)
      - construct-data:/construct-data
      
    ports:
      # Gateway API port (override HOST_PORT if 42617 is taken)
      - "${HOST_PORT:-42617}:${CONSTRUCT_GATEWAY_PORT:-42617}"
    
    # Resource limits
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 512M
        reservations:
          cpus: '0.5'
          memory: 32M

    # Health check — uses lightweight status instead of full diagnostics.
    # For images with curl, prefer: curl -f http://localhost:42617/health
    healthcheck:
      test: ["CMD", "construct", "status", "--format=exit-code"]
      interval: 60s
      timeout: 10s
      retries: 3
      start_period: 10s

volumes:
  construct-data:
