services:
  invariant-gateway:
    container_name: invariant-gateway
    build:
      context: .
      dockerfile: Dockerfile.gateway
    working_dir: /srv/gateway
    env_file:
      - .env
    environment:
      - DEV_MODE=true
      - GUARDRAILS_FILE_PATH=${GUARDRAILS_FILE_PATH:+/srv/resources/guardrails.py}
      - ${INVARIANT_API_KEY:+INVARIANT_API_KEY=${INVARIANT_API_KEY}}
    volumes:
      - type: bind
        source: ./gateway
        target: /srv/gateway
      - type: bind
        source: ${GUARDRAILS_FILE_PATH:-/dev/null}
        target: /srv/resources/guardrails.py
    networks:
      - invariant-explorer-web
    ports:
      - "8005:8000" # Direct access without Traefik
    labels:
    # For access via Traefik
      - "traefik.enable=true"
      - "traefik.http.routers.invariant-gateway-api.rule=(Host(`localhost`) && PathPrefix(`/api/v1/gateway/`)) || (Host(`127.0.0.1`) && PathPrefix(`/api/v1/gateway/`))"
      - "traefik.http.routers.invariant-gateway-api.entrypoints=invariant-explorer-web"
      - "traefik.http.services.invariant-gateway-api.loadbalancer.server.port=8000"
      - "traefik.docker.network=invariant-explorer-web"
networks:
  invariant-explorer-web:
    external: true