From 8f7133baedf569f3eb59091c55fc8b07ae5538de Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <maltanar@gmail.com> Date: Thu, 6 Feb 2020 13:53:56 +0100 Subject: [PATCH] [Docker] use JUPYTER_PORT to specify the Jupyter notebook port --- Dockerfile | 3 ++- run-docker.sh | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index ccc0a8ea8..2769ab91f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,7 @@ ARG GNAME ARG UNAME ARG UID ARG PASSWD +ARG JUPYTER_PORT RUN groupadd -g $GID $GNAME RUN useradd -M -u $UID $UNAME -g $GNAME @@ -43,5 +44,5 @@ USER $UNAME RUN echo "source \$VIVADO_PATH/settings64.sh" >> /home/$UNAME/.bashrc RUN echo "PS1='\[\033[1;36m\]\u\[\033[1;31m\]@\[\033[1;32m\]\h:\[\033[1;35m\]\w\[\033[1;31m\]\$\[\033[0m\] '" >> /home/$UNAME/.bashrc - +EXPOSE $JUPYTER_PORT WORKDIR /home/$UNAME/finn diff --git a/run-docker.sh b/run-docker.sh index d13e9f562..7b187bb24 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -11,7 +11,7 @@ DOCKER_UNAME=$(id -un) DOCKER_UID=$(id -u) DOCKER_PASSWD="finn" DOCKER_TAG="finn_$DOCKER_UNAME" -: ${DOCKER_PORT_FORWARD="-p 8888:8888 -p 8081:8081"} +: ${JUPYTER_PORT=8888} # Absolute path to this script, e.g. /home/user/bin/foo.sh SCRIPT=$(readlink -f "$0") @@ -54,14 +54,14 @@ echo "Mounting $SCRIPTPATH/pyverilator into /workspace/pyverilator" echo "Mounting $SCRIPTPATH/PYNQ-HelloWorld into /workspace/PYNQ-HelloWorld" echo "Mounting $BUILD_LOCAL into $BUILD_LOCAL" echo "Mounting $VIVADO_PATH into $VIVADO_PATH" -echo "Port-forwarding with $DOCKER_PORT_FORWARD" +echo "Port-forwarding for Jupyter $JUPYTER_PORT:$JUPYTER_PORT" if [ "$1" = "test" ]; then echo "Running test suite" DOCKER_CMD="python setup.py test" elif [ "$1" = "notebook" ]; then echo "Running Jupyter notebook server" - DOCKER_CMD="source ~/.bashrc; jupyter notebook --ip=0.0.0.0 notebooks" + DOCKER_CMD="source ~/.bashrc; jupyter notebook --ip=0.0.0.0 --port $JUPYTER_PORT notebooks" else echo "Running container only" DOCKER_CMD="bash" @@ -74,6 +74,7 @@ docker build --tag=$DOCKER_TAG \ --build-arg UNAME=$DOCKER_UNAME \ --build-arg UID=$DOCKER_UID \ --build-arg PASSWD=$DOCKER_PASSWD \ + --build-arg JUPYTER_PORT=$JUPYTER_PORT \ . # Launch container with current directory mounted docker run -t --rm --name finn_dev_$DOCKER_UNAME -it \ @@ -89,5 +90,5 @@ docker run -t --rm --name finn_dev_$DOCKER_UNAME -it \ -v $BUILD_LOCAL:$BUILD_LOCAL \ -v $VIVADO_PATH:$VIVADO_PATH \ -e VIVADO_PATH=$VIVADO_PATH \ -$DOCKER_PORT_FORWARD \ +-p $JUPYTER_PORT:$JUPYTER_PORT \ $DOCKER_TAG bash -c "$DOCKER_CMD" -- GitLab