version: "3.9"

services:
  conductor:
    image: docker.adaoncloud.com/automation/conductor:staging
    depends_on:
      - mongo
      - rabbitmq
      # - redis
      - analytics
    restart: unless-stopped
    environment:
      pollinginterval: 10
      dbhost: mongodb://${MONGO_USER}:${MONGO_PASSWORD}@mongo:27017/
      rabbitmq: amqp://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@rabbitmq:5672/
      # redis: redis,password=${REDIS_PASSWORD}

  api:
    image: docker.adaoncloud.com/automation/api:staging
    ports:
      - ${API_PORT}:80
    depends_on:
      - conductor
      - mongo
      - redis
    environment:
      - DOTNET_ENVIRONMENT=${ENVIRONMENT}
      - CONDUCTOR_API_BASE_URL=http://conductor/api/
      - ADA_API_BASE_URL=https://st.apiautomation.adaoncloud.com
      - ADA_TOKEN_PRE_AUTHORIZATION_HEADER=${ADA_TOKEN_PRE_AUTHORIZATION_HEADER}
      - ADA_JWT_SECRET=${ADA_JWT_SECRET}
      - ADA_JWT_DECODE_KEY=${ADA_JWT_DECODE_KEY}
      - DB_HOST=mongodb://${MONGO_USER}:${MONGO_PASSWORD}@mongo:27017/
      - REDIS_HOST=redis,password=${REDIS_PASSWORD}

  client:
    image: docker.adaoncloud.com/automation/client:staging
    volumes:
      - ./environment.js:/usr/share/nginx/html/environment.js
    ports:
      - ${CLIENT_PORT}:80

  events:
    image: docker.adaoncloud.com/automation/events:staging
    ports:
      - ${EVENTS_PORT}:80
    depends_on:
      - conductor
      - rabbitmq
    environment:
      - DOTNET_ENVIRONMENT=${ENVIRONMENT}
      - CONDUCTOR_API_BASE_URL=http://conductor/api/
      - ADA_JWT_SECRET=${ADA_JWT_SECRET}
      - RABBITMQ_HOST=rabbitmq://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@rabbitmq:5672/

  actions:
    image: docker.adaoncloud.com/automation/actions:staging
    depends_on:
      - rabbitmq
    environment:
      - DOTNET_ENVIRONMENT=${ENVIRONMENT}
      - ADA_API_BASE_URL=https://st.apiautomation.adaoncloud.com
      - ADA_TOKEN_PRE_AUTHORIZATION_HEADER=${ADA_TOKEN_PRE_AUTHORIZATION_HEADER}
      - RABBITMQ_HOST=rabbitmq://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@rabbitmq:5672/

  starter:
    image: docker.adaoncloud.com/automation/starter:staging
    depends_on:
      - conductor
      - rabbitmq
      - redis
    environment:
      - DOTNET_ENVIRONMENT=${ENVIRONMENT}
      - CONDUCTOR_API_BASE_URL=http://conductor/api/
      - ADA_API_BASE_URL=https://st.apiautomation.adaoncloud.com
      - ADA_TOKEN_PRE_AUTHORIZATION_HEADER=${ADA_TOKEN_PRE_AUTHORIZATION_HEADER}
      - DB_HOST=mongodb://${MONGO_USER}:${MONGO_PASSWORD}@mongo:27017/
      - RABBITMQ_HOST=rabbitmq://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@rabbitmq:5672/
      - REDIS_HOST=redis,password=${REDIS_PASSWORD}

  analytics:
    image: docker.adaoncloud.com/automation/analytics:staging
    depends_on:
      - mongo
      - rabbitmq
    environment:
      - DOTNET_ENVIRONMENT=${ENVIRONMENT}
      - DB_HOST=mongodb://${MONGO_USER}:${MONGO_PASSWORD}@mongo:27017/
      - RABBITMQ_HOST=rabbitmq://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@rabbitmq:5672/

  # actions.send-email:
  #   image: docker.adaoncloud.com/automation/actions-send-email:staging
  #   depends_on:
  #     - conductor
  #   environment:
  #     - DOTNET_ENVIRONMENT=${ENVIRONMENT}
  #     - CONDUCTOR_API_BASE_URL=http://conductor/api/
  #     - ADA_API_BASE_URL=https://st.apiautomation.adaoncloud.com
  #     - ADA_TOKEN_PRE_AUTHORIZATION_HEADER=${ADA_TOKEN_PRE_AUTHORIZATION_HEADER}

  # actions.send-sms:
  #   image: docker.adaoncloud.com/automation/actions-send-sms:staging
  #   depends_on:
  #     - conductor
  #   environment:
  #     - DOTNET_ENVIRONMENT=${ENVIRONMENT}
  #     - CONDUCTOR_API_BASE_URL=http://conductor/api/
  #     - ADA_API_BASE_URL=https://st.apiautomation.adaoncloud.com
  #     - ADA_TOKEN_PRE_AUTHORIZATION_HEADER=${ADA_TOKEN_PRE_AUTHORIZATION_HEADER}

  # actions.add-to-group:
  #   image: docker.adaoncloud.com/automation/actions-add-to-group:staging
  #   depends_on:
  #     - conductor
  #   environment:
  #     - DOTNET_ENVIRONMENT=${ENVIRONMENT}
  #     - CONDUCTOR_API_BASE_URL=http://conductor/api/
  #     - ADA_API_BASE_URL=https://st.apiautomation.adaoncloud.com
  #     - ADA_TOKEN_PRE_AUTHORIZATION_HEADER=${ADA_TOKEN_PRE_AUTHORIZATION_HEADER}

  operators.belongs-to-group:
    image: docker.adaoncloud.com/automation/operators-belongs-to-group:staging
    depends_on:
      - conductor
    environment:
      - DOTNET_ENVIRONMENT=${ENVIRONMENT}
      - CONDUCTOR_API_BASE_URL=http://conductor/api/
      - ADA_API_BASE_URL=https://st.apiautomation.adaoncloud.com
      - ADA_TOKEN_PRE_AUTHORIZATION_HEADER=${ADA_TOKEN_PRE_AUTHORIZATION_HEADER}

  mongo:
    image: mongo:6.0.3
    ports:
      - 27022:27017
    environment:
      - MONGO_INITDB_ROOT_USERNAME=${MONGO_USER}
      - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}
    volumes:
      - mongo_data:/data/db

  rabbitmq:
    image: rabbitmq:3.11.4-management-alpine
    hostname: rabbitmq
    ports:
    #   - 5672:5672
      - 15672:15672
    environment:
      - RABBITMQ_DEFAULT_USER=${RABBITMQ_USER}
      - RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD}
    volumes:
      - rabbitmq_data:/var/lib/rabbitmq/

  redis:
    image: "redis:alpine"
    command: >
        --requirepass ${REDIS_PASSWORD}
    ports:
      - 6382:6379
volumes:
  mongo_data:
  rabbitmq_data:
  redis_data:
