-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
102 lines (65 loc) · 2.88 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
# Build this image: docker build -t mpi .
FROM ubuntu:20.04
MAINTAINER Mohamad Arafeh <[email protected]>
ENV USER mpirun
ENV DEBIAN_FRONTEND=noninteractive \
HOME=/home/${USER}
RUN apt-get update
RUN apt-get install -y --no-install-recommends sudo apt-utils
RUN apt-get install -y software-properties-common gcc && \
add-apt-repository -y 'ppa:deadsnakes/ppa'
RUN apt-get update
RUN apt-get update && apt-get install -y python3.9 python3-distutils \
python3-pip python3-apt git wget vim nano
RUN apt-get install -y --no-install-recommends openssh-server \
gfortran libopenmpi-dev openmpi-bin openmpi-common openmpi-doc binutils
RUN mkdir /var/run/sshd
RUN echo 'root:${USER}' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
# ------------------------------------------------------------
# Add an 'mpirun' user
# ------------------------------------------------------------
RUN adduser --disabled-password --gecos "" ${USER} && \
echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# ------------------------------------------------------------
# Set-Up SSH with our Github deploy key
# ------------------------------------------------------------
ENV SSHDIR ${HOME}/.ssh/
RUN mkdir -p ${SSHDIR}
ADD utilities/mpi/ssh/config ${SSHDIR}/config
ADD utilities/mpi/ssh/id_rsa.mpi ${SSHDIR}/id_rsa
ADD utilities/mpi/ssh/id_rsa.mpi.pub ${SSHDIR}/id_rsa.pub
ADD utilities/mpi/ssh/id_rsa.mpi.pub ${SSHDIR}/authorized_keys
RUN chmod -R 600 ${SSHDIR}* && \
chown -R ${USER}:${USER} ${SSHDIR}
# RUN pip3 install --upgrade python3-pip
USER ${USER}
RUN pip3 install --user -U setuptools \
&& pip3 install --user mpi4py
# ------------------------------------------------------------
# Add localfed lib
# ------------------------------------------------------------
ENV FedLib=${HOME}/localfed
ENV PYTHONPATH "${PYTHONPATH}:${FedLib}"
ADD . ${FedLib}
RUN pip3 install -r ${FedLib}/requirements.txt
# ------------------------------------------------------------
# Configure OpenMPI
# ------------------------------------------------------------
USER root
RUN rm -fr ${HOME}/.openmpi && mkdir -p ${HOME}/.openmpi
ADD utilities/mpi/default-mca-params.conf ${HOME}/.openmpi/mca-params.conf
RUN chown -R ${USER}:${USER} ${HOME}/.openmpi
RUN chown -R ${USER}:${USER} ${FedLib}
# ------------------------------------------------------------
# Copy MPI4PY example scripts
# ------------------------------------------------------------
ENV TRIGGER 1
ADD utilities/mpi/benchmarks ${HOME}/mpi4py_benchmarks
RUN chown -R ${USER}:${USER} ${HOME}/mpi4py_benchmarks
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]