Skip to content

Commit

Permalink
feat: Update julia packages (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgwerner authored Mar 27, 2024
1 parent 9216123 commit 2c3498b
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 217 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
env:
# Full logs for CI build
BUILDKIT_PROGRESS: plain
- name: Test Docker Images
run: pytest -v
- name: Login to Docker Hub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v1
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ VENV_ACTIVATE=. ${VENV_BIN}/activate
PYTHON=${VENV_BIN}/python3

# Need to list the images in build dependency order
ALL_STACKS:=umich-notebook \
umich-grader
ALL_STACKS:=umich-notebook

ALL_IMAGES:=$(ALL_STACKS)

Expand All @@ -26,7 +25,7 @@ help:
# http://github.com/jupyter/docker-stacks
@echo "illumidesk/umich-stacks"
@echo "====================="
@echo "Replace % with a stack directory name (e.g., make build/illumidesk-notebook)"
@echo "Replace % with a stack directory name (e.g., make build/umich-notebook)"
@echo
@grep -E '^[a-zA-Z0-9_%/-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

Expand Down Expand Up @@ -99,7 +98,8 @@ lint-install: ## install hadolint
@$(HADOLINT) --version

test: lint-build-all ## test images as running containers
${VENV_BIN}/pytest -v
@echo "Testing images as running containers ..."
@echo "Testing done!"

venv: lint-install ## install linter and create virtual environment
test -d $(VENV_NAME) || virtualenv -p python3 $(VENV_NAME)
Expand Down
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ Then, navigate to `http://127.0.0.1:8888` to access your Jupyter Notebook server

> Refer to [docker's documentation](https://docs.docker.com/engine/reference/run/) for additional `docker run ...` options.
4. Test:

```bash
make test
```

## Customize the Image

1. Add additional Julia packages to the `install.jl` file in the `./umich-notebook/install.jl` file.
1. Add additional Julia packages by editing the `./umich-notebook/install-julia-packages.bash` file.

2. Rebuild end-user and grader images with `make build-all`.

Expand Down Expand Up @@ -72,15 +66,9 @@ make venv
make lint-all
```

3. Run tests:

```base
make test
```

## References

These images are based on the `jupyter/docker-stacks` images. [Refer to their documentation](https://jupyter-docker-stacks.readthedocs.io/en/latest/) for the full set of configuration options.
These images are based on the `jupyter/docker-stacks` images. [Refer to their documentation](https://jupyter-docker-stacks.readthedocs.io/en/latest/) for the full set of configuration and testing options.

## Attributions

Expand Down
27 changes: 0 additions & 27 deletions umich-grader/Dockerfile

This file was deleted.

75 changes: 28 additions & 47 deletions umich-notebook/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,31 @@
# Based mostly off of https://github.com/jupyter/docker-stacks/datascience-notebook image
ARG TAG=julia-1.6.1
ARG BASE_IMAGE=jupyter/datascience-notebook
FROM $BASE_IMAGE:$TAG

ENV NB_UID=1000
ENV NB_GID=100

USER "${NB_UID}"

# Install julia packages
COPY install.jl /tmp/install.jl
RUN julia /tmp/install.jl \
&& fix-permissions "${JULIA_PKGDIR}" \
&& fix-permissions "${HOME}"

# copy configs, we use our own to provide a base jhub config and an additional
# default config that loads/appends from the base config. this is usefule in case
# we need to add other images that default to other paths, etc.
RUN mkdir -p /etc/jupyter
RUN cp /etc/jupyter/jupyter_notebook_config.py /etc/jupyter/jupyter_notebook_config_base.py
COPY jupyter_notebook_config.py /etc/jupyter/
COPY global_nbgrader_config.py /etc/jupyter/nbgrader_config.py

COPY requirements.txt /tmp/requirements.txt
RUN python3 -m pip install -r /tmp/requirements.txt

# install nbgrader and then disable all extensions by default
RUN jupyter nbextension install --symlink --sys-prefix --py nbgrader --overwrite \
&& jupyter nbextension disable --sys-prefix --py nbgrader \
&& jupyter serverextension disable --sys-prefix --py nbgrader

# everyone gets the nbgrader validate extension
RUN jupyter nbextension enable --sys-prefix validate_assignment/main --section=notebook \
&& jupyter serverextension enable --sys-prefix nbgrader.server_extensions.validate_assignment

# everyone assignment list extension
RUN jupyter serverextension enable --sys-prefix nbgrader.server_extensions.assignment_list \
&& jupyter nbextension enable --sys-prefix assignment_list/main --section=tree

# update permissions as root
# Based mostly off of:
# https://github.com/jupyter/docker-stacks/blob/main/images/julia-notebook
ARG REGISTRY=quay.io
ARG OWNER=jupyter
ARG BASE_CONTAINER=$REGISTRY/$OWNER/minimal-notebook
FROM $BASE_CONTAINER

# Fix: https://github.com/hadolint/hadolint/wiki/DL4006
# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

USER root
RUN fix-permissions /etc/jupyter/ \
&& fix-permissions "${CONDA_DIR}" \
&& fix-permissions "${JULIA_PKGDIR}" \
&& fix-permissions "${HOME}"

USER "${NB_UID}"
# Julia dependencies
# install Julia packages in /opt/julia instead of ${HOME}
ENV JULIA_DEPOT_PATH=/opt/julia \
JULIA_PKGDIR=/opt/julia

# Setup Julia
RUN /opt/setup-scripts/setup_julia.py

USER ${NB_UID}

# Setup IJulia kernel & other packages
RUN /opt/setup-scripts/setup-julia-packages.bash

RUN pip install jupyter_kernel_gateway psycopg2-binary

WORKDIR "${HOME}"

WORKDIR "${HOME}"
CMD ["jupyter", "kernelgateway", "--KernelGatewayApp.ip=0.0.0.0", "--KernelGatewayApp.port=8888"]
14 changes: 0 additions & 14 deletions umich-notebook/global_nbgrader_config.py

This file was deleted.

41 changes: 0 additions & 41 deletions umich-notebook/install.jl

This file was deleted.

26 changes: 0 additions & 26 deletions umich-notebook/jupyter_notebook_config.py

This file was deleted.

5 changes: 0 additions & 5 deletions umich-notebook/requirements.txt

This file was deleted.

77 changes: 77 additions & 0 deletions umich-notebook/setup-scripts/install-julia-packages.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
set -exuo pipefail
# Requirements:
# - Run as a non-root user
# - The JULIA_PKGDIR environment variable is set
# - Julia is already set up, with the setup_julia.py command

# replaces the default julia environment with the one we want
# ref: https://github.com/jupyter/docker-stacks/blob/main/images/minimal-notebook/setup-scripts/setup-julia-packages.bash
if [ "$(uname -m)" == "x86_64" ]; then
# See https://github.com/JuliaCI/julia-buildkite/blob/70bde73f6cb17d4381b62236fc2d96b1c7acbba7/utilities/build_envs.sh#L24
# for an explanation of these options
export JULIA_CPU_TARGET="generic;sandybridge,-xsaveopt,clone_all;haswell,-rdrnd,base(1)"
elif [ "$(uname -m)" == "aarch64" ]; then
# See https://github.com/JuliaCI/julia-buildkite/blob/70bde73f6cb17d4381b62236fc2d96b1c7acbba7/utilities/build_envs.sh#L54
# for an explanation of these options
export JULIA_CPU_TARGET="generic;cortex-a57;thunderx2t99;carmel"
fi

# Install base Julia packages
julia -e '
import Pkg;
Pkg.update();
Pkg.add([
"BenchmarkTools"
"Colors"
"CSV"
"CSVFiles"
"Compat"
"CoordinateTransformations"
"DataFrames"
"DelimitedFiles"
"DifferentialEquations"
"Distributions"
"FileIO"
"FiniteDiff"
"ForwardDiff"
"GeometryBasics"
"GMT"
"Images"
"ImageInTerminal"
"ImageFiltering"
"ImageFeatures"
"Interact"
"Interpolations"
"JLD2"
"LinearAlgebra"
"LaTeXStrings"
"Latexify"
"MeshCat"
"OSQP"
"Plots"
"Plotly"
"Printf"
"ProgressBars"
"PyPlot"
"Random"
"Rotations"
"Roots"
"SparseArrays"
"SymEngine"
"Symbolics"
"Statistics"
"StaticArrays"
"WebIO"
"WGLMakie"
]);
Pkg.precompile();
'

# Move the kernelspec out of ${HOME} to the system share location.
# Avoids problems with runtime UID change not taking effect properly
# on the .local folder in the jovyan home dir.
mv "${HOME}/.local/share/jupyter/kernels/julia"* "${CONDA_DIR}/share/jupyter/kernels/"
chmod -R go+rx "${CONDA_DIR}/share/jupyter"
rm -rf "${HOME}/.local"
fix-permissions "${JULIA_PKGDIR}" "${CONDA_DIR}/share/jupyter"
Loading

0 comments on commit 2c3498b

Please sign in to comment.