r-studio-test/Dockerfile

113 lines
4.9 KiB
Docker
Raw Normal View History

2022-04-04 19:35:45 +02:00
FROM d4science/r-studio-requirement
LABEL org.d4science.image.licenses="EUPL-1.2" \
org.d4science.image.source="https://code-repo.d4science.org/gCubeSystem/r-studio-requirement" \
org.d4science.image.vendor="D4Science <https://www.d4science.org>" \
org.d4science.image.authors="Andrea Dell'Amico <andrea.dellamico@isti.cnr.it>, Roberto Cirillo <roberto.cirillo@isti.cnr.it>" \
org.d4science.image.r_version="2022.02.1+461"
2023-03-15 17:31:31 +01:00
ARG NB_USER="jovyan"
ARG NB_UID="1000"
ARG NB_GID="100"
2023-03-20 13:22:22 +01:00
ARG HOME="/home/${NB_USER}"
2022-04-04 19:35:45 +02:00
ENV S6_VERSION=v2.1.0.2
ENV RSTUDIO_VERSION=2022.02.1+461
2023-03-15 17:31:31 +01:00
ENV DEFAULT_USER="jovyan"
ENV USERID="1000"
ENV GROUPID="100"
2022-04-04 19:35:45 +02:00
ENV PANDOC_VERSION=default
ENV PATH=/usr/lib/rstudio-server/bin:$PATH
2023-03-15 17:31:31 +01:00
ENV DEBIAN_FRONTEND=noninteractive
# Configure environment
ENV SHELL=/bin/bash \
NB_USER="${NB_USER}" \
NB_UID=${NB_UID} \
NB_GID=${NB_GID} \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
ENV HOME="/home/${NB_USER}"
2022-04-04 19:35:45 +02:00
2023-03-15 17:31:31 +01:00
RUN apt-get update --yes && \
apt-get upgrade --yes && \
apt-get install --yes --no-install-recommends \
2023-03-20 13:33:04 +01:00
python3 python3-pip \
curl
2022-04-04 19:35:45 +02:00
RUN /rocker_scripts/install_rstudio.sh
# This part comes from https://github.com/openanalytics/shinyproxy-rstudio-ide-demo/blob/master/Dockerfile
RUN echo "www-frame-origin=same" >> /etc/rstudio/disable_auth_rserver.conf
RUN echo "www-verify-user-agent=0" >> /etc/rstudio/disable_auth_rserver.conf
2023-03-20 13:22:22 +01:00
ARG EXCLUDE_VARS="HOME PASSWORD RSTUDIO_VERSION BATCH_USER_CREATION"
ARG R_HOME="/usr/local"
# The 0*_ scripts cannot be used anymore
# ADD 01_set_env.sh /etc/cont-init.d/01_set_env
2023-03-20 13:33:04 +01:00
RUN for file in /var/run/s6/container_environment/* ; do sed -i "/^${file##*/}=/d" ${R_HOME}/etc/Renviron.site ; regex="(^| )${file##*/}($| )" ; if [ ! "$exclude_vars" =~ "$regex" ] ; then echo "${file##*/}=$(cat $file)" >> ${R_HOME}/etc/Renviron.site ; fi ; done
2023-03-20 13:22:22 +01:00
# ADD 02_userconf.sh /etc/cont-init.d/02_userconf
RUN mv -f /etc/rstudio/disable_auth_rserver.conf /etc/rstudio/rserver.conf
RUN echo "USER=$NB_USER" >> /etc/environment
# ADD 03_setup_root_path.sh /etc/cont-init.d/03_setup_root_path
2022-04-04 19:35:45 +02:00
# By default RStudio does not give access to all enviornment variables defined in the container (e.g. using ShinyProxy).
# Uncomment the next line, to change this behavior.
2023-03-20 13:22:22 +01:00
# ADD 04_copy_env.sh /etc/cont-init.d/04_copy_env
# ADD 05_setup_rsession_parameters.sh /etc/cont-init.d/05_setup_rsession_parameters
RUN echo "session-timeout-minutes=7200" >> /etc/rstudio/rsession.conf
RUN echo "session-disconnected-timeout-minutes=1440" >> /etc/rstudio/rsession.conf
RUN echo "session-quit-child-processes-on-exit=0" >> /etc/rstudio/rsession.conf
RUN echo "session-default-working-dir=~" >> /etc/rstudio/rsession.conf
RUN echo "session-default-new-project-dir=~" >> /etc/rstudio/rsession.conf
RUN #echo "session-save-action-default=yes" >> /etc/rstudio/rsession.conf
RUN echo "allow-shell=1" >> /etc/rstudio/rsession.conf
RUN #echo "allow-terminal-websockets=1" >> /etc/rstudio/rsession.conf
RUN echo "limit-cpu-time-minutes=0" >> /etc/rstudio/rsession.conf
RUN echo "limit-file-upload-size-mb=0" >> /etc/rstudio/rsession.conf
RUN #echo "limit-xfs-disk-quota=no" >> /etc/rstudio/rsession.conf
RUN curl -o /etc/R/Rprofile.site "https://code-repo.d4science.org/gCubeSystem/rstudio-rprofile/raw/branch/master/jupyter-Rprofile.site"
2022-04-04 19:35:45 +02:00
# Copy a script that we will use to correct permissions after running certain commands
COPY fix-permissions /usr/local/bin/fix-permissions
RUN chmod a+rx /usr/local/bin/fix-permissions
2023-03-16 16:07:24 +01:00
# Create NB_USER with name jovyan user with UID=1000 and in the 'users' group
# and make sure these dirs are writable by the `users` group.
RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
sed -i.bak -e 's/^%admin/#%admin/' /etc/sudoers && \
sed -i.bak -e 's/^%sudo/#%sudo/' /etc/sudoers && \
2023-03-20 13:22:22 +01:00
userdel -r rstudio && \
useradd -l -m -s /bin/bash -N -u "${NB_UID}" "${NB_USER}" && \
2023-03-16 16:07:24 +01:00
chmod g+w /etc/passwd && \
fix-permissions "${HOME}"
2023-03-15 17:31:31 +01:00
# Install the jupiterhub proxy
RUN pip3 install \
jsonschema'[format,format-nongpl]' \
jupyterhub \
jupyterlab \
jupyter-rsession-proxy \
jupyter-server-proxy \
notebook
2023-03-15 17:31:31 +01:00
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
# Enable prompt color in the skeleton .bashrc before creating the default NB_USER
# hadolint ignore=SC2016
RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
2023-03-20 13:22:22 +01:00
WORKDIR ${HOME}
2022-04-04 19:35:45 +02:00
# Prepare the workspace environment
2023-03-15 17:31:31 +01:00
# RUN mkdir -p /opt/workspace-lib
# RUN mkdir /var/log/workspace-lib
# ADD https://maven.d4science.org/nexus/content/repositories/gcube-snapshots/org/gcube/data-access/sh-fuse-integration/2.0.0-SNAPSHOT/sh-fuse-integration-2.0.0-20211005.090627-1-jar-with-dependencies.jar /opt/workspace-lib/fuse-workspace.jar
# ADD 06_workspace_mount.sh /etc/cont-init.d/06_workspace_mount
# ADD 06-fuse-logback.xml /opt/workspace-lib/logback.xml
2022-04-04 19:35:45 +02:00
# EXPOSE 8787
2023-03-20 13:22:22 +01:00
# CMD ["/init"]