Skip to content

Commit

Permalink
add docker configs for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
matuskosut committed Mar 8, 2024
1 parent 91214bb commit e8fd41e
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# MAKEFILE SETTINGS
# Silence default command echoing
.SILENT:
# Use one shell for all commands in a target recipe
.ONESHELL:
.EXPORT_ALL_VARIABLES:
# Set phony targets
.PHONY: help build up down
# Set default goal
.DEFAULT_GOAL := help
# Use bash shell in Makefile instead of sh
SHELL = /bin/bash

build: ## Build docker image
docker compose build

up: build ## Run docker compose service
docker compose up -d
sleep 3
echo "open http://127.0.0.1:8888/lab"
bash -c "open http://127.0.0.1:8888/lab"
sleep 2
docker logs -n 1000 -f jupyterlab-logout

down: ## Stop docker compose service
docker compose down
docker compose down --volumes

rebuild: down up ## Rebuild docker compose service

# Display target comments in 'make help'
help: ## Show this help
grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
17 changes: 17 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.9"

services:
jupyterlab:
image: jupyterlab-logout
build:
context: "."
dockerfile: setup/Dockerfile
container_name: jupyterlab-logout
restart: always
ports:
- 8888:8888
environment:
WORKBENCH_APP_ENABLED: 'true'
# WORKBENCH_APP_ENABLED: 'false'
volumes:
- "${PWD}:/home/jovyan/jupyterlab-logout"
34 changes: 34 additions & 0 deletions setup/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM jupyter/minimal-notebook:lab-4.0.7

USER root

RUN set -x \
&& apt-get update \
&& apt-get install -y curl vim less

# setup package, enable classic extension, build lab extension
USER "${NB_USER}"

RUN set -x \
&& mamba install -q -c conda-forge -y jupyter-server-proxy \
&& fix-permissions /opt/conda

WORKDIR "${HOME}/jupyterlab-logout"
COPY . .
RUN set -x \
&& python3 -m pip install "${HOME}/jupyterlab-logout" \
&& fix-permissions /opt/conda

WORKDIR "${HOME}"
RUN jupyter server extension enable --sys-prefix jupyter_server_proxy
RUN jupyter labextension disable "@jupyterlab/apputils-extension:announcements"

# copy configs, update permissions as root
USER root
RUN rm -rf "${HOME}/jupyterlab-logout"
RUN cp /etc/jupyter/jupyter_server_config.py /etc/jupyter/jupyter_server_config_base.py
COPY setup/jupyter_server_config.py /etc/jupyter/jupyter_server_config.py
RUN fix-permissions /etc/jupyter

USER "${NB_USER}"
WORKDIR "${HOME}"
15 changes: 15 additions & 0 deletions setup/jupyter_server_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
c = get_config() # noqa

# load base config
load_subconfig("/etc/jupyter/jupyter_server_config_base.py") # noqa

# supports iframe and samesite cookies
c.ServerApp.tornado_settings = {
"headers": {"Content-Security-Policy": "frame-ancestors 'self' *"},
"cookie_options": {"SameSite": "None", "Secure": True},
}
c.ServerApp.allow_root = True
c.ServerApp.allow_origin = "*"

c.IdentityProvider.token = ""
# c.ServerApp.default_url = "/lab"

0 comments on commit e8fd41e

Please sign in to comment.