version: '3'
services:

  postgres:
    image: postgres
    environment:
      - POSTGRES_DB=question
      - POSTGRES_PASSWORD=123456

  core:
    image: registry.gitlab.com/chiavegatto/question-core:latest
    depends_on:
      - postgres
    env_file: question.conf
    ports:
      - 8000:8000
    working_dir: /usr/src/app
    command: >-
                /bin/sh -c "./wait-for-it.sh -t 180 postgres:5432 -- echo 'postgres is up'
                && python -u manage.py migrate
                && python -u production-server.py"

  selenium:
    image: joyzoursky/python-chromedriver
    depends_on:
      - core
    working_dir: /usr/workspace
    volumes:
      - ./:/usr/workspace
    command: >-
              /bin/sh -c "./wait-for-it.sh -t 300 core:8000 -- echo 'core is up'
              && pip install -r requirements-e2e.txt
              && python question_test.py"