#
# Docker compose file that launches Jupyter Notebook for interactive iTango sessions over HTTP.
#
# Connect by surfing to http://localhost:8888/
# View logs through 'docker logs -f -t jupyter'
#
# Defines:
#   - jupyter: Jupyter Notebook with iTango support
#
version: '2'

services:
  jupyter:
    build:
        context: jupyter
        args:
            CONTAINER_EXECUTION_UID: ${CONTAINER_EXECUTION_UID}
    container_name: ${CONTAINER_NAME_PREFIX}jupyter
    network_mode: ${NETWORK_MODE}
    volumes:
        - ${TANGO_SKA_CONTAINER_MOUNT}
        - ${TANGO_LOFAR_CONTAINER_MOUNT}
        - ${TANGO_LOFAR_LOCAL_DIR}/jupyter-notebooks:/jupyter-notebooks:rw
        - ${HOME}:/hosthome
    environment:
      - TANGO_HOST=${TANGO_HOST}
      - XAUTHORITY=${XAUTHORITY}
      - DISPLAY=${DISPLAY}
    ports:
      - "8888:8888"
    user: ${CONTAINER_EXECUTION_UID}
    working_dir: /jupyter-notebooks
    entrypoint:
      - /usr/local/bin/wait-for-it.sh
      - ${TANGO_HOST}
      - --timeout=30
      - --strict
      - --
      - /usr/bin/tini -- /usr/local/bin/jupyter-notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token= --NotebookApp.password=
    restart: on-failure
