services:
  redis:
    image: "redis:alpine"
    command: redis-server
    ports:
      - "6379:6379"
    volumes:
      - $PWD/redis-data:/var/lib/redis
      - $PWD/redis.conf:/usr/local/etc/redis/redis.conf
    environment:
      - REDIS_REPLICATION_MODE=master
    

  helper:
    build:
      context: ./helper
    expose:
      - "8080"
    container_name: helper
    restart: unless-stopped
    volumes:
      - ./helper:/usr/src/app
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
      - vault:host-gateway
    environment:
      - CAPIF_HOSTNAME=${CAPIF_HOSTNAME}
      - CONTAINER_NAME=helper
      - VAULT_HOSTNAME=vault
      - VAULT_ACCESS_TOKEN=dev-only-token
      - VAULT_PORT=8200
      - LOG_LEVEL=${LOG_LEVEL}
    image: labs.etsi.org:5050/ocf/capif/helper:v2.x.x-release
    depends_on:
      - nginx

  access-control-policy:
    build:
      context: ./TS29222_CAPIF_Access_Control_Policy_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Access_Control_Policy_API:/usr/src/app
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
    environment:
      - CONTAINER_NAME=access-control-policy
      - MONITORING=${MONITORING}
      - LOG_LEVEL=${LOG_LEVEL}
    restart: unless-stopped
    image: labs.etsi.org:5050/ocf/capif/access-control-policy:v2.x.x-release
    depends_on:
      - redis
      - nginx

  api-invoker-management:
    build:
      context: ./TS29222_CAPIF_API_Invoker_Management_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_API_Invoker_Management_API:/usr/src/app
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
      - vault:host-gateway
    environment:
      - CONTAINER_NAME=api-invoker-management
      - MONITORING=${MONITORING}
      - VAULT_HOSTNAME=vault
      - VAULT_ACCESS_TOKEN=dev-only-token
      - VAULT_PORT=8200
      - LOG_LEVEL=${LOG_LEVEL}
    restart: unless-stopped
    image: labs.etsi.org:5050/ocf/capif/api-invoker-management-api:v2.x.x-release
    depends_on:
    - redis
    - nginx

  api-provider-management:
    build:
      context: ./TS29222_CAPIF_API_Provider_Management_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_API_Provider_Management_API:/usr/src/app
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
      - vault:host-gateway
    image: labs.etsi.org:5050/ocf/capif/api-provider-management-api:v2.x.x-release
    environment:
      - CONTAINER_NAME=api-provider-management
      - MONITORING=${MONITORING}
      - VAULT_HOSTNAME=vault
      - VAULT_ACCESS_TOKEN=dev-only-token
      - VAULT_PORT=8200
      - LOG_LEVEL=${LOG_LEVEL}
    depends_on:
      - redis
      - nginx

  logs:
    build:
      context: ./TS29222_CAPIF_Auditing_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Auditing_API:/usr/src/app
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
    restart: unless-stopped
    image: labs.etsi.org:5050/ocf/capif/auditing-api:v2.x.x-release
    environment:
      - CONTAINER_NAME=api-auditing
      - MONITORING=${MONITORING}
      - LOG_LEVEL=${LOG_LEVEL}
    depends_on:
      - mongo

  service-apis:
    build:
      context: ./TS29222_CAPIF_Discover_Service_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Discover_Service_API:/usr/src/app
    restart: unless-stopped
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
    image: labs.etsi.org:5050/ocf/capif/discover-service-api:v2.x.x-release
    environment:
      - CONTAINER_NAME=services-apis
      - MONITORING=${MONITORING}
      - LOG_LEVEL=${LOG_LEVEL}
    depends_on:
    - mongo

  capif-events:
    build:
      context: ./TS29222_CAPIF_Events_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Events_API:/usr/src/app
    image: labs.etsi.org:5050/ocf/capif/events-api:v2.x.x-release
    environment:
      - CONTAINER_NAME=api-events
      - MONITORING=${MONITORING}
      - LOG_LEVEL=${LOG_LEVEL}
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
    depends_on:
      - redis
      - mongo

  api-invocation-logs:
    build:
      context: ./TS29222_CAPIF_Logging_API_Invocation_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Logging_API_Invocation_API:/usr/src/app
    restart: unless-stopped
    image: labs.etsi.org:5050/ocf/capif/api-invocation-logs-api:v2.x.x-release
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
    environment:
      - CAPIF_HOSTNAME=${CAPIF_HOSTNAME}
      - CONTAINER_NAME=api-invocation-logs
      - MONITORING=${MONITORING}
      - LOG_LEVEL=${LOG_LEVEL}
    depends_on:
      - mongo

  published-apis:
    build:
      context: ./TS29222_CAPIF_Publish_Service_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Publish_Service_API:/usr/src/app
    restart: unless-stopped
    image: labs.etsi.org:5050/ocf/capif/publish-service-api:v2.x.x-release
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
    environment:
      - CONTAINER_NAME=api-publish-apis
      - MONITORING=${MONITORING}
      - LOG_LEVEL=${LOG_LEVEL}
    depends_on:
      - redis
      - mongo

  capif-routing-info:
    build:
      context: ./TS29222_CAPIF_Routing_Info_API
    expose:
      - "8080"
    image: labs.etsi.org:5050/ocf/capif/routing-info-api:v2.x.x-release

  capif-security:
    build:
      context: ./TS29222_CAPIF_Security_API
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Security_API:/usr/src/app
    restart: unless-stopped
    image: labs.etsi.org:5050/ocf/capif/security-api:v2.x.x-release
    environment:
      - CAPIF_HOSTNAME=${CAPIF_HOSTNAME}
      - CONTAINER_NAME=api-security
      - MONITORING=${MONITORING}
      - VAULT_HOSTNAME=vault
      - VAULT_ACCESS_TOKEN=dev-only-token
      - VAULT_PORT=8200
      - LOG_LEVEL=${LOG_LEVEL}
    extra_hosts:
      - host.docker.internal:host-gateway
      - fluent-bit:host-gateway
      - otel-collector:host-gateway
      - vault:host-gateway
    depends_on:
      - redis
      - nginx

  mongo:
    image: mongo:6.0.2
    logging:
      driver: 'none'
    restart: unless-stopped
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example
  
  mongo-express:
    image: mongo-express:1.0.0-alpha.4
    logging:
      driver: 'none'
    restart: unless-stopped
    ports:
      - 8082:8081
    environment:
      ME_CONFIG_MONGODB_ENABLE_ADMIN: true
      ME_CONFIG_BASICAUTH_USERNAME: admin
      ME_CONFIG_BASICAUTH_PASSWORD: admin
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: example
      ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
    depends_on:
      - mongo

  nginx:
    build:
      context: ./nginx
    ports:
      - "8080:8080"
      - "443:443"
    image: labs.etsi.org:5050/ocf/capif/nginx:v2.x.x-release
    environment:
      - CAPIF_HOSTNAME=${CAPIF_HOSTNAME}
      - VAULT_HOSTNAME=vault
      - VAULT_ACCESS_TOKEN=dev-only-token
      - VAULT_PORT=8200
      - LOG_LEVEL=${LOG_LEVEL}
    hostname: ${CAPIF_HOSTNAME}
    volumes:
      - ./nginx/certs:/etc/nginx/certs
    extra_hosts:
      - host.docker.internal:host-gateway
      - vault:host-gateway
    restart: unless-stopped
    depends_on:
      - redis
      - service-apis
      - api-invocation-logs
      - published-apis
      - capif-events
      - logs

networks:
  default:
    name: capif-network
    external: true
