version: '3.2'

services:
  test:
    build:
        context: .
        cache_from:
          - lasnq/nqontrol
    image: lasnq/nqontrol
    command: bash -c "rsync -ur --exclude settings_local.py /mnt/* /code/ && cp /mnt/src/tests/user_configuration.py /root/.nqontrol.py && make test && chown -R 1000:1000 /code/src/nqontrol/htmlcov"
    environment:
      PYTHONPATH: "/code/src"
      RUNNING_IN_DOCKER: 'true'
    volumes:
      - ./:/mnt:ro
      - ./htmlcov:/code/src/nqontrol/htmlcov:rw

  build:
    build:
        context: .
        cache_from:
          - lasnq/nqontrol
    image: lasnq/nqontrol
    command: bash -c "rsync -ur /mnt/{*,.git} /code/ && make bdist && chown -R 1000:1000 /code/dist"
    environment:
      PYTHONPATH: "/code/src"
    volumes:
      - ./:/mnt:ro
      - ./dist:/code/dist:rw

  doc:
    build:
        context: .
        cache_from:
          - lasnq/nqontrol
    image: lasnq/nqontrol
    command: bash -c "rsync -ur /mnt/* /code/ && make doc && chown -R 1000:1000 /code/doc/_build"
    environment:
      PYTHONPATH: "/code/src"
    volumes:
      - ./:/mnt:ro
      - ./doc/_build:/code/doc/_build:rw

  gui:
    build:
        context: .
        cache_from:
          - lasnq/nqontrol
    command: bash -c "rsync -ur /mnt/* /code/ && ipython3 `pwd`/src/nqontrol/gunirun.py"
    environment:
      PYTHONPATH: "/code/src"
    volumes:
      - ./:/mnt:ro
    ports:
      - "8000:8000"
