Skip to content

Commit

Permalink
Adding docker resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Erick Verleye committed Apr 5, 2024
1 parent d206ff9 commit f58b234
Show file tree
Hide file tree
Showing 19 changed files with 507 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build-and-push-jupyterlab-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: build-and-push-jupyterlab-image

on:
workflow_dispatch: # This allows you to manually trigger the action from GitHub UI.

jobs:

build:
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/[email protected]

- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]

- name: Login to dockerhub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Get lowercase repo name (for dynamic tags)
id: repo_name
run: |
lowercase_name=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')
echo "::set-output name=repo_name::${lowercase_name}"
- name: Build and push latest
id: docker_build_jupyterlab
uses: docker/[email protected]
with:
context: docker/jupyterlab
file: docker/jupyterlab/Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: |
esiil/${{ steps.repo_name.outputs.repo_name }}_jupyterlab:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
136 changes: 136 additions & 0 deletions docker/jupyterlab/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
FROM jupyter/r-notebook:hub-4.0.1

USER root

# Set up package manager
RUN apt-get install -y apt-transport-https && \
apt-get clean && apt-get update && apt-get install -y software-properties-common && \
add-apt-repository multiverse && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Install some base software
RUN apt-get update --yes && \
apt-get install --yes \
fonts-dejavu \
unixodbc \
unixodbc-dev \
r-base \
r-cran-rodbc && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Add sudo to jovyan user
RUN apt update && \
apt install -y sudo && \
apt clean && \
rm -rf /var/lib/apt/lists/*

# This is where we can control which root permissions the jovyan user will have
ARG PRIV_CMDS='/bin/ch*,/bin/cat,/bin/gunzip,/bin/tar,/bin/mkdir,/bin/ps,/bin/mv,/bin/cp,/usr/bin/apt*,/usr/bin/pip*,/bin/yum,/opt,/opt/conda/bin/*,/usr/bin/*'

RUN usermod -aG sudo jovyan && \
echo "$LOCAL_USER ALL=NOPASSWD: $PRIV_CMDS" >> /etc/sudoers
RUN addgroup jovyan
RUN usermod -aG jovyan jovyan

# Install RStudio
RUN apt-get update && apt-get install --yes gdebi-core && \
wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.09.1-494-amd64.deb && \
gdebi -n rstudio-server-2023.09.1-494-amd64.deb && \
rm rstudio-server-2023.09.1-494-amd64.deb && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Geospatial libraries
RUN apt-get update && \
apt install -y \
gdal-bin \
lbzip2 \
libfftw3-dev \
libgdal-dev \
libgeos-dev \
libgsl0-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
libhdf4-alt-dev \
libhdf5-dev \
libjq-dev \
libpq-dev \
libproj-dev \
libprotobuf-dev \
libnetcdf-dev \
libsqlite3-dev \
libudunits2-dev \
lsb-release \
netcdf-bin \
postgis \
protobuf-compiler \
sqlite3 \
tk-dev \
libfmt-dev \
unixodbc-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/*

# Fix RStudio / Conda openssl version mismatch
RUN wget https://www.openssl.org/source/openssl-3.2.0.tar.gz && \
tar xfz openssl-3.2.0.tar.gz && \
mkdir openssl-build && cd openssl-build && \
../openssl-3.2.0/Configure --libdir=/lib/x86_64-linux-gnu/ && \
make && \
make install

# Update permissions for /opt/conda
RUN mkdir /usr/local/bin/start-notebook.d && \
chown -R jovyan:users /opt/conda/share /usr/local/share /usr/local/bin/start-notebook.d

USER jovyan

# Install jupyterlab and rstudio dependencies
RUN conda install -c conda-forge \
jupyter_client \
jupyter_core \
jupyterlab_server \
jupyter_server \
r-rgl \
r-htmlwidgets \
r-htmltools && \
jupyter lab clean

# reinstall R packages. Here is where you add any new R packages you would like to install
RUN mamba install --quiet --yes \
r-base \
r-tidyverse \
r-terra \
r-future \
r-future.apply \
r-furrr \
&& \
mamba clean --all -f -y

# Install Jupyter Lab Proxy extensions (cards in Launcher)
RUN pip install jupyter-rsession-proxy jupyter-server-proxy jupyter-shiny-proxy jupyterlab-git

# Install Mamba Gator package manager
RUN rm -f ~/.jupyter/lab/workspaces/default* && \
mamba install -y -c conda-forge mamba_gator

# Install and configure jupyter lab
COPY jupyter_notebook_config.json /opt/conda/etc/jupyter/jupyter_notebook_config.json

# Rebuild the Jupyter Lab with new tools
RUN jupyter lab build

# Build Conda environment. Any packages you would like to install with conda need to be added to the environment.yml file in this Dockerfiles directory
RUN conda update -y conda && \
conda config --remove channels conda-forge && \
conda config --add channels conda-forge
WORKDIR /home/jovyan
COPY environment.yml /home/jovyan/
RUN mamba env create -f /home/jovyan/environment.yml
RUN . /opt/conda/etc/profile.d/conda.sh && conda deactivate && conda activate custom && python -m ipykernel install --name custom && pip install jupyter_contrib_nbextensions

# Install R packages from CRAN and GitHub
RUN R -e "remotes::install_github('tomroh/ecoregions')"
RUN R -e "install.packages('mblm', repos='http://cran.rstudio.com/')"

# Set any required environment variables
ENV PROJ_LIB=/opt/conda/envs/custom/share/proj
RUN echo "PROJ_LIB=/opt/conda/envs/custom/share/proj" > /home/jovyan/.Renviron
40 changes: 40 additions & 0 deletions docker/jupyterlab/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: custom
channels:
- conda-forge
- defaults

dependencies:
- python=3.10

- pip:
- affine==2.4.0
- aiosignal==1.3.1
- appdirs==1.4.4
- attrs==23.1.0
- certifi==2023.7.22
- charset-normalizer==3.1.0
- click==8.1.3
- click-plugins==1.1.1
- cligj==0.7.2

# Core scientific python
- numpy
- matplotlib
- rioxarray
- geopandas
- gdal

# Jupyter Lab Environment & Kernel
- papermill
- autopep8
- jupyterlab
- notebook
- ipython
- nbclean
- nbresuse
- jupyterlab-geojson
- nb_conda_kernels
- ipykernel

# openssh because openssl bin path is in conda now for Rstudio issue
- openssh
11 changes: 11 additions & 0 deletions docker/jupyterlab/jupyter_notebook_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"NotebookApp": {
"allow_origin" : "*",
"token":"",
"password":"",
"nbserver_extensions": {
"jupyterlab": true,
"mamba_gator": true
}
}
}
Binary file added docs/assets/docker_basics/actions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/add_tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/app_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/container_port.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/create_app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/dockerhub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/image_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/manage_tools.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/restrictions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/run_workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/save_and_launch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/tool_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/tool_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/docker_basics/workflows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f58b234

Please sign in to comment.