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}
    depends_on:
      - nginx

  access-control-policy:
    build: 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: public.ecr.aws/o2v4a8t6/opencapif/access-control-policy:3.1.3
    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: public.ecr.aws/o2v4a8t6/opencapif/api-invoker-management-api:3.1.3
    depends_on:
    - redis
    - nginx

  api-provider-management:
    build: 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: public.ecr.aws/o2v4a8t6/opencapif/api-provider-management-api:3.1.3
    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: public.ecr.aws/o2v4a8t6/opencapif/auditing-api:3.1.3
    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: public.ecr.aws/o2v4a8t6/opencapif/discover-service-api:3.1.3
    environment:
      - CONTAINER_NAME=services-apis
      - MONITORING=${MONITORING}
      - LOG_LEVEL=${LOG_LEVEL}
    depends_on:
    - mongo

  capif-events:
    build: TS29222_CAPIF_Events_API/.
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Events_API:/usr/src/app
    image: public.ecr.aws/o2v4a8t6/opencapif/events-api:3.1.3
    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: public.ecr.aws/o2v4a8t6/opencapif/api-invocation-logs-api:3.1.3
    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: TS29222_CAPIF_Publish_Service_API/.
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Publish_Service_API:/usr/src/app
    restart: unless-stopped
    image: public.ecr.aws/o2v4a8t6/opencapif/publish-service-api:3.1.3
    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: TS29222_CAPIF_Routing_Info_API/.
    expose:
      - "8080"
    image: public.ecr.aws/o2v4a8t6/opencapif/routing-info-api:3.1.3

  capif-security:
    build: TS29222_CAPIF_Security_API/.
    expose:
      - "8080"
    volumes:
      - ./TS29222_CAPIF_Security_API:/usr/src/app
    restart: unless-stopped
    image: public.ecr.aws/o2v4a8t6/opencapif/security-api:3.1.3
    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: public.ecr.aws/o2v4a8t6/opencapif/nginx:3.1.3
    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
