# Bare-metal overlay — expose PostgreSQL and let the console reach
# a turnstone-server running outside Docker on the host machine.
#
# Requires TURNSTONE_HOST_IP set to the host's routable IP address.
#
# Usage:
#   export TURNSTONE_HOST_IP="$(hostname -I | awk '{print $1}')"
#   docker compose --profile production \
#     -f compose.yaml -f deploy/docker-compose.bare-metal.yml up
#
# Then on the host:
#   export TURNSTONE_JWT_SECRET="<same as .env>"
#   export TURNSTONE_DB_BACKEND=postgresql
#   export TURNSTONE_DB_URL="postgresql://turnstone:<pw>@localhost:5432/turnstone"
#   export TURNSTONE_NODE_ID="bare-metal-1"
#   export TURNSTONE_ADVERTISE_URL="http://${TURNSTONE_HOST_IP}:8080"
#   python -m turnstone.server --host 0.0.0.0 --port 8080 \
#     --base-url http://localhost:8000/v1 --api-key "$OPENAI_API_KEY"

services:
  postgres:
    ports:
      - "${POSTGRES_PORT:-5432}:5432"

  console:
    extra_hosts:
      - "host.docker.internal:host-gateway"
    environment:
      # Console needs to reach the bare-metal server on the host
      TURNSTONE_SERVER_URL: "http://${TURNSTONE_HOST_IP}:${SERVER_PORT:-8080}"

  channel:
    ports:
      - "${CHANNEL_PORT:-8091}:8091"
    environment:
      # Channel gateway advertises with host-routable IP so the
      # bare-metal server can reach it for schedule notifications
      TURNSTONE_CHANNEL_ADVERTISE_URL: "http://${TURNSTONE_HOST_IP}:${CHANNEL_PORT:-8091}"
      # Channel needs to reach the bare-metal server on the host
      TURNSTONE_SERVER_URL: "http://${TURNSTONE_HOST_IP}:${SERVER_PORT:-8080}"
