version: "3.3"
services:

  #######################################################
  #  Gateway
  #######################################################
  gateway:
    image: gateway
    build:
      args:
        Version: "1"
      context: ../../
      dockerfile: src/ApiGateway/Dockerfile
    container_name: booking-gateway
    ports:
      - "5001:80"
      - "5000:443"
    depends_on:
      - postgres
      - rabbitmq
      - jaeger
      - elasticsearch
      - kibana
    volumes:
      - ~/.aspnet/https:/https:ro
    environment:
      - 'ASPNETCORE_URLS=https://+;http://+'
      - ASPNETCORE_HTTPS_PORT=5001
      - ASPNETCORE_Kestrel__Certificates__Default__Password=password
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
    networks:
      - booking


    #######################################################
    #  Flight
    #######################################################
  flight:
    image: flight
    build:
      args:
        Version: "1"
      context: ../../
      dockerfile: src/Services/Flight/Dockerfile
    container_name: flight
    ports:
      - 5004:80
      - 5003:443
    depends_on:
      - postgres
      - rabbitmq
      - jaeger
      - elasticsearch
      - kibana
      - mongo
    volumes:
      - ~/.aspnet/https:/https:ro
    environment:
      - 'ASPNETCORE_URLS=https://+;http://+'
      - ASPNETCORE_HTTPS_PORT=5003
      - ASPNETCORE_Kestrel__Certificates__Default__Password=password
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
    networks:
      - booking


    #######################################################
    #  Identity
    #######################################################
  identity:
    image: identity
    build:
      args:
        Version: "1"
      context: ../../
      dockerfile: src/Services/Identity/Dockerfile
    container_name: identity
    ports:
      - 6005:80
      - 5005:443
    depends_on:
      - postgres
      - rabbitmq
      - jaeger
      - elasticsearch
      - kibana
    volumes:
      - ~/.aspnet/https:/https:ro
    environment:
      - 'ASPNETCORE_URLS=https://+;http://+'
      - ASPNETCORE_HTTPS_PORT=5005
      - ASPNETCORE_Kestrel__Certificates__Default__Password=password
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
    networks:
      - booking


    #######################################################
    #  Passenger
    #######################################################
  passenger:
    image: passenger
    build:
      args:
        Version: "1"
      context: ../../
      dockerfile: src/Services/Passenger/Dockerfile
    container_name: passenger
    ports:
      - 6012:80
      - 5012:443
    depends_on:
      - postgres
      - rabbitmq
      - jaeger
      - elasticsearch
      - kibana
      - mongo
    volumes:
      - ~/.aspnet/https:/https:ro
    environment:
      - 'ASPNETCORE_URLS=https://+;http://+'
      - ASPNETCORE_HTTPS_PORT=5012
      - ASPNETCORE_Kestrel__Certificates__Default__Password=password
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
    networks:
      - booking


    #######################################################
    #  Booking
    #######################################################
  booking:
    image: booking
    build:
      args:
        Version: "1"
      context: ../../
      dockerfile: src/Services/Booking/Dockerfile
    container_name: booking
    ports:
      - 6010:80
      - 5010:443
    depends_on:
      - postgres
      - rabbitmq
      - jaeger
      - eventstore
      - elasticsearch
      - kibana
      - mongo
    volumes:
      - ~/.aspnet/https:/https:ro
    environment:
      - 'ASPNETCORE_URLS=https://+;http://+'
      - ASPNETCORE_HTTPS_PORT=5010
      - ASPNETCORE_Kestrel__Certificates__Default__Password=password
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
    networks:
      - booking


    ######################################################
    #  Postgres
    ######################################################
  postgres:
   image: postgres:latest
   container_name: postgres
   restart: on-failure
   ports:
     - '5432:5432'
   environment:
     - POSTGRES_USER=postgres
     - POSTGRES_PASSWORD=postgres
   networks:
     - booking


    #######################################################
    #  Rabbitmq
    #######################################################
  rabbitmq:
    container_name: rabbitmq
    image: rabbitmq:3-management
    restart: unless-stopped
    ports:
      - 5672:5672
      - 15672:15672
    networks:
      - booking


    #######################################################
    #  Jaeger
    #######################################################
  jaeger:
    image: jaegertracing/all-in-one
    container_name: jaeger
    restart: unless-stopped
    networks:
      - booking
    ports:
      - 5775:5775/udp
      - 5778:5778
      - 6831:6831/udp
      - 6832:6832/udp
      - 9411:9411
      - 14268:14268
      - 16686:16686


    #######################################################
    #  EventStoreDB
    #######################################################
  eventstore:
    container_name: eventstore
    image: eventstore/eventstore:21.2.0-buster-slim
    restart: on-failure
    environment:
      - EVENTSTORE_CLUSTER_SIZE=1
      - EVENTSTORE_RUN_PROJECTIONS=All
      - EVENTSTORE_START_STANDARD_PROJECTIONS=true
      - EVENTSTORE_EXT_TCP_PORT=1113
      - EVENTSTORE_EXT_HTTP_PORT=2113
      - EVENTSTORE_INSECURE=true
      - EVENTSTORE_ENABLE_EXTERNAL_TCP=true
      - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=true
    ports:
      - '1113:1113'
      - '2113:2113'
    networks:
      - booking


    #######################################################
    #  Mongo
    #######################################################
  mongo:
    image: mongo:5
    container_name: mongo
    restart: unless-stopped
    # environment:
    #   - MONGO_INITDB_ROOT_USERNAME=root
    #   - MONGO_INITDB_ROOT_PASSWORD=secret
    networks:
      - booking
    ports:
      - 27017:27017

    #######################################################
    #  Elastic Search
    #######################################################
  elasticsearch:
    container_name: elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
    restart: unless-stopped
    ports:
      - 9200:9200
    volumes:
      - elasticsearch-data:/usr/share/elasticsearch/data
    environment:
      - xpack.monitoring.enabled=true
      - xpack.watcher.enabled=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - discovery.type=single-node
    networks:
      - booking

      #######################################################
      #  Kibana
      #######################################################
  kibana:
    container_name: kibana
    image: docker.elastic.co/kibana/kibana:7.9.2
    restart: unless-stopped
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch
    environment:
      - ELASTICSEARCH_URL=http://localhost:9200
    networks:
      - booking



networks:
  booking:
    name: booking


volumes:
  db-data:
    external: false
  elasticsearch-data:



