version: "2"
services:

  base:
    build: .
    command: bash -c "mbs-upgradedb && mbs-gencert && touch /etc/module-build-service/.ready"
    volumes:
      - ./:/tmp/module_build_service:z
      - /etc/module-build-service
      - /tmp/module_build_service/module_build_service.egg-info

  fedmsg-relay:
    depends_on:
      - base
    build: .
    command: bash -c "while [ ! -f /etc/module-build-service/.ready ] ; do sleep 1 ; done ; fedmsg-relay"
    expose:
      - 2001
      - 2003
    ports:
      - "5001:2001"
    volumes_from:
      - base

  scheduler:
    depends_on:
      - base
    build: .
    command: bash -c "while [ ! -f /etc/module-build-service/.ready ] ; do sleep 1 ; done ; fedmsg-hub"
    links:
      - fedmsg-relay
    environment:
      # Check /var/tmp/krbcc and make sure that it is not a directory.  If it
      # is, then delete it with 'sudo rm -rf /var/tmp/krbcc'.
      # Initialize the file before running 'docker-compose up' with:
      # $ KRB5CCNAME=FILE:/var/tmp/krbcc kinit YOUR_USERNAME@FEDORAPROJECT.ORG
      - KRB5CCNAME=FILE:/var/tmp/krbcc
    volumes_from:
      - base
    volumes:
      - /tmp/mbs-krbcc:/var/tmp/krbcc:Z

  frontend:
    depends_on:
      - base
    build: .
    command: bash -c "while [ ! -f /etc/module-build-service/.ready ] ; do sleep 1 ; done ; mbs-frontend"
    ports:
      - "5000:5000"
    links:
      - scheduler
      - fedmsg-relay
    volumes_from:
      - base
