version: "3.9"

services:
  api-gateway:
    env_file: .env.local
    environment:
      - APP_DOMAIN=egommerce.local
      # - APP_PORT=40056
    ports:
      - '40056:443'
      - '40057:8080'
      - '5672:5672'
  
  api-registry:
    command: ["-ui-content-path=/registry", "-log-level=DEBUG"]
    environment:
      - APP_DOMAIN=registry.egommerce.local
      # - APP_PORT=40058
    ports:
      - '8300:8300'
      - '40058:8500'
      - '8600:8600/udp'

  api-eventbus:
    env_file: .env.local
    environment:
      - APP_DOMAIN=eventbus.egommerce.local
      # - APP_PORT=40059
    labels:
      - traefik.enable=true
      - traefik.tcp.routers.eventbus.rule=HostSNI(`*`)
      - traefik.tcp.routers.eventbus.entrypoints=rabbitmq
      - traefik.tcp.routers.eventbus.service=eventbus
      - traefik.tcp.services.eventbus.loadbalancer.server.port=5672
    ports:
      - '40059:8084'
      - '15672:15672'
  
  api-cache:
    env_file: .env.local
    environment:
      - APP_DOMAIN=redis.egommerce.local
    command: ["redis-server", "/etc/redis.conf", "--requirepass", "12345678"]
    ports:
      - 6379:6379

  api-logger:
    env_file: .env.local
    environment:
      - APP_DOMAIN=logger.egommerce.local
    ports:
      - 24224:24224

  # api-prometheus:
  #   environment:
  #     - APP_DOMAIN=prometheus.egommerce.local
  #   ports:
  #     - 9090:9090

  # api-grafana:
  #   environment:
  #     - APP_DOMAIN=grafana.egommerce.local
  #   ports:
  #     - 3000:3000

  postgres-db:
    env_file: .env.local
    environment:
      - APP_DOMAIN=postgres.egommerce.local
    ports:
      - 5432:5432

  mongo-db:
    env_file: .env.local
    environment:
      - APP_DOMAIN=mongo.egommerce.local
    ports:
      - 27017:27017

  identity-svc:
    env_file: .env.local
    environment:
      - APP_DOMAIN=identity.api.egommerce.local
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672
    ports:
      - 8080:80

  basket-svc:
    env_file: .env.local
    environment:
      - APP_DOMAIN=basket.api.egommerce.local
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672
    ports:
      - 8001:80

  catalog-svc:
    env_file: .env.local
    environment:
      - APP_DOMAIN=catalog.api.egommerce.local
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672
    ports:
      - 8002:80

  order-svc:
    env_file: .env.local
    environment:
      - APP_DOMAIN=order.api.egommerce.local
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672
    ports:
      - 8003:80

  pricing-svc:
    env_file: .env.local
    environment:
      - APP_DOMAIN=pricing.api.egommerce.local
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672
    ports:
      - 8004:80

  # Workers (EventBus)
  basket-worker:
    env_file: .env.local
    environment:
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672

  catalog-worker:
    env_file: .env.local
    environment:
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672

  pricing-worker:
    env_file: .env.local
    environment:
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672

  order-worker:
    env_file: .env.local
    environment:
      - DATABASE_URL=postgres://postgres:12345678@postgres-db:5432/egommerce
      - MONGODB_URL=mongodb://mongodb:12345678@mongo-db:27017
      - EVENTBUS_URL=amqp://guest:guest@api-eventbus:5672