---
version: "3.7"

services:
  aws_setup:
    build: ./aws_setup
    env_file:
      - ./envs/common.env
    depends_on:
      - localstack
  postgres:
    image: postgres:9.6
    volumes:
      - "./init-db.sql:/docker-entrypoint-initdb.d/init-dbs.sql"
    environment:
      - POSTGRES_PASSWORD=secret
  # Source: https://github.com/localstack/localstack/blob/master/docker-compose.yml
  localstack:
    image: localstack/localstack
    ports:
      - "4566:4566"
    environment:
      - SERVICES=sns,sqs
      - 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"
  merge_priority_manager:
    image: merge_priority_manager:latest
    depends_on:
      - postgres
    env_file:
      - ./envs/common.env
      - ./envs/merge_priority_manager.env
    ports:
      - "5110:80"
    command: migrate-and-run
    restart: on-failure
  merge_conflict_check_daemon:
    image: merge_conflict_check_daemon:latest
    depends_on:
      - merge_priority_manager
      - localstack
    env_file:
      - ./envs/common.env
      - ./envs/merge_conflict_check_daemon.env
    volumes:
      - "./github_id_rsa:/ssh-key/ssh-privatekey"
    restart: on-failure
