From f77b3bb297c38c2734d1de8af91b3ca9280a1a2b Mon Sep 17 00:00:00 2001 From: Dan Rapp Date: Wed, 1 Aug 2018 15:48:07 -0600 Subject: [PATCH] Support capabilities added to rappdw/docker-ds for better vcs integration. --- README.md | 7 ++++++- scripts/run-notebook | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 887837a..21c632f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,12 @@ the docker file to the defined repository (AWS or Docker) `run-notebook` will start a docker container using either the notebook container found in the `docker/notebook` directory if it exists, or [rappdw/docker-ds](https://github.com/rappdw/docker-ds) otherwise. The current directory will be mounted -into the container for use in the Juypter notebook environment. +into the container for use in the Juypter notebook environment. There are a couple of environment variable to be aware of +with this command: + +* DOCKER_DS_DONT_PULL - if set, the version of rappdw/docker-ds currently available will be used rather than pulling +the latest version from docker hub. +* DOCKER_DS_DIFFS - if set, ## `dockerutils.cfg` Format Configuration in `docker/dockerutils.cfg` is used to configure behavior of the `dockerutils` scripts. diff --git a/scripts/run-notebook b/scripts/run-notebook index ff16412..235c161 100755 --- a/scripts/run-notebook +++ b/scripts/run-notebook @@ -1,22 +1,47 @@ #!/usr/bin/env bash +DOCKER_DS_DONT_PULL=${DOCKER_DS_DONT_PULL:-pull} +DOCKER_DS_DIFFS=${DOCKER_DS_DIFFS:-no_diffs} + +DOCKER_ENV="" + +if [ "$DOCKER_DS_DIFFS" != "no_diffs" ]; then + DOCKER_ENV="-e DOCKER_DS_DIFFS=1" +fi + if [ -d "./docker/notebook" ]; then build-image -f notebook run-image notebook else # Script to run rappdw/docker-ds notebok against the current directory - docker pull rappdw/docker-ds:latest + if [ "$DOCKER_DS_DONT_PULL" = "pull" ]; then + docker pull rappdw/docker-ds:latest + fi + date_stamp=$(date "+%Y_%m_%d_%H.%M.%S") if [ -z "$DOCKER_HOST" ] then if [[ ! -d "./.ipynb_checkponts" ]]; then mkdir ./.ipynb_checkpoints fi - echo 'docker run --init --name '$USER'_notebook_'$date_stamp' -e NOTEBOOK_MODE=lab --rm -it --mount type=bind,source=$(pwd),target=/home/jovyan/project -v /data:/data --mount type=bind,source=$HOME/.aws,target=/home/jovyan/.aws -p 8888:8888 rappdw/docker-ds:latest' - docker run --init --name $USER"_notebook_"$date_stamp -e NOTEBOOK_MODE=lab --rm -it --mount type=bind,source=$(pwd),target=/home/jovyan/project -v /data:/data --mount type=bind,source=$HOME/.aws,target=/home/jovyan/.aws -p 8888:8888 rappdw/docker-ds:latest + if [[ -d "/data" ]]; then + if [[ -d "$HOME/.aws" ]]; then + volume_mounts="--mount type=bind,source=$(pwd),target=/home/jovyan/project -v /data:/data --mount type=bind,source=$HOME/.aws,target=/home/jovyan/.aws" + else + volume_mounts="--mount type=bind,source=$(pwd),target=/home/jovyan/project -v /data:/data" + fi + else + if [[ -d "$HOME/.aws" ]]; then + volume_mounts="--mount type=bind,source=$(pwd),target=/home/jovyan/project --mount type=bind,source=$HOME/.aws,target=/home/jovyan/.aws" + else + volume_mounts="--mount type=bind,source=$(pwd),target=/home/jovyan/project" + fi + fi + echo 'docker run --init --name '$USER'_notebook_'$date_stamp' '$DOCKER_ENV' -e NOTEBOOK_MODE=lab --rm -it '$volume_mounts' -p 8888:8888 rappdw/docker-ds:latest' + docker run --init --name $USER"_notebook_"$date_stamp $DOCKER_ENV -e NOTEBOOK_MODE=lab --rm -it $volume_mounts -p 8888:8888 rappdw/docker-ds:latest else - echo 'docker run --init --name '$USER'_notebook_'$date_stamp' -e NOTEBOOK_MODE=lab --rm -it --mount type=bind,source=/data/workspaces/'$USER'/code/'${PWD##*/}',target=/home/jovyan/project -v /data:/data -p 8888:8888 rappdw/docker-ds:latest' - docker run --init --name $USER"_notebook_"$date_stamp -e NOTEBOOK_MODE=lab --rm -it --mount type=bind,source="/data/workspaces/"$USER"/code/"${PWD##*/}",target=/home/jovyan/project" -v /data:/data -p 8888:8888 rappdw/docker-ds:latest + echo 'docker run --init --name '$USER'_notebook_'$date_stamp' '$DOCKER_ENV' -e NOTEBOOK_MODE=lab --rm -it --mount type=bind,source=/data/workspaces/'$USER'/code/'${PWD##*/}',target=/home/jovyan/project -v /data:/data -p 8888:8888 rappdw/docker-ds:latest' + docker run --init --name $USER"_notebook_"$date_stamp $DOCKER_ENV -e NOTEBOOK_MODE=lab --rm -it --mount type=bind,source="/data/workspaces/"$USER"/code/"${PWD##*/}",target=/home/jovyan/project" -v /data:/data -p 8888:8888 rappdw/docker-ds:latest fi fi \ No newline at end of file