---
version: '3'

services:

  web:
    build: &BUILD
      context: .
      dockerfile: Dockerfile.dev
    command: gunicorn -c conf/gunicorn_local.py application:application
    environment: &ENVIRONMENT
      QUAY_OVERRIDE_CONFIG: |
        {
          "SERVER_HOSTNAME": "localhost:5000",
          "DB_URI": "mysql+pymysql://quay:quay@localhost/quay_dev",
          "BUILDLOGS_MODULE_AND_CLASS": null,
          "BUILDLOGS_OPTIONS": [],
          "BUILDLOGS_REDIS": { "host": "localhost" },
          "USER_EVENTS_REDIS": { "host": "localhost" },
          "BUILD_MANAGER": [
            "ephemeral",
            {
              "ALLOWED_WORKER_COUNT": 1,
              "ETCD_HOST": "localhost",
              "EXECUTORS": [
                {
                  "EXECUTOR": "popen"
                }
              ]
            }
          ]
        }
    ports:
      - 5000:5000
    network_mode: host
    volumes:
      - .:/quay-registry
      - ../quay-config-local/local:/quay-registry/conf/stack
    depends_on:
      - mysql
      - redis

  webpack:
    build: *BUILD
    command: npm run watch
    environment: *ENVIRONMENT
    network_mode: host
    volumes:
      - .:/quay-registry
      - ../quay-config-local/local:/quay-registry/conf/stack

  buildman:
    build: *BUILD
    command: python -m buildman.builder
    environment: *ENVIRONMENT
    network_mode: host
    volumes:
      - .:/quay-registry
      - ../quay-config-local/local:/quay-registry/conf/stack
      - ../quay-builder/bin/quay-builder:/usr/local/bin/quay-builder
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - etcd
      - redis

  notifications:
    build: *BUILD
    command: python -m workers.notificationworker.notificationworker
    environment: *ENVIRONMENT
    network_mode: host
    volumes:
      - .:/quay-registry
      - ../quay-config-local/local:/quay-registry/conf/stack

  mysql:
    image: mysql:5.6
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: quay_dev
      MYSQL_USER: quay
      MYSQL_PASSWORD: quay
    network_mode: host

  etcd:
    image: quay.io/coreos/etcd:v2.3.8
    environment:
      ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379
      ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
    network_mode: host

  redis:
    image: redis:3.2
    network_mode: host