Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
make everware runnable as a container itself #195
Merged
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
63ed6c0
Dockerfile
BertrandNOEL 03ddcef
Config and env file to run on local or remote Docker
BertrandNOEL 8508be4
Config and env file to run on Docker Swarm
BertrandNOEL 48ea1bb
Documentation
BertrandNOEL d72a0c4
fix Dockerfile
anaderi 16583e7
updated configs and makefile to deploy everware as docker image
anaderi a6c5568
Merge branch 'master' into pr-docker
anaderi
Jump to file or symbol
Failed to load files and symbols.
12
Dockerfile
| @@ -0,0 +1,12 @@ | ||
| +FROM jupyterhub/jupyterhub:0.7.2 | ||
| +RUN apt-get update && apt-get install make | ||
| + | ||
| +COPY . /srv/everware | ||
| +WORKDIR /srv/everware/ | ||
| +RUN make install | ||
| + | ||
| +EXPOSE 8000 | ||
| +EXPOSE 8081 | ||
| + | ||
| +ENTRYPOINT ["/srv/everware/scripts/everware-server", "-f"] | ||
| + |
| @@ -0,0 +1,71 @@ | ||
| + | ||
| +# Run Everware in a Docker container | ||
| + | ||
| +This section explains how to run Everware in a container, and the different possibilities to run users container | ||
| + | ||
| +## Build Everware container | ||
| + | ||
| +[Dockerfile](Dockerfile) | ||
| + | ||
| +``` | ||
| + docker build -t everware . | ||
| +``` | ||
| + | ||
| +## Create user containers on same machine as the Everware one | ||
| + | ||
| +Fill the file which will contains environment variables for Everware. | ||
| +``` | ||
| + cp env.docker-local.orig env.docker-local | ||
| +``` | ||
| +Define the `GITHUB_CLIENT_ID`, `GITHUB_CLIENT_SECRET`, and `OAUTH_CALLBACK_URL` | ||
| + | ||
| +Edit `etc/container_config.py` file to set `c.DockerSpawner.hub_ip_connect` and `c.DockerSpawner.container_ip` to the IP of your machine running the Everware container. | ||
| + | ||
| +``` | ||
| + docker run -d --name everware \ | ||
| + -v /var/run/docker.sock:/var/run/docker.sock \ | ||
| + -v $PWD/etc/container_config.py:/srv/everware/etc/container_config.py \ | ||
| + --env-file=env.docker-local \ | ||
| + -p 8000:8000 \ | ||
| + -p 8081:8081 \ | ||
| + everware /srv/everware/etc/container_config.py --no-ssl --debug | ||
| +``` | ||
| + | ||
| +Note that you can skip `-v $PWD/etc/container_config.py:/srv/everware/etc/container_config.py` part if you build the container after having modified the config file `etc/container_config.py` | ||
| + | ||
| +## Create user containers on a remote Docker machine | ||
| + | ||
| +``` | ||
| + cp env.docker-remote.orig env.docker-remote | ||
| +``` | ||
| +Same as before, and define `DOCKER_HOST`, the IP of your remote Docker machine. | ||
| + | ||
| +``` | ||
| +docker run -d --name everware \ | ||
| + -v $PWD/etc/container_config.py:/srv/everware/etc/container_config.py \ | ||
| + --env-file=env.docker-remote \ | ||
| + -p 8000:8000 \ | ||
| + -p 8081:8081 \ | ||
| + everware /srv/everware/etc/container_config.py --no-ssl --debug | ||
| +``` | ||
| + | ||
| +## Create user containers on a Docker Swarm cluster | ||
| + | ||
| +This allows to create users container on a Docker Swarm cluster. | ||
| + | ||
| +``` | ||
| + cp env.docker-swarm.orig env.docker-swarm | ||
| +``` | ||
| +Define the variable, and set `DOCKER_HOST` to the IP of your Swarm master. | ||
| + | ||
| +Edit `etc/container_swarm.py` file to set `c.DockerSpawner.hub_ip_connect` to the IP of your machine hosting Everware container. | ||
| + | ||
| +``` | ||
| + docker run --rm -it --name everware \ | ||
| + -v $PWD/etc/container_swarm_config.py:/srv/everware/etc/container_swarm_config.py \ | ||
| + -v /home/ubuntu/docker:/etc/docker \ | ||
| + --env-file=env.docker-swarm \ | ||
| + -p 8000:8000 \ | ||
| + -p 8081:8081 \ | ||
| + everware /srv/everware/etc/container_swarm_config.py --no-ssl --debug | ||
| +``` |
| @@ -0,0 +1,4 @@ | ||
| +GITHUB_CLIENT_ID= | ||
| +GITHUB_CLIENT_SECRET= | ||
| +OAUTH_CALLBACK_URL=http://xxxxxxxx:8000/hub/oauth_callback | ||
| +EVERWARE_WHITELIST=whitelist.txt |
| @@ -0,0 +1,7 @@ | ||
| +GITHUB_CLIENT_ID= | ||
| +GITHUB_CLIENT_SECRET= | ||
| +OAUTH_CALLBACK_URL=http://xxxxxxxx:8000/hub/oauth_callback | ||
| +EVERWARE_WHITELIST=whitelist.txt | ||
| +DOCKER_HOST=tcp://xxx.xxx.xxx.xxx:2376 | ||
| +# most likely the same IP as DOCKER_HOST | ||
| +DOCKER_PUBLIC_IP=xxx.xxx.xxx.xxx |
| @@ -0,0 +1,9 @@ | ||
| +GITHUB_CLIENT_ID= | ||
| +GITHUB_CLIENT_SECRET= | ||
| +OAUTH_CALLBACK_URL=http://xxxxxxxx:8000/hub/oauth_callback | ||
| +EVERWARE_WHITELIST=whitelist.txt | ||
| +DOCKER_CERT_PATH=/etc/docker | ||
| +DOCKER_HOST=tcp://xxx.xxx.xxx.xxx:2376 | ||
| +DOCKER_TLS_VERIFY=1 | ||
| +# most likely the same IP as DOCKER_HOST | ||
| +DOCKER_PUBLIC_IP=xxx.xxx.xxx.xxx |
| @@ -0,0 +1,17 @@ | ||
| +# Use this config file to run everware in a container, | ||
| +# and create user containers in local or remote Docker service | ||
| +# | ||
| +# In case of local, don't forget to mount /var/run/docker.sock | ||
| +# In case of remote, don't forget the DOCKER_HOST environment variable | ||
| + | ||
| +c = get_config() | ||
| +load_subconfig('etc/base_config.py') | ||
| +load_subconfig('etc/github_auth.py') | ||
| + | ||
| +c.JupyterHub.hub_ip = '0.0.0.0' | ||
| +c.JupyterHub.proxy_api_ip = '0.0.0.0' | ||
| + | ||
| +# IP of the machine where the Everware (run as docker container) can be contacted | ||
| +c.DockerSpawner.hub_ip_connect = os.environ['DOCKER_PUBLIC_IP'] | ||
| +# IP of the machine running Docker service, normally the same as above | ||
| +c.DockerSpawner.container_ip = c.DockerSpawner.hub_ip_connect |
| @@ -0,0 +1,21 @@ | ||
| +# Use this config file to run everware in a container, | ||
| +# and create the user container on a Docker Swarm cluster | ||
| +# | ||
| +# No need to mount /var/run/docker.sock, | ||
| +# but don't forget to set Docker Swarm environment | ||
| +# variables in the env file | ||
| + | ||
| +c = get_config() | ||
| +load_subconfig('etc/base_config.py') | ||
| +load_subconfig('etc/github_auth.py') | ||
| + | ||
| +c.JupyterHub.hub_ip = '0.0.0.0' | ||
| +c.JupyterHub.proxy_api_ip = '0.0.0.0' | ||
| + | ||
| +c.JupyterHub.spawner_class = 'everware.CustomSwarmSpawner' | ||
| +c.Spawner.tls = True | ||
| +c.DockerSpawner.tls = True | ||
| + | ||
| +# Change this setting: | ||
| +# IP of the machine where the Everware can be contacted | ||
| +c.DockerSpawner.hub_ip_connect = os.environ['DOCKER_PUBLIC_IP'] |
67
run.makefile
| @@ -0,0 +1,67 @@ | ||
| +HERE=$(shell pwd) | ||
| +LOG := everware.log | ||
| +PIDFILE := everware.pid | ||
| +EXECUTOR = everware-server | ||
| + | ||
| +reload: ## reload everware whitelist | ||
| + PID=`pgrep '${EXECUTOR}'` ;\ | ||
| + if [ -z "$${PID}" ] ; then echo "Cannot find running ${EXECUTOR}" ; exit 1 ; fi | ||
| + pkill -1 '${EXECUTOR}' | ||
| + | ||
| +clean: ## clean user base | ||
| + if [ -f ${PIDFILE} ] ; then echo "${PIDFILE} exists, cannot continute" ; exit 1; fi | ||
| + rm -f jupyterhub.sqlite | ||
| + | ||
| +run-linux: clean ## run everware server on linux | ||
| + source ./env.sh && \ | ||
| + ${EXECUTOR} -f etc/local_config.py --no-ssl 2>&1 | tee ${LOG} | ||
| + | ||
| +run-dockermachine: clean ## run everware server on MacOS | ||
| + source ./env.sh && \ | ||
| + ${EXECUTOR} -f etc/local_dockermachine_config.py --no-ssl 2>&1 | tee ${LOG} | ||
| + | ||
| +run-daemon: clean ## run everware in daemon mode, linux only, SSL required | ||
| + source ./env.sh && \ | ||
| + ${EXECUTOR} -f etc/local_config.py >> ${LOG} 2>&1 & | ||
| + pgrep ${EXECUTOR} > ${PIDFILE} || ( tail ${LOG} && exit 1 ) | ||
| + echo "Started. Log saved to ${LOG}" | ||
| + | ||
| +stop: | ||
| + -rm ${PIDFILE} | ||
| + -pkill -9 ${EXECUTOR} | ||
| + -pkill -9 node | ||
| +run-docker-local: | ||
| + docker run -d --name everware \ | ||
| + -v /var/run/docker.sock:/var/run/docker.sock \ | ||
| + -v ${HERE}/etc/container_config.py:/srv/everware/etc/container_config.py \ | ||
| + --env-file=env.docker-local \ | ||
| + -p 8000:8000 \ | ||
| + -p 8081:8081 \ | ||
| + everware/everware:latest /srv/everware/etc/container_config.py --no-ssl --debug | ||
| + | ||
| +run-docker-remote: | ||
| + docker run -d --name everware \ | ||
| + -v ${HERE}/etc/container_config.py:/srv/everware/etc/container_config.py \ | ||
| + --env-file=env.docker-remote \ | ||
| + -p 8000:8000 \ | ||
| + -p 8081:8081 \ | ||
| + everware/everware:latest /srv/everware/etc/container_config.py --no-ssl --debug | ||
| + | ||
| +run-docker-swarm: | ||
| + docker run -d --name everware \ | ||
| + -v ${HERE}/etc/container_swarm_config.py:/srv/everware/etc/container_swarm_config.py \ | ||
| + --env-file=env.docker-swarm \ | ||
| + -p 8000:8000 \ | ||
| + -p 8081:8081 \ | ||
| + everware/everware:latest /srv/everware/etc/container_swarm_config.py --no-ssl --debug | ||
| + | ||
| +stop-docker: | ||
| + docker stop everware | ||
| + docker rm everware | ||
| + | ||
| +stop-docker-swarm: | ||
| + bash -c "source env.docker-swarm && docker stop everware && docker rm everware" | ||
| + | ||
| +logs: ${LOG} ## watch log file | ||
| + tail -f ${LOG} | ||
| + |