version: "2"

services:

  ui:
    build: ./ui
    networks:
      - cloudcms
    depends_on:
      - apilb
    env_file:
      - ./ui/ui.env
    ports:
      - "80:80"

  apilb:
    build: ./apilb
    networks:
      - cloudcms
    depends_on:
      - api1
      - api2
    ports:
      - "8080:8080"
      - "8085:8085"
    expose:
      - "8080"
    
  api1:
    build: ./api1
    networks:
      - cloudcms
    depends_on:
      - mongodb
      - elasticsearch
    env_file:
      - ./api1/api.env
    ports:
      - "8091:8080"
    expose:
      - "8080"
      - "6301"

  api2:
    build: ./api2
    networks:
      - cloudcms
    depends_on:
      - mongodb
      - elasticsearch
    env_file:
      - ./api2/api.env
    ports:
      - "8092:8080"
    expose:
      - "8080"
      - "6302"

  apiworker1:
    build: ./apiworker1
    networks:
      - cloudcms
    depends_on:
      - mongodb
      - elasticsearch
    env_file:
      - ./apiworker1/api.env
    expose:
      - "6303"

  apiworker2:
    build: ./apiworker2
    networks:
      - cloudcms
    depends_on:
      - mongodb
      - elasticsearch
    env_file:
      - ./api2/api.env
    expose:
      - "6304"

  mongodb:
    build: ./mongodb
    networks:
      - cloudcms
    ports:
      - "27017:27017"
    expose:
      - "27017"
    command: mongod --config /etc/mongod.conf

  elasticsearch:
    build: ./elasticsearch
    networks:
      - cloudcms
    environment:
      - "cluster.name=cloudcms-docker"
      - "transport.host=elasticsearch"
      - "network.host=elasticsearch"
      - "discovery.type=single-node"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - "9300:9300"
      - "9200:9200"

networks:
  cloudcms:
    driver: bridge