services:
  apply-executor:
    image: tobikodata/tcloud:latest
    platform: linux/amd64
    command: executor apply
    restart: unless-stopped
    environment:
      # Tobiko Cloud connection
      TCLOUD_URL: https://internal.cloud.tobikodata.com/sqlmesh/${ORGANIZATION}/${PROJECT}
      TCLOUD_CLIENT_ID: ${TCLOUD_CLIENT_ID}
      TCLOUD_CLIENT_SECRET: ${TCLOUD_CLIENT_SECRET}
      
      # SQLMesh configuration
      SQLMESH__DEFAULT_GATEWAY: ${DEFAULT_GATEWAY:-GATEWAY_A}
      
      # Example database configuration (adjust for your database)
      # All database parameters below should be customized for your specific setup
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__TYPE: ${DB_TYPE}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__HOST: ${DB_HOST}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PORT: ${DB_PORT}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__DATABASE: ${DB_NAME}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__USER: ${DB_USER}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PASSWORD: ${DB_PASSWORD}
    volumes:
      # Optional volume for persistent storage if needed
      - apply-executor-data:/app/data
    deploy:
      resources:
        limits:
          memory: ${APPLY_MEMORY_LIMIT:-4g}
          cpus: ${APPLY_CPU_LIMIT:-2}
        reservations:
          memory: ${APPLY_MEMORY_REQUEST:-2g}
          cpus: ${APPLY_CPU_REQUEST:-1}

  run-executor:
    image: tobikodata/tcloud:latest
    platform: linux/amd64
    command: executor run
    restart: unless-stopped
    environment:
      # Tobiko Cloud connection
      TCLOUD_URL: https://internal.cloud.tobikodata.com/sqlmesh/${ORGANIZATION}/${PROJECT}
      TCLOUD_CLIENT_ID: ${TCLOUD_CLIENT_ID}
      TCLOUD_CLIENT_SECRET: ${TCLOUD_CLIENT_SECRET}
      
      # SQLMesh configuration
      SQLMESH__DEFAULT_GATEWAY: ${DEFAULT_GATEWAY:-GATEWAY_A}
      
      # Example database configuration (adjust for your database)
      # All database parameters below should be customized for your specific setup
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__TYPE: ${DB_TYPE}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__HOST: ${DB_HOST}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PORT: ${DB_PORT}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__DATABASE: ${DB_NAME}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__USER: ${DB_USER}
      SQLMESH__GATEWAYS__GATEWAY_A__CONNECTION__PASSWORD: ${DB_PASSWORD}
    volumes:
      # Optional volume for persistent storage if needed
      - run-executor-data:/app/data
    deploy:
      resources:
        limits:
          memory: ${PLAN_MEMORY_LIMIT:-4g}
          cpus: ${PLAN_CPU_LIMIT:-2}
        reservations:
          memory: ${PLAN_MEMORY_REQUEST:-2g}
          cpus: ${PLAN_CPU_REQUEST:-1}

volumes:
  apply-executor-data: {}
  run-executor-data: {}
