Created
July 18, 2022 08:05
-
-
Save pat-s/b0cb9a11e6f3fabe50e05b89915180cf to your computer and use it in GitHub Desktop.
Stripped RSW server image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:focal | |
# set ENV variables | |
ENV LC_ALL=en_US.UTF-8 | |
ENV LANG=en_US.UTF-8 | |
ENV TERM=xterm | |
ENV DEBIAN_FRONTEND=noninteractive | |
# locale ----------------------------------------------------------------------# | |
RUN apt update \ | |
&& apt install -y locales | |
RUN echo "Europe/Zurich" >/etc/timezone \ | |
echo -e "en_US.UTF-8 UTF-8\nde_CH.UTF-8 UTF-8\nfr_CH.UTF-8 UTF-8" >>/etc/locale.gen \ | |
&& locale-gen de_CH.utf8 en_US.utf8 fr_CH.utf8 \ | |
&& /usr/sbin/update-locale LANG=en_US.UTF-8 | |
# we actually do not need these files in the server image, though they are checked in startup.sh and their non-existence would result in an error | |
COPY renv.sh / | |
RUN chmod +x /renv.sh | |
# Set default env values | |
ENV RSW_LICENSE "" | |
# ENV RSW_TESTUSER rstudio | |
# ENV RSW_TESTUSER_PASSWD rstudiotestuser | |
# ENV RSW_TESTUSER_UID 10000 | |
ENV RSW_LAUNCHER "" | |
ENV RSW_LAUNCHER_TIMEOUT 10 | |
# this uses the default rstudio global options defined in the rstudio.prefs.json file. | |
ENV XDG_CONFIG_DIRS "/etc" | |
# Install R runtime deps ------------------------------------------------------# | |
RUN apt update \ | |
&& apt install -y gdebi-core gdebi supervisor sssd sssd-dbus sssd-tools rsyslog gfortran libbz2-dev libblas-dev libicu-dev liblapack-dev liblzma-dev libpaper-utils libpcre2-dev libtcl8.6 libtk8.6 libxt6 unzip zip zlib1g-dev libpcre3-dev \ | |
&& apt-get clean \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Install R -------------------------------------------------------------------# | |
ARG TOKEN | |
ARG R_MULTIPLE_VERSIONS | |
ARG UBUNTU_VERSION | |
RUN curl -s -O -X GET "https://gitea.cynkra.com/api/v1/repos/config/config/raw/scripts/install-r.sh" -H "accept: application/json" -H "Authorization: token $TOKEN" \ | |
&& chmod +x install-r.sh \ | |
&& bash install-r.sh || touch /failure \ | |
&& ! test -f /failure \ | |
&& rm install-r.sh | |
# install jupyter -------------------------------------------------------------# | |
# 'notebook' and 'jupyterlab' are needed to start the Jupyter IDEs | |
RUN apt update && apt install -y python3-pip \ | |
&& pip3 install notebook jupyterlab | |
# startup ---------------------------------------------------------------------# | |
# copy startup.sh which takes care of the server startup, license activation and other necessary configurations at runtime | |
COPY startup.sh /usr/local/bin/startup.sh | |
RUN chmod +x /usr/local/bin/startup.sh \ | |
# Create placeholders for Renviron.site and Rprofile.site | |
&& touch /etc/Renviron.site && touch /etc/Rprofile.site | |
# Copy config and startup | |
COPY startup/* /startup/base/ | |
COPY startup-launcher/* /startup/launcher/ | |
COPY startup-sssd/* /startup/sssd/ | |
COPY conf/supervisord.conf /etc/supervisor/supervisord.conf | |
COPY startup.sh /usr/local/bin/startup.sh | |
RUN chmod +x /usr/local/bin/startup.sh | |
# suppress error message "activation of imklog failed" ------------------------# | |
# https://stackoverflow.com/a/60265997/4185785 | |
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf | |
# FIXME: this does not solve the problem | |
RUN mkdir -p /var/run/rstudio-server/rstudio-rserver \ | |
&& touch /var/run/rstudio-server/rstudio-rserver/rserver-monitor.socket | |
# Locale configuration --------------------------------------------------------# | |
RUN localedef -i en_US -f UTF-8 en_US.UTF-8 | |
ENV LANG en_US.UTF-8 | |
ENV LANGUAGE en_US:en | |
ENV LC_ALL en_US.UTF-8 | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN locale-gen de_CH.utf8 de_DE.utf8 && update-locale | |
# Runtime settings ------------------------------------------------------------# | |
ARG TOKEN | |
RUN export TINI_VERSION=$(curl -s -X GET "https://gitea.cynkra.com/api/v1/repos/config/config/raw/tini-version" -H "accept: application/json" -H "Authorization: token $TOKEN") && \ | |
curl -sL -o /usr/local/bin/tini https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini && \ | |
chmod +x /usr/local/bin/tini \ | |
# wait-for-it | |
&& curl -sL -o /usr/local/bin/wait-for-it.sh https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh && \ | |
chmod +x /usr/local/bin/wait-for-it.sh | |
# copy default configuration files. These files can be replaced by mounting the as volumes at runtime. | |
# COPY conf/* /etc/rstudio/ | |
# Install RSW (release or preview) --------------------------------------------# | |
ARG RSW_RELEASE_CHANNEL | |
ARG TOKEN | |
RUN curl -s -O -X GET "https://gitea.cynkra.com/api/v1/repos/config/config/raw/scripts/install-rsw.sh" -H "accept: application/json" -H "Authorization: token $TOKEN" \ | |
&& chmod +x install-rsw.sh \ | |
&& bash install-rsw.sh || touch /failure \ | |
&& ! test -f /failure \ | |
&& rm install-rsw.sh | |
# Install VSCode --------------------------------------------------------------# | |
# only create VSCode dir for extensions | |
# a full code-server install is not needed for the server image | |
# IMPORTANT: this is the dir vscode expects extensions to go. It is not created by the code-server installer. | |
# For users to install extensions, it must be world readable | |
RUN mkdir -p /usr/lib/code-server/lib/vscode/extensions \ | |
&& chmod 777 /usr/lib/code-server/lib/vscode/extensions | |
# Create log dirs | |
RUN mkdir -p /var/lib/rstudio-server/monitor/log && \ | |
chown -R rstudio-server:rstudio-server /var/lib/rstudio-server/monitor && \ | |
touch /var/log/rstudio-server.log && \ | |
chown -R rstudio-server:rstudio-server /var/log/rstudio-server.log | |
EXPOSE 8787/tcp | |
EXPOSE 5559/tcp | |
ENTRYPOINT [] | |
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment