Dockerfile sample for RStudio images

Adapt the customizations in the following sample Dockerfile to fit your needs and remove those that you don't need.

ARG  base_image_tag
FROM ${base_image_tag}

# Operating system packages must be installed as root.
USER root:root
# If you don't need to install additional operating system packages from the
# default repositories, remove the "microdnf install" command and package list,
# but keep the rest of this RUN statement. This will install security updates.
# The chown and chmod commands are needed when system certificates get updated.
RUN microdnf update \
 && microdnf install --nodocs \
     poppler-utils \
 && microdnf clean all \
 && rm -rf /var/cache/yum \
 && chown -cR :wsbuild \
             /etc/pki/ca-trust/source/anchors/ \
             /etc/pki/ca-trust/extracted/ \
 && chmod -cR g+w \
             /etc/pki/ca-trust/source/anchors/ \
             /etc/pki/ca-trust/extracted/

# ==================================================
# Modify the conda environment of the Jupyter kernel
# ==================================================
# The name of the kernel conda environment is given by $DSX_KERNEL_CONDENV.
# The examples assume that you are modifying the conda environment of the
# base image. If you prefer to create and use a different conda environment
# from scratch, set DSX_KERNEL_CONDENV to the name of that environment.
#
# The conda environment should be changed with user and group "wsbuild".
# In each layer, call fix-conda-permissions to ensure group write permission,
# because some files may get installed without respect for the umask.

USER wsbuild:wsbuild

# If you need to add files to the image, use
# COPY --chown=wsbuild:wsbuild ...

# ===========================
# Install packages with conda
# ===========================
# If you don't need to install packages with conda, remove this RUN statement.
RUN umask 002 \
 && conda install -n $DSX_KERNEL_CONDENV \
     basemap=1.3.0 \
     py4j \
 && /bin/bash -c 'source /opt/ibm/build/bin/installutils.sh ; fix-conda-permissions'

# =========================
# Install packages with pip
# =========================
# If you don't need to install packages with pip, remove this RUN statement.
RUN umask 002 \
 && conda run -n $DSX_KERNEL_CONDENV pip install \
     astrotools==1.4.2 \
     scikit-multilearn \
     scikit-plot \
     seawater \
     fuzzy \
 && /bin/bash -c 'source /opt/ibm/build/bin/installutils.sh ; fix-conda-permissions'

# ========================================================
# Install R packages from CRAN or tar.gz file
# below exaple installed testthat package
# users can add any other additional packages simialr way
# If you don't need to install packages from CRAN, remove this RUN statement.
# =======================================================
RUN umask 002 \
 && source activate ${DSX_KERNEL_CONDENV} \
 && R -e "install.packages('testthat', repos='http://cran.rstudio.com')" \
 && /bin/bash -c 'source /opt/ibm/build/bin/installutils.sh ; fix-conda-permissions'

# ======================================
# change from build user to runtime user
# ======================================
USER $DSX_USERNAME:wsbuild

Parent topic: Creating a custom image