-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
197 lines (152 loc) · 7.25 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
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
196
197
FROM ubuntu:20.04
LABEL org.opencontainers.image.source="https://github.com/michaelmayer2/slurm-docker-cluster" \
org.opencontainers.image.title="slurm-docker-cluster" \
org.opencontainers.image.description="Slurm Docker cluster on Ububtu 20.04 LTS" \
org.label-schema.docker.cmd="docker-compose up -d" \
maintainer="Michael Mayer"
ARG SLURM_TAG=slurm-19-05-2-1
ARG GOSU_VERSION=1.11
ARG R_VERSIONS="3.6.3 4.3.2"
ARG PWB_VERSION
ARG PROXY
RUN if test -n $PROXY; then echo "Acquire::http { Proxy \"http://$PROXY:3142\"; };" >> /etc/apt/apt.conf.d/01proxy; fi
## Install R and RStudio Workbench
COPY rstudio/create.R /tmp/create.R
RUN apt-get update -y && \
apt-get install -y gdebi-core curl && \
IFS=" "; for R_VERSION in $R_VERSIONS ; \
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 && \
/opt/R/$R_VERSION/bin/Rscript /tmp/create.R ;\
done && \
curl -O https://download2.rstudio.org/server/bionic/amd64/rstudio-workbench-${PWB_VERSION}-amd64.deb && \
gdebi -n rstudio-workbench-${PWB_VERSION}-amd64.deb && \
rm -f rstudio-workbench-${PWB_VERSION}-amd64.deb && \
apt clean all && \
rm -rf /var/cache/apt
COPY rstudio/launcher.conf /etc/rstudio/launcher.conf
COPY rstudio/launcher.slurm.conf /etc/rstudio/launcher.slurm.conf
COPY rstudio/launcher.slurm.profiles.conf /etc/rstudio/launcher.slurm.profiles.conf
COPY rstudio/rserver.conf /etc/rstudio/rserver.conf
## Install SLURM
### Populate directories and set permissions
RUN /bin/bash -c "set -x \
&& groupadd -r --gid=995 slurm \
&& useradd -r -s /bin/bash -g slurm --uid=995 slurm \
&& mkdir -p /home/slurm && chown slurm /home/slurm \
&& mkdir -p /etc/sysconfig/slurm \
/var/spool/slurmd \
/var/run/slurmd \
/var/run/slurmdbd \
/var/lib/slurmd \
/var/log/slurm \
/data \
&& touch /var/lib/slurmd/node_state \
/var/lib/slurmd/front_end_state \
/var/lib/slurmd/job_state \
/var/lib/slurmd/resv_state \
/var/lib/slurmd/trigger_state \
/var/lib/slurmd/assoc_mgr_state \
/var/lib/slurmd/assoc_usage \
/var/lib/slurmd/qos_usage \
/var/lib/slurmd/fed_mgr_state \
&& ln -s /etc/slurm-llnl /etc/slurm \
&& chown -R slurm:slurm /var/*/slurm* "
RUN /bin/bash -c "set -x \
&& groupadd -r --gid=105 munge \
&& useradd -r -s /bin/bash -g munge --uid=105 munge"
### Install slurm packages and db dependencies
RUN set -ex \
&& apt-get update \
&& apt-get -y install \
slurmd slurmdbd slurmctld slurm-client \
mariadb-server \
mariadb-client \
libmariadbd-dev \
psmisc \
bash-completion \
&& apt clean all \
&& rm -rf /var/cache/apt
RUN umask 0022 && echo "export TZ=Europe/Paris" > /etc/profile.d/timezone.sh
### Copy slurm.conf and slurmdbd.conf
COPY slurm/slurm.conf /etc/slurm/slurm.conf
COPY slurm/slurmdbd.conf /etc/slurm/slurmdbd.conf
RUN chmod 0600 /etc/slurm/slurmdbd.conf
## Configure a mail client and add a couple of nice to have tools
RUN mkdir -p /etc/postfix
COPY rstudio/main.cf /etc/postfix/main.cf
ENV DEBIAN_FRONTEND=noninteractive
RUN set -ex \
&& apt-get update \
&& apt-get -y install \
wget gpg vim net-tools iputils-ping postfix mailutils \
&& apt clean all \
&& rm -rf /var/cache/apt
## Add VSCode and Jupyter/Python (copied from https://github.com/rstudio/rstudio-docker-products/blob/main/workbench/Dockerfile)
# Install jupyter -------------------------------------------------------------#
ARG JUPYTER_VERSION=3.8.10
RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash Miniconda3-latest-Linux-x86_64.sh -bp /opt/python/jupyter && \
/opt/python/jupyter/bin/conda install -y python==${JUPYTER_VERSION} && \
rm -rf Miniconda3-latest-Linux-x86_64.sh && \
/opt/python/jupyter/bin/pip install \
jupyter==1.0.0 \
'jupyterlab<3.0.0' \
rsp_jupyter \
rsconnect_jupyter && \
/opt/python/jupyter/bin/jupyter kernelspec remove python3 -f && \
/opt/python/jupyter/bin/pip uninstall -y ipykernel
# Install RSW/RSC Notebook Extensions --------------------#
RUN /opt/python/jupyter/bin/jupyter-nbextension install --sys-prefix --py rsp_jupyter && \
/opt/python/jupyter/bin/jupyter-nbextension enable --sys-prefix --py rsp_jupyter && \
/opt/python/jupyter/bin/jupyter-nbextension install --sys-prefix --py rsconnect_jupyter && \
/opt/python/jupyter/bin/jupyter-nbextension enable --sys-prefix --py rsconnect_jupyter && \
/opt/python/jupyter/bin/jupyter-serverextension enable --sys-prefix --py rsconnect_jupyter
# Install Python --------------------------------------------------------------#
ARG PYTHON_VERSION=3.9.5
RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh && \
bash Miniconda3-4.7.12.1-Linux-x86_64.sh -bp /opt/python/${PYTHON_VERSION} && \
/opt/python/${PYTHON_VERSION}/bin/conda install -y python==${PYTHON_VERSION} && \
/opt/python/${PYTHON_VERSION}/bin/pip install \
ipykernel \
virtualenv \
&& \
rm -rf Miniconda3-*-Linux-x86_64.sh && \
/opt/python/${PYTHON_VERSION}/bin/python -m ipykernel install --name py${PYTHON_VERSION} --display-name "Python ${PYTHON_VERSION}"
# Install another Python --------------------------------------------------------------#
ARG PYTHON_VERSION_ALT=3.8.10
RUN curl -O https://repo.anaconda.com/miniconda/Miniconda3-4.7.12.1-Linux-x86_64.sh && \
bash Miniconda3-4.7.12.1-Linux-x86_64.sh -bp /opt/python/${PYTHON_VERSION_ALT} && \
/opt/python/${PYTHON_VERSION_ALT}/bin/conda install -y python==${PYTHON_VERSION_ALT} && \
/opt/python/${PYTHON_VERSION_ALT}/bin/pip install \
ipykernel \
virtualenv \
&& \
rm -rf Miniconda3-*-Linux-x86_64.sh && \
/opt/python/${PYTHON_VERSION_ALT}/bin/python -m ipykernel install --name py${PYTHON_VERSION_ALT} --display-name "Python ${PYTHON_VERSION_ALT}"
COPY rstudio/jupyter.conf /etc/rstudio/jupyter.conf
# Install VSCode code-server --------------------------------------------------#
RUN rstudio-server install-vs-code /opt/code-server/
COPY rstudio/vscode.conf /etc/rstudio/vscode.conf
COPY rstudio/vscode-user-settings.json /etc/rstudio/vscode-user-settings.json
## Install gosu
RUN set -ex \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -rf "${GNUPGHOME}" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
## Add test user mm
RUN groupadd mm -g 2048 \
&& useradd mm -s /bin/bash -u 2048 -g 2048\
&& mkdir /home/mm \
&& chown mm:mm /home/mm \
&& bash -c "echo -e \"test123\\ntest123\" | passwd mm"
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["slurmdbd"]