-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathr-session-complete.sdef
195 lines (158 loc) · 7.91 KB
/
r-session-complete.sdef
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
Bootstrap: docker
From: ubuntu:focal
# needed if you want to set up CRAN and BioConductor repos from RSPM (optional)
# set binaryflag to "" in order to stick to source RPMs
%files
../scripts/run.R /
../scripts/bioc.txt /
../scripts/r-packages.txt /
%post -c /bin/bash
# Install Pro Drivers
apt-get update && apt-get install -y gdebi-core curl wget
curl -O https://cdn.rstudio.com/drivers/7C152C12/installer/rstudio-drivers_{{ PRO_DRIVERS_VERSION }}_amd64.deb && \
gdebi -n rstudio-drivers_{{ PRO_DRIVERS_VERSION }}_amd64.deb && \
rm -f rstudio-drivers_{{ PRO_DRIVERS_VERSION }}_amd64.deb
# Install TeXlive
apt-get install libpod-simple-perl -y
curl -LO https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \
tar xvfz install-tl-unx.tar.gz && \
rm install-tl-unx.tar.gz && \
cd install-tl-* && \
./install-tl --scheme small --no-interaction
echo "export PATH=/usr/local/texlive/2024/bin/x86_64-linux:\$PATH" > /etc/profile.d/texlive.sh
# Install Quarto
curl -o quarto.tar.gz -L https://github.com/quarto-dev/quarto-cli/releases/download/v{{ QUARTO_VERSION }}/quarto-{{ QUARTO_VERSION }}-linux-amd64.tar.gz \
&& mkdir -p /opt/quarto/{{ QUARTO_VERSION }} \
&& tar -zxf quarto.tar.gz -C "/opt/quarto/{{ QUARTO_VERSION }}" --strip-components=1 \
&& rm -f quarto.tar.gz \
&& ln -s /opt/quarto/{{ QUARTO_VERSION }}/bin/quarto /usr/local/bin/quarto
# Install Python
for PYTHON_VERSION in {{ PYTHON_VERSION_LIST }}
do
curl -O https://cdn.rstudio.com/python/ubuntu-2004/pkgs/python-${PYTHON_VERSION}_1_amd64.deb
gdebi -n python-${PYTHON_VERSION}_1_amd64.deb
rm -f python-${PYTHON_VERSION}_1_amd64.deb
done
# Configure Python versions to have
# - upgraded pip
# - configure pip to use posit package manager
# - preinstalling packages needed for the integration with other tools (e.g Connect)
# Note: Install will run in parallel to speed up things
cat << EOF > /etc/pip.conf
[global]
timeout = 60
index-url = https://packagemanager.posit.co/pypi/latest/simple
EOF
for PYTHON_VERSION in {{ PYTHON_VERSION_LIST }}
do
/opt/python/${PYTHON_VERSION}/bin/pip install --upgrade \
pip setuptools wheel && \
/opt/python/${PYTHON_VERSION}/bin/pip install \
ipykernel \
jupyter \
rsconnect_jupyter \
rsconnect_python \
rsp_jupyter \
jupyterlab~=4.2.4 \
pwb_jupyterlab~=1.0 && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-nbextension install --sys-prefix --py rsp_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-nbextension enable --sys-prefix --py rsp_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-nbextension install --sys-prefix --py rsconnect_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-nbextension enable --sys-prefix --py rsconnect_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/jupyter-serverextension enable --sys-prefix --py rsconnect_jupyter && \
/opt/python/${PYTHON_VERSION}/bin/python -m ipykernel install --name py${PYTHON_VERSION} --display-name "Python ${PYTHON_VERSION}" &
done
wait
# Use default version to point to jupyter and python
if [ ! -z {{ PYTHON_VERSION_DEFAULT }} ]; then
ln -s /opt/python/{{ PYTHON_VERSION_DEFAULT }}/bin/jupyter /usr/local/bin
ln -s /opt/python/{{ PYTHON_VERSION_DEFAULT }}/bin/python /usr/local/bin
ln -s /opt/python/{{ PYTHON_VERSION_DEFAULT }}/bin/python3 /usr/local/bin
fi
# Install PWB session components
mkdir -p /usr/lib/rstudio-server
DEBIAN_FRONTEND=noninteractive apt-get install -y curl libcurl4-gnutls-dev libssl-dev libuser libuser1-dev rrdtool libpq5
curl -O https://s3.amazonaws.com/rstudio-ide-build/session/focal/amd64/rsp-session-focal-{{ PWB_VERSION }}-amd64.tar.gz
tar xfz rsp-session-focal-{{ PWB_VERSION }}-amd64.tar.gz -C /usr/lib/rstudio-server --strip=1
rm -f rsp-session-focal-{{ PWB_VERSION }}-amd64.tar.gz
#!/bin/bash
# Install Java JDK (optional)
apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
default-jdk
# Install and configure new set of defined R versions
for R_VERSION in {{ R_VERSION_LIST }}
do
curl -O https://cdn.rstudio.com/r/ubuntu-2004/pkgs/r-${R_VERSION}_1_amd64.deb && \
gdebi -n r-${R_VERSION}_1_amd64.deb && \
rm -f r-${R_VERSION}_1_amd64.deb
# Reconfigure R for Java (optional)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
/opt/R/${R_VERSION}/bin/R CMD javareconf
echo $JAVA_HOME/lib/server > /etc/ld.so.conf.d/java.conf
# Need to make sure R is in PATH so that pak can run R as a subprocess
PATH=/opt/R/${R_VERSION}/bin:$PATH /opt/R/${R_VERSION}/bin/Rscript /run.R
done
rm -f /run.R
# Defining system default version
if [ ! -z {{ R_VERSION_DEFAULT }} ]; then
ln -s /opt/R/{{ R_VERSION_DEFAULT }}/bin/R /usr/local/bin
ln -s /opt/R/{{ R_VERSION_DEFAULT }}/bin/Rscript /usr/local/bin
fi
# Installing frequently needed system dependencies
# (Cf. https://docs.posit.co/connect/admin/r/dependencies/)
apt install -y libcairo2-dev libssl-dev make libcurl4-openssl-dev \
libmysqlclient-dev unixodbc-dev libnode-dev default-jdk libxml2-dev \
git libfontconfig1-dev libfreetype6-dev libssh2-1-dev zlib1g-dev \
libglpk-dev libjpeg-dev imagemagick libmagick++-dev gsfonts cmake \
libpng-dev libtiff-dev python3 libglu1-mesa-dev libgl1-mesa-dev \
libgdal-dev gdal-bin libgeos-dev libproj-dev libsqlite3-dev \
libsodium-dev libicu-dev tcl tk tk-dev tk-table libfribidi-dev \
libharfbuzz-dev libudunits2-dev
# Install zeromq as prereq for clustermq (optional)
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libzmq5
# Install JAGS as prereq for rjags (optional)
DEBIAN_FRONTEND=noninteractive apt-get install -y \
jags
# Install SLURM
groupadd -g 401 slurm
useradd -u 401 -g 401 slurm
apt-get install -y libmunge-dev
# Note that the git branches on github do have a slightly different
# naming scheme - firstly the dots are replaced by dashes and
# secondly each SLURM version can have more than one release tag
# Here, we simply append "-1" to use the first git tag of a given
# SLURM version
dir=`mktemp -d` && \
cd $dir && \
rm -rf slurm && \
export SLURM_VER={{ SLURM_VERSION }} && git clone --depth 1 -b slurm-${SLURM_VER//./-}-1 https://github.com/SchedMD/slurm.git && \
cd slurm && \
./configure --prefix /usr/local/slurm > /var/log/slurm-configure.log && \
echo "Compiling SLURM" && \
make -j 4 > /var/log/slurm-compile.log && \
echo "Installing SLURM" && \
make install > /var/log/slurm-install.log && \
cd / && \
rm -rf $dir && \
ln -s /usr/local/slurm/bin/* /usr/local/bin
#Install Apptainer
dir=`mktemp -d`
cd $dir
curl -L -O https://github.com/apptainer/apptainer/releases/download/v{{ APPTAINER_VERSION }}/apptainer_{{ APPTAINER_VERSION }}_amd64.deb
curl -L -O https://github.com/apptainer/apptainer/releases/download/v{{ APPTAINER_VERSION }}/apptainer-suid_{{ APPTAINER_VERSION }}_amd64.deb
gdebi -n apptainer_{{ APPTAINER_VERSION }}_amd64.deb
gdebi -n apptainer-suid_{{ APPTAINER_VERSION }}_amd64.deb
rm -f apptainer*
cd
rm -rf $dir
rm -rf /var/cache/yum/*
#%startscript
# # The below is saving the necessary environment variables so they can eb inherited into
# # subsequent singularity calls
# env | grep -e ^SINGULARITY -e ^SLURM | grep -v NAME | grep -v BIND | sed 's/^/export /' > /tmp/.slurm-$USER-$SLURM_JOBID.env
# $@
%environment
TINI_SUBREAPER=true
export SLURM_CONF=/opt/slurm/etc/slurm.conf