Skip to content

Commit

Permalink
Update docs about GraalVM compiler switches and tidy up docker relate…
Browse files Browse the repository at this point in the history
…d scripts: create docker user and enable running Jupyter inside the container and be able to create notebooks.
  • Loading branch information
neomatrix369 committed Sep 10, 2019
1 parent 4d5a183 commit 863e4bf
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/JuPyteR/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
jupyter/
notebooks/
vulnerabilities/
dockerfileScan/
13 changes: 8 additions & 5 deletions examples/JuPyteR/Docker-container-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,25 @@ which runs the container and the [runLocal.sh](runLocal.sh) is executed inside t

#### Scripts provided:

All the scripts will be found on the `build-docker-image` folder:

- [buildDockerImage.sh](buildDockerImage.sh): build the docker image using Dockerfile
- [Dockerfile](Dockerfile): a dockerfile script to help build a docker image of Jupyter with the IJava kernel running on Java 9 (with Graal enabled)
- [install-jupyter-notebooks.sh](install-jupyter-notebooks.sh): installs Jupyter notebook and its dependencies
- [install-java-kernel.sh](install-java-kernel.sh): executed during building of the Docker container
- [removeUnusedContainersAndImages.sh](removeUnusedContainersAndImages.sh) - clean up after a build, removes dangling images and closed/exited containers
- [runDockerContainer.sh](runDockerContainer.sh): run the Jupyter docker image, exposing port 8888 to point your browser to (http://localhost:8888)
- [runLocal.sh](runLocal.sh): runs inside the docker container but can be also run on any local environment with the necessary dependencies installed
- [push-jupyter-java-docker-image-to-hub.sh](push-jupyter-java-docker-image-to-hub.sh): push the built docker image to Docker Hub. `DOCKER_USER_NAME` must be set in the environment or passed in on CLI, otherwise a default user name is assumed.
- [push-jupyter-java-docker-image-to-hub.sh](push-jupyter-java-docker-image-to-hub.sh): push the built docker image to Docker Hub. `DOCKER_USER_NAME` must be set in the environment or passed in on CLI, otherwise a default user name is assumed

Note: the GraalVM compiler can be enabled starting Java 9 and this currently only works for Linux. But later versions support Linux, MacOS and Windows.
Note: the GraalVM compiler can be enabled starting Java 9 and this currently only works for Linux. But later versions support Linux, MacOS and Windows. See [Switches to enable the GraalVM compiler in Java 9](./README.md#switches-to-enable-the-graalvm-compiler-in-java-9) in [README.md](README.md).

### Debug your running container

Set the environment variable `DEBUG` to `true` and it should do the job:

```
$ cd build-docker-image
$ [stay or switch into the project root folder]
```

```
Expand All @@ -87,7 +90,7 @@ You will be provided with the below `bash` prompt:
* Running in Debug mode *
*************************
root@a659f75885b0:/jupyter-notebooks#
root@a659f75885b0:/home/jupyter#
```

The `jupyter-notebook` instance will need to be started manually.
The `/home/jupyter` instance will need to be started manually.
16 changes: 16 additions & 0 deletions examples/JuPyteR/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ GraalVM compiler can be enabled for JDK 9 and higher, for platforms where it is
|Java 10 | Linux and MacOS |
|Java 11 or higher| Linux, MacOS, Windows |

#### Switches to enable the GraalVM compiler in Java 9

```
export JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler"
export JAVA_TOOL_OPTIONS="${JAVA_TOOL_OPTIONS} ${JAVA_OPTS}"
```

or

```
export ENABLE_GRAALVM_COMPILER="-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler"
java [-cp] [...] [-jar] [...] \
${ENABLE_GRAALVM_COMPILER}
```

### Additional source of kernels
- [beakerx](http://beakerx.com/) - Is another source where a wider range of kernels can be found (covering many JVM languages).

Expand Down
14 changes: 12 additions & 2 deletions examples/JuPyteR/build-docker-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ EXPOSE 8888

RUN rm -f *.sh *.zip install.py

COPY runLocal.sh runLocal.sh
ARG USER
RUN groupadd -r ${USER} \
&& useradd -r -s /bin/false \
-g ${USER} ${USER}

ARG WORKDIR
WORKDIR ${WORKDIR}

ENTRYPOINT ["./../runLocal.sh"]
COPY runLocal.sh runLocal.sh
RUN mv -f /root/.local ${WORKDIR}

RUN chown -R ${USER}:${USER} ${WORKDIR}

USER ${USER}

ENTRYPOINT ["./runLocal.sh"]
5 changes: 4 additions & 1 deletion examples/JuPyteR/build-docker-image/buildDockerImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ if [[ -z ${DOCKER_USER_NAME:-""} ]]; then
fi

DOCKER_FULL_TAG_NAME="${DOCKER_USER_NAME}/${IMAGE_NAME}"
USER=jupyter
JUPYTER_HOME=/home/${USER}

time docker build \
--build-arg WORKDIR=/jupyter-notebooks \
--build-arg USER=jupyter \
--build-arg WORKDIR=${JUPYTER_HOME} \
-t ${DOCKER_FULL_TAG_NAME}:${IMAGE_VERSION} \
.

Expand Down
4 changes: 2 additions & 2 deletions examples/JuPyteR/runDockerContainer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if [[ "${DEBUG}" == "true" ]]; then
echo "*************************"
fi

[ ! ${PWD}/jupyter/notebooks ] && mkdir -p ${PWD}/jupyter/notebooks
[ ! ${PWD}/notebooks ] && mkdir -p ${PWD}/notebooks

IMAGE_NAME=${IMAGE_NAME:-jupyter-java}
IMAGE_VERSION=${IMAGE_VERSION:-$(cat version.txt)}
Expand All @@ -30,6 +30,6 @@ DOCKER_FULL_TAG_NAME="${DOCKER_USER_NAME}/${IMAGE_NAME}"

docker run --rm \
${DOCKER_DEBUG_PARAMS} \
--volume ${PWD}/jupyter/notebooks:/jupyter-notebooks \
--volume ${PWD}/notebooks:/home/jupyter/notebooks \
-p 8888:8888 \
${DOCKER_FULL_TAG_NAME}:${IMAGE_VERSION}

0 comments on commit 863e4bf

Please sign in to comment.