-
Notifications
You must be signed in to change notification settings - Fork 63
/
Dockerfile
81 lines (56 loc) · 2.43 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
# Build this image: docker build -t mpi .
#
FROM ubuntu:18.04
# FROM phusion/baseimage
MAINTAINER Ole Weidner <[email protected]>
ENV USER mpirun
ENV DEBIAN_FRONTEND=noninteractive \
HOME=/home/${USER}
RUN apt-get update -y && \
apt-get install -y --no-install-recommends sudo apt-utils && \
apt-get install -y --no-install-recommends openssh-server \
python-dev python-numpy python-pip python-virtualenv python-scipy \
gcc gfortran libopenmpi-dev openmpi-bin openmpi-common openmpi-doc binutils && \
apt-get clean && apt-get purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
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 ssh/config ${SSHDIR}/config
ADD ssh/id_rsa.mpi ${SSHDIR}/id_rsa
ADD ssh/id_rsa.mpi.pub ${SSHDIR}/id_rsa.pub
ADD ssh/id_rsa.mpi.pub ${SSHDIR}/authorized_keys
RUN chmod -R 600 ${SSHDIR}* && \
chown -R ${USER}:${USER} ${SSHDIR}
RUN pip install --upgrade pip
USER ${USER}
RUN pip install --user -U setuptools \
&& pip install --user mpi4py
# ------------------------------------------------------------
# Configure OpenMPI
# ------------------------------------------------------------
USER root
RUN rm -fr ${HOME}/.openmpi && mkdir -p ${HOME}/.openmpi
ADD default-mca-params.conf ${HOME}/.openmpi/mca-params.conf
RUN chown -R ${USER}:${USER} ${HOME}/.openmpi
# ------------------------------------------------------------
# Copy MPI4PY example scripts
# ------------------------------------------------------------
ENV TRIGGER 1
ADD mpi4py_benchmarks ${HOME}/mpi4py_benchmarks
RUN chown -R ${USER}:${USER} ${HOME}/mpi4py_benchmarks
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]