Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notebook service #107

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ venv.bak/
# -- Tools
.coverage

# Jupytext: we version converted md files not ipynb sources
*.ipynb

# -- Provisioning
provisioning/.terraform*
provisioning/terraform.tfstate*
25 changes: 23 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ bootstrap: \
create-metabase-db \
seed-metabase \
seed-oidc \
create-superuser
create-superuser \
jupytext--to-ipynb
.PHONY: bootstrap

build: ## build services image
Expand All @@ -55,6 +56,10 @@ build-client: ## build the client image
$(COMPOSE) build client
.PHONY: build-client

build-notebook: ## build custom jupyter notebook image
@$(COMPOSE) build notebook
.PHONY: build-notebook

down: ## stop and remove all containers
@$(COMPOSE) down
.PHONY: down
Expand All @@ -67,14 +72,22 @@ logs-api: ## display API server logs (follow mode)
@$(COMPOSE) logs -f api
.PHONY: logs-api

logs-notebook: ## display notebook logs (follow mode)
@$(COMPOSE) logs -f notebook
.PHONY: logs-notebook

run: ## run the api server (and dependencies)
$(COMPOSE) up -d api
.PHONY: run

run-all: ## run the whole stack
$(COMPOSE) up -d api keycloak metabase
$(COMPOSE) up -d api keycloak metabase notebook
.PHONY: run-all

run-notebook: ## run the notebook service
$(COMPOSE) up -d notebook
.PHONY: run-notebook

status: ## an alias for "docker compose ps"
@$(COMPOSE) ps
.PHONY: status
Expand Down Expand Up @@ -132,6 +145,14 @@ create-superuser: ## create super user
--force
.PHONY: create-superuser

jupytext--to-md: ## convert local ipynb files into md
bin/jupytext --to md work/src/notebook/**/*.ipynb
.PHONY: jupytext--to-md

jupytext--to-ipynb: ## convert remote md files into ipynb
bin/jupytext --to ipynb work/src/notebook/**/*.md
.PHONY: jupytext--to-ipynb

seed-metabase: ## seed the Metabase server
@echo "Running metabase service …"
@$(COMPOSE) up -d --wait metabase
Expand Down
6 changes: 6 additions & 0 deletions bin/jupytext
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

declare DOCKER_USER
DOCKER_USER="$(id -u):$(id -g)"

DOCKER_USER=${DOCKER_USER} docker compose run --rm notebook jupytext "$@"
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ services:
depends_on:
- postgresql

notebook:
build:
context: .
dockerfile: src/notebook/Dockerfile
user: ${DOCKER_USER:-1000}
environment:
NB_UID: ${DOCKER_UID:-1000}
NB_GID: ${DOCKER_GID:-1000}
CHOWN_HOME: 'yes'
CHOWN_HOME_OPTS: -R
ports:
- 8888:8888
volumes:
- .:/home/jovyan/work
depends_on:
- postgresql

# -- tools
curl:
image: curlimages/curl:8.8.0
Expand Down
2 changes: 1 addition & 1 deletion src/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update && \
# Upgrade pip to its latest release to speed up dependencies
# installation
RUN pip install --upgrade pip && \
pip install pipenv
pip install pipenv==2024.0.1

# Pipenv configuration
ENV PIPENV_USER_UID ${DOCKER_UID}
Expand Down
11 changes: 11 additions & 0 deletions src/notebook/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -- Custom image --
FROM jupyter/base-notebook

# Install base dependencies
RUN mamba install --yes \
duckdb \
geopandas \
jupytext \
matplotlib \
pandas \
seaborn
Empty file added src/notebook/analyses/.keep
Empty file.
Empty file added src/notebook/indicators/.keep
Empty file.
Loading