diff --git a/.env.sample b/.env.sample index 7e12bc7..9054aca 100644 --- a/.env.sample +++ b/.env.sample @@ -2,6 +2,12 @@ TYPE=jupyter-lab DOMAIN=jupyter-lab.example.com +COMPOSE_FILE="compose.yml" + ## Domain aliases #EXTRA_DOMAINS=', `www.jupyter-lab.example.com`' LETS_ENCRYPT_ENV=production + +# SSH access +#SECRET_SSH_KEY_VERSION=v1 +#COMPOSE_FILE="$COMPOSE_FILE:compose.ssh.yml" diff --git a/abra.sh b/abra.sh new file mode 100644 index 0000000..724bb11 --- /dev/null +++ b/abra.sh @@ -0,0 +1 @@ +export INSTALL_PACKAGES_CONF_VERSION=v6 diff --git a/compose.ssh.yml b/compose.ssh.yml new file mode 100644 index 0000000..cb4182e --- /dev/null +++ b/compose.ssh.yml @@ -0,0 +1,16 @@ +--- +version: "3.8" + +services: + app: + secrets: + - source: ssh_key + target: /home/jovyan/.ssh/id_rsa + mode: 0400 + uid: '1000' + gid: '1000' + +secrets: + ssh_key: + external: true + name: ${STACK_NAME}_ssh_key_${SECRET_SSH_KEY_VERSION} diff --git a/compose.yml b/compose.yml index f3ed87b..771e919 100644 --- a/compose.yml +++ b/compose.yml @@ -8,6 +8,12 @@ services: - proxy environment: - JUPYTER_ENABLE_LAB=yes + volumes: + - jupyter_data:/home/jovyan + configs: + - source: install-packages_conf + target: /usr/local/bin/start-notebook.d/install-packages + mode: 0555 deploy: restart_policy: condition: on-failure @@ -27,6 +33,56 @@ services: # timeout: 10s # retries: 10 # start_period: 1m + # + + voila: + image: jupyter/datascience-notebook:r-4.1.1 + networks: + - proxy + environment: + - JUPYTER_ENABLE_LAB=yes + volumes: + - jupyter_data:/home/jovyan + command: > + bash -c + " + pip install ipywidgets jupyterlab-git voila && + voila \ + --enable_nbextensions=True \ + --autoreload=True \ + --Voila.ip=0.0.0.0 \ + --no-browser \ + --MappingKernelManager.cull_interval=60 \ + --MappingKernelManager.cull_idle_timeout=120 + " + + configs: + - source: install-packages_conf + target: /usr/local/bin/start-notebook.d/install-packages + mode: 0555 + deploy: + restart_policy: + condition: on-failure + labels: + - "traefik.enable=true" + - "traefik.http.services.${STACK_NAME}_voila.loadbalancer.server.port=8866" + - "traefik.http.routers.${STACK_NAME}_voila.rule=Host(`dashboard.${DOMAIN}`)" + - "traefik.http.routers.${STACK_NAME}_voila.entrypoints=web-secure" + - "traefik.http.routers.${STACK_NAME}_voila.tls.certresolver=${LETS_ENCRYPT_ENV}" + # healthcheck: + # test: ["CMD", "curl", "-f", "http://localhost"] + # interval: 30s + # timeout: 10s + # retries: 10 + # start_period: 1m + +volumes: + jupyter_data: + +configs: + install-packages_conf: + name: ${STACK_NAME}_install_packages_${INSTALL_PACKAGES_CONF_VERSION} + file: install-packages.sh networks: proxy: diff --git a/install-packages.sh b/install-packages.sh new file mode 100644 index 0000000..398da76 --- /dev/null +++ b/install-packages.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +pip install ipywidgets jupyterlab-git