---
version: "3.7"

services:
  mission:
    image: docker-registry.zooxlabs.com/mission_service:latest
    depends_on:
      - postgres
    env_file:
      - ./envs/common.env
      - ./envs/mission.env
    ports:
      - "5110:80"
    command: migrate-and-run
    restart: on-failure
  mission_assignment_daemon:
    image: docker-registry.zooxlabs.com/mission_assignment_daemon:latest
    depends_on:
      - localstack
      - robot_pairing
    env_file:
      - ./envs/common.env
      - ./envs/mission_assignment_daemon.env
    restart: on-failure
  trip:
    image: docker-registry.zooxlabs.com/dispatch_trip:latest
    depends_on:
      - postgres
    env_file:
      - ./envs/common.env
      - ./envs/trip.env
    ports:
      - "5111:80"
    command: migrate-and-run
    restart: on-failure
  predetermined_route:
    image: docker-registry.zooxlabs.com/predetermined_route:latest
    depends_on:
      - postgres
    env_file:
      - ./envs/common.env
      - ./envs/predetermined_route.env
    ports:
      - "5112:80"
    command: migrate-and-run
    restart: on-failure
  user:
    image: docker-registry.zooxlabs.com/zoox_dispatch_user:latest
    depends_on:
      - postgres
    env_file:
      - ./envs/common.env
      - ./envs/user.env
    ports:
      - "5113:80"
    command: migrate-and-run
    restart: on-failure
  session:
    image: docker-registry.zooxlabs.com/zoox_dispatch_session:latest
    depends_on:
      - postgres
    env_file:
      - ./envs/common.env
      - ./envs/session.env
    ports:
      - "5114:80"
    command: migrate-and-run
    restart: on-failure
  vitals:
    image: docker-registry.zooxlabs.com/zoox_dispatch_vitals:latest
    depends_on:
      - postgres
    env_file:
      - ./envs/common.env
      - ./envs/vitals.env
    ports:
      - "5115:80"
    restart: on-failure
  geo:
    image: docker-registry.zooxlabs.com/maestro_geo:latest
    env_file:
      - ./envs/common.env
    ports:
      - "5116:80"
    restart: on-failure
  planner:
    image: docker-registry.zooxlabs.com/dispatch_planner:latest
    env_file:
      - ./envs/common.env
      - ./envs/planner.env
    ports:
      - "5117:80"
    restart: on-failure
  smoother:
    image: docker-registry.zooxlabs.com/route_smoother:latest
    environment:
      - ROUTE_SMOOTHER__MAP_BOX_CLIENT__TOKEN=${MAP_BOX_ACCESS_TOKEN}
    env_file:
      - ./envs/common.env
      - ./envs/smoother.env
    ports:
      - "5118:80"
    restart: on-failure
  client_gateway:
    image: docker-registry.zooxlabs.com/maestro_client_gateway:latest
    depends_on:
      - mission
      - user
      - session
      - trip
      - redis
      - smoother
      - planner
      - predetermined_route
    env_file:
      - ./envs/common.env
      - ./envs/client_gateway.env
    ports:
      - "5100:80"
    restart: on-failure
  robot_gateway:
    image: docker-registry.zooxlabs.com/maestro_robot_gateway:latest
    depends_on:
      - mission
      - user
      - trip
      - smoother
      - vitals
      - planner
      - robot_pairing
    env_file:
      - ./envs/common.env
      - ./envs/robot_gateway.env
    ports:
      - "5101:80"
    restart: on-failure
  admin_gateway:
    image: docker-registry.zooxlabs.com/dispatch_admin_gateway:latest
    depends_on:
      - mission
      - trip
      - redis
    env_file:
      - ./envs/common.env
      - ./envs/admin_gateway.env
    ports:
      - "5102:80"
    restart: on-failure
  fleetdash:
    image: docker-registry.zooxlabs.com/dispatch_admin_ui:1.1.4
    depends_on:
      - admin_gateway
    env_file:
      - ./envs/common.env
      - ./envs/fleetdash.env
    ports:
      - "5555:80"
    restart: on-failure
  robot_sims:
    image: docker-registry.zooxlabs.com/maestro_robot_sims:latest
    depends_on:
      - planner
      - robot_gateway
    env_file:
      - ./envs/common.env
      - ./envs/robot_sims.env
    command: run_daemon --processes 1
    restart: on-failure
  vitals_daemon:
    image: docker-registry.zooxlabs.com/robot_vitals_daemon:latest
    depends_on:
      - redis
    env_file:
      - ./envs/common.env
      - ./envs/vitals_daemon.env
    restart: on-failure
  robot_pairing:
    image: docker-registry.zooxlabs.com/maestro_robot_pairing:latest
    depends_on:
      - redis
    env_file:
      - ./envs/common.env
      - ./envs/robot_pairing.env
    restart: on-failure
  postgres:
    image: postgres:9.6
    volumes:
      - type: bind
        source: ./init-dbs.sh
        target: /docker-entrypoint-initdb.d/init-dbs.sh
    environment:
      - POSTGRES_PASSWORD=secret
  redis:
    image: redis:4.0
  # Source: https://github.com/localstack/localstack/blob/master/docker-compose.yml
  localstack:
    image: localstack/localstack
    ports:
      - "4567-4584:4567-4584"
      - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=${SERVICES- }
      - DEBUG=${DEBUG- }
      - DATA_DIR=${DATA_DIR- }
      - PORT_WEB_UI=${PORT_WEB_UI- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOSTNAME_EXTERNAL=localstack
      - HOSTNAME=localstack
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
  aws_setup:
    build: ./aws_setup
    env_file:
      - ./envs/common.env
    depends_on:
      - localstack

