version: "3.9"

services:
  authority:
    build:
      context: ../..
      dockerfile: ops/authority/Dockerfile
    image: stellaops-authority:dev
    container_name: stellaops-authority
    depends_on:
      mongo:
        condition: service_started
    environment:
      # Override issuer to match your deployment URL.
      STELLAOPS_AUTHORITY__ISSUER: "https://authority.localtest.me"
      # Point the Authority host at the Mongo instance defined below.
      STELLAOPS_AUTHORITY__PLUGINDIRECTORIES__0: "/app/plugins"
      STELLAOPS_AUTHORITY__PLUGINS__CONFIGURATIONDIRECTORY: "/app/etc/authority.plugins"
    volumes:
      # Mount Authority configuration + plugins (edit etc/authority.yaml before running).
      - ../../etc/authority.yaml:/etc/authority.yaml:ro
      - ../../etc/authority.plugins:/app/etc/authority.plugins:ro
      # Optional: persist plugin binaries or key material outside the container.
      - authority-keys:/app/keys
    ports:
      - "8080:8080"
    restart: unless-stopped

  mongo:
    image: mongo:7
    container_name: stellaops-authority-mongo
    command: ["mongod", "--bind_ip_all"]
    environment:
      MONGO_INITDB_ROOT_USERNAME: stellaops
      MONGO_INITDB_ROOT_PASSWORD: stellaops
    volumes:
      - mongo-data:/data/db
    ports:
      - "27017:27017"
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    container_name: stellaops-authority-redis
    command: ["redis-server", "--save", "60", "1"]
    volumes:
      - redis-data:/data
    ports:
      - "6379:6379"
    restart: unless-stopped
    # Uncomment to enable if/when Authority consumes Redis.
    # deploy:
    #   replicas: 0

volumes:
  mongo-data:
  redis-data:
  authority-keys:
