version: '3'

services:
  # Configuration for Hub+Proxy
  jupyterhub:
    image: ${COMPOSE_PROJECT_NAME}_hub_img
    build: jupyterhub                # Build the container from this folder.
    container_name: ${COMPOSE_PROJECT_NAME}_hub    # The service will use this container name.
    volumes:                         # Give access to Docker socket.
      - /var/run/docker.sock:/var/run/docker.sock
      - ./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py
      - ../lists/adminlist:/srv/jupyterhub/adminlist
      - ../lists/userlist:/srv/jupyterhub/userlist
      - ../lists/idlist:/srv/jupyterhub/idlist # users in idlist have specific permissions
      - ../lists/grouplist:/srv/jupyterhub/grouplist
      - ../lists/projectlist:/srv/jupyterhub/projectlist
      - ../lists/dockerlist:/srv/jupyterhub/dockerlist
    environment:                     # Env variables passed to the Hub process.
      DOCKER_NETWORK_NAME: ${COMPOSE_PROJECT_NAME}_default
      URL_PREFIX: ${COMPOSE_PROJECT_NAME}
      HUB_IP: ${COMPOSE_PROJECT_NAME}_hub
      GITLAB_URL: ${GITLAB_URL}
      GITLAB_CLIENT_ID: ${GITLAB_CLIENT_ID}
      GITLAB_CLIENT_SECRET: ${GITLAB_CLIENT_SECRET}
      OAUTH_CALLBACK_URL: ${OAUTH_CALLBACK_URL}
    ports:
      - "8000:8000"

  # Configuration docker images to build, with prefix so they can easily be removed afterwards
  pytools4dart:
    image: ${COMPOSE_PROJECT_NAME}-pytools4dart
    build:
      context: ..
      dockerfile: ./hub/pytools4dart/Dockerfile
    network_mode: none
    command: echo

  qgis:
    image: ${COMPOSE_PROJECT_NAME}-qgis
    build: qgis
    network_mode: none
    command: echo
  
  biodivmapr:
    image: ${COMPOSE_PROJECT_NAME}-biodivmapr
    build: biodivmapr
    network_mode: none
    command: echo
  
  eodag:
    image: ${COMPOSE_PROJECT_NAME}-eodag
    build: eodag
    network_mode: none
    command: echo

networks:
   default:
      name: ${COMPOSE_PROJECT_NAME}_default

volumes:

  # WARNING: mounting the credentials as such will make them available to any user... 
  # So do not put your own, we are looking for a better solution.
  eodag: 
    name: ${COMPOSE_PROJECT_NAME}-eodag # necessary otherwise it is not mapped correctly by jupyterhub_config.py
    driver: local
    driver_opts:
      type: none
      o: bind
      device: ./eodag-cred

  notebooks:
    name: ${COMPOSE_PROJECT_NAME}-notebooks
    driver: local
    driver_opts:
      type: none
      o: bind
      device: ../notebooks
