-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
84 lines (67 loc) · 3.66 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
FROM ghcr.io/nmfs-opensci/py-rocket-base/base-image:latest
LABEL org.opencontainers.image.maintainers="[email protected]"
LABEL org.opencontainers.image.author="[email protected]"
LABEL org.opencontainers.image.source=https://github.com/nmfs-opensci/py-rocket-base
LABEL org.opencontainers.image.description="Python (3.12), R (4.4.1), Desktop and Publishing tools"
LABEL org.opencontainers.image.licenses=Apache2.0
LABEL org.opencontainers.image.version=2024.11.24
USER root
# Define environment variables
# DISPLAY Tell applications where to open desktop apps - this allows notebooks to pop open GUIs
ENV REPO_DIR="/srv/repo" \
DISPLAY=":1.0" \
R_VERSION="4.4.1"
# The latest rocker will set CRAN to 'latest' but we need a date stamped version for reproducibility
# So pull the latest and use one earlier
ARG R_VERSION_PULL="4.4.2"
# Add NB_USER to staff group (required for rocker script)
# Ensure the staff group exists first
RUN groupadd -f staff && usermod -a -G staff "${NB_USER}"
# Copy files into REPO_DIR and make sure staff group can edit (use staff for rocker)
COPY --chown=${NB_USER}:${NB_USER} . ${REPO_DIR}
RUN chgrp -R staff ${REPO_DIR} && \
chmod -R g+rwx ${REPO_DIR} && \
rm -rf ${REPO_DIR}/book ${REPO_DIR}/docs
# Copy scripts to /pyrocket_scripts and set permissions
RUN mkdir -p /pyrocket_scripts && \
cp -r ${REPO_DIR}/scripts/* /pyrocket_scripts/ && \
chown -R root:staff /pyrocket_scripts && \
chmod -R 775 /pyrocket_scripts
# Install conda packages (will switch to NB_USER in script)
RUN /pyrocket_scripts/install-conda-packages.sh ${REPO_DIR}/environment.yml
# Install R, RStudio via Rocker scripts. Requires the prefix for a rocker Dockerfile
RUN R_VERSION_PULL=$R_VERSION_PULL /pyrocket_scripts/install-rocker.sh "verse_${R_VERSION}"
# Install Zotero; must be run before apt since zotero apt install requires this is run first
RUN wget -qO- https://raw.githubusercontent.com/retorquere/zotero-deb/master/install.sh | bash
# Install extra apt packages
# Install linux packages after R installation since the R install scripts get rid of packages
RUN /pyrocket_scripts/install-apt-packages.sh ${REPO_DIR}/apt.txt
# Install some basic VS Code extensions
RUN /pyrocket_scripts/install-vscode-extensions.sh ${REPO_DIR}/vscode-extensions.txt
# Re-enable man pages disabled in Ubuntu 18 minimal image
# https://wiki.ubuntu.com/Minimal
RUN yes | unminimize
ENV MANPATH="${NB_PYTHON_PREFIX}/share/man:${MANPATH}"
RUN mandb
# Add custom Jupyter server configurations
RUN mkdir -p ${NB_PYTHON_PREFIX}/etc/jupyter/jupyter_server_config.d/ && \
mkdir -p ${NB_PYTHON_PREFIX}/etc/jupyter/jupyter_notebook_config.d/ && \
cp ${REPO_DIR}/custom_jupyter_server_config.json ${NB_PYTHON_PREFIX}/etc/jupyter/jupyter_server_config.d/ && \
cp ${REPO_DIR}/custom_jupyter_server_config.json ${NB_PYTHON_PREFIX}/etc/jupyter/jupyter_notebook_config.d/
# Set up the defaults for Desktop. Keep config in the /etc so doesn't trash user environment (that they might want for other environments)
ENV XDG_CONFIG_HOME=/etc/xdg/userconfig
RUN mkdir -p ${XDG_CONFIG_HOME} && \
chown -R ${NB_USER}:${NB_USER} ${XDG_CONFIG_HOME} && \
chmod -R u+rwx,g+rwX,o+rX ${XDG_CONFIG_HOME} && \
mv ${REPO_DIR}/user-dirs.dirs ${XDG_CONFIG_HOME} && \
chmod +x ${REPO_DIR}/scripts/setup-desktop.sh && \
${REPO_DIR}/scripts/setup-desktop.sh
# Fix home permissions. Not needed in JupyterHub with persistent memory but needed if not used in that context
RUN /pyrocket_scripts/fix-home-permissions.sh
# Set up the start command
USER ${NB_USER}
RUN chmod +x ${REPO_DIR}/start \
&& cp ${REPO_DIR}/start /srv/start
# Revert to default user and home as pwd
USER ${NB_USER}
WORKDIR ${HOME}