Skip to content

Commit f982515

Browse files
Vismayaklmarinilongshuicy
authored
Integration of Jupyter through docker-compose (#1088)
* Working Jupyterhub Integration * Linting * Handling logout * Updating docker-compose to keep jupyterhub version static * Incorporating feedback * Working Jupyterhub Integration * Linting * Handling logout * Updating docker-compose to keep jupyterhub version static * Incorporating feedback * Fix conflict * Fix config * Creating a traefik setup for prod docker-compose * Make it work for dev set up * Updating .env ecample * better file names * Updated prod webpack and a shell script for prod setup --------- Co-authored-by: Luigi Marini <[email protected]> Co-authored-by: Chen Wang <[email protected]>
1 parent c5aa719 commit f982515

21 files changed

+637
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,4 @@ secrets.yaml
8282
# faker
8383
official.csv
8484
fact.png
85+
jupyterhub/.env-dev

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ There is a few other documentation links available on the [website](https://clow
3636
## Installation
3737

3838
The easiest way of running Clowder v2 is checking out the [code](https://github.com/clowder-framework/clowder2)
39-
and running `docker compose up` in the main directory.
39+
and running `docker compose up` in the main directory. If you would like to run Clowder with JupyterHub,
40+
you can use our script `docker-prod.sh` to start the services. Run `./docker-prod.sh prod up` to start the services
41+
and `./docker-prod.sh prod down` to stop them.
4042

4143
Helm charts are available for running Clowder v2 on Kubernetes. See the [helm](https://github.com/clowder-framework/clowder2/tree/main/deployments/kubernetes/charts) directory for more information.
4244

docker-compose.dev.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ services:
6767

6868
postgres:
6969
image: postgres
70+
networks:
71+
- clowder2
7072
volumes:
7173
- postgres_data:/var/lib/postgresql/data
7274
environment:
@@ -79,6 +81,8 @@ services:
7981
volumes:
8082
- ./scripts/keycloak/clowder-realm-dev.json:/opt/keycloak/data/import/realm.json:ro
8183
- ./scripts/keycloak/clowder-theme/:/opt/keycloak/themes/clowder-theme/:ro
84+
networks:
85+
- clowder2
8286
command:
8387
- start-dev
8488
- --http-relative-path /keycloak
@@ -172,6 +176,7 @@ services:
172176

173177
networks:
174178
clowder2:
179+
name: clowder2
175180

176181
## By default this config uses default local driver,
177182
## For custom volumes replace with volume driver configuration.

docker-compose.jupyter-dev.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: '3'
2+
services:
3+
jupyterhub:
4+
build:
5+
context: jupyterhub
6+
dockerfile: Dockerfile.jupyterhub
7+
args:
8+
JUPYTERHUB_VERSION: 4
9+
restart: always
10+
networks:
11+
- clowder2
12+
volumes:
13+
# The JupyterHub configuration file
14+
- ./jupyterhub/jupyterhub_dev_config.py:/srv/jupyterhub/jupyterhub_config.py:ro
15+
# Bind Docker socket on the hostso we can connect to the daemon from
16+
# within the container
17+
- /var/run/docker.sock:/var/run/docker.sock:rw
18+
# Bind Docker volume on host for JupyterHub database and cookie secrets
19+
- jupyterhub-data:/data
20+
ports:
21+
- "8765:8000"
22+
env_file:
23+
- jupyterhub/.env-dev
24+
command: jupyterhub -f /srv/jupyterhub/jupyterhub_config.py
25+
26+
depends_on:
27+
- keycloak
28+
29+
volumes:
30+
jupyterhub-data:

docker-compose.jupyter.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3'
2+
services:
3+
jupyterhub:
4+
build:
5+
context: jupyterhub
6+
dockerfile: Dockerfile.jupyterhub
7+
args:
8+
JUPYTERHUB_VERSION: 4
9+
restart: always
10+
networks:
11+
- clowder2
12+
volumes:
13+
# The JupyterHub configuration file
14+
- ./jupyterhub/jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py:ro
15+
# Bind Docker socket on the hostso we can connect to the daemon from
16+
# within the container
17+
- /var/run/docker.sock:/var/run/docker.sock:rw
18+
# Bind Docker volume on host for JupyterHub database and cookie secrets
19+
- jupyterhub_data:/data
20+
env_file:
21+
- jupyterhub/.env
22+
labels:
23+
- "traefik.enable=true"
24+
- "traefik.http.routers.jupyterhub.rule=PathPrefix(`/jupyterhub`)"
25+
- "traefik.http.services.jupyterhub.loadbalancer.server.port=8000"
26+
27+
command: jupyterhub -f /srv/jupyterhub/jupyterhub_config.py
28+
29+
depends_on:
30+
- keycloak
31+
32+
volumes:
33+
jupyterhub_data:

docker-dev.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ if [ "$1" = "down" ]
77
then
88
docker-compose -f docker-compose.dev.yml -p clowder2-dev down
99
fi
10+
if [ "$1" = "jupyter" ] && [ "$2" = "up" ]
11+
then
12+
docker-compose -f docker-compose.dev.yml -f docker-compose.jupyter-dev.yml -p clowder2-dev up -d --build
13+
fi
14+
15+
if [ "$1" = "jupyter" ] && [ "$2" = "down" ]
16+
then
17+
docker-compose -f docker-compose.dev.yml -f docker-compose.jupyter-dev.yml -p clowder2-dev down
18+
fi

docker-prod.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env sh
2+
if [ "$1" = "prod" ] && [ "$2" = "up" ]
3+
then
4+
docker-compose -f docker-compose.yml -f docker-compose.jupyter.yml up -d
5+
fi
6+
7+
if [ "$1" = "prod" ] && [ "$2" = "down" ]
8+
then
9+
docker-compose -f docker-compose.yml -f docker-compose.jupyter.yml down
10+
fi

docs/docs/devs/getstarted.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ section below).
4747
- Running `docker-compose logs -f` displays the live logs for all containers. To view the logs of individual containers,
4848
provide the container name. For example, for viewing the backend module logs, run `docker-compose logs -f backend`.
4949
- Running `./docker-dev.sh down` brings down the required services.
50+
- If you want to run the jupyterhub, you can run `./docker-dev.sh jupyter up`. The jupyterhub will be available at
51+
`http://localhost:8765`. You can bring it down using `./docker-dev.sh jupyter down`.
5052

5153
**Note:** `./docker-dev.sh` sets the project name flag to `-p clowder2-dev`. This is so that the dev containers
5254
don't get mixed with the production containers if the user is running both on the same machine using `docker-compose.yml`.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"start-message": "babel-node tools/startMessage.js",
1313
"prestart": "npm-run-all --parallel start-message",
1414
"start": "npm-run-all --parallel open:src",
15-
"start:dev": "export CLOWDER_REMOTE_HOSTNAME=http://localhost:8000 && npm run start",
15+
"start:dev": "export CLOWDER_REMOTE_HOSTNAME=http://localhost:8000 && export JUPYTERHUB_URL=http://localhost:8765 && npm run start",
1616
"open:src": "babel-node tools/srcServer.js",
1717
"open:dist": "babel-node tools/distServer.js",
1818
"lint:watch": "npm run lint --watch",

frontend/src/app.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface Config {
99
hostname: string;
1010
apikey: string;
1111
GHIssueBaseURL: string;
12+
jupyterHubURL: string;
1213
KeycloakBaseURL: string;
1314
KeycloakLogin: string;
1415
KeycloakLogout: string;
@@ -66,6 +67,10 @@ config["KeycloakRegister"] = `${config.KeycloakBaseURL}/register`;
6667
config["searchEndpoint"] = `${hostname}/api/v2/elasticsearch`;
6768
config["publicSearchEndpoint"] = `${hostname}/api/v2/public_elasticsearch`;
6869

70+
// jupterhub
71+
const localJupyterhubURL: string = `${config.hostname}/jupyterhub`;
72+
config["jupyterHubURL"] = process.env.JUPYTERHUB_URL || localJupyterhubURL;
73+
6974
// refresh token time interval
7075
config["refreshTokenInterval"] = 1000 * 60; // 1 minute
7176
// updated extractor logs

0 commit comments

Comments
 (0)