-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile.ssh
214 lines (188 loc) · 8.86 KB
/
Dockerfile.ssh
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#
# Base Build box for PRRTE CI
# Requires:
# - Basic compile tooling and runtime support
# - libevent
# - hwloc 2.x
# Optional:
# - PMIx - built in a location that can be replaced with volume mount
# - For now use 'master' branch
# - PRRTE - built in a location that can be replaced with volume mount
# - For now use 'master' branch
# - Open MPI - built in a location that can be replaced with volume mount
# - For now use 'master' branch
#
# Directory structure for volume mounting
# - Build directory to mount in the source from the local file system
# /opt/hpc/local/build/
# - Install directory to mount in an installation directory to be shared between containers
# /opt/hpc/external/{pmix,prrte,ompi}
#
FROM centos:7
MAINTAINER Josh Hursey <[email protected]>
# ------------------------------------------------------------
# Install required packages
# ------------------------------------------------------------
RUN yum -y update && \
yum -y install \
openssh-server openssh-clients \
gcc gcc-gfortran gcc-c++ gdb strace \
binutils less wget which sudo \
perl perl-Data-Dumper \
autoconf automake libtool flex bison \
iproute net-tools hwloc make git \
libnl3 gtk2 atk cairo tcl tcsh tk pciutils lsof ethtool bc file \
psmisc valgrind && \
yum -y install epel-release && \
yum -y install pandoc --enablerepo=epel && \
yum clean all
# ------------------------------------------------------------
# Define support libraries
# - hwloc
# - libevent
# ------------------------------------------------------------
RUN mkdir -p /opt/hpc/local/build
COPY src /opt/hpc/local/src
ARG LIBEVENT_INSTALL_PATH=/opt/hpc/local/libevent
ENV LIBEVENT_INSTALL_PATH=$LIBEVENT_INSTALL_PATH
ARG HWLOC_INSTALL_PATH=/opt/hpc/local/hwloc
ENV HWLOC_INSTALL_PATH=$HWLOC_INSTALL_PATH
RUN cd /opt/hpc/local/build && \
tar -zxf ../src/libevent* && \
cd libevent-* && \
./configure --prefix=${LIBEVENT_INSTALL_PATH} > /dev/null && \
make > /dev/null && \
make install > /dev/null
RUN cd /opt/hpc/local/build && \
tar -zxf ../src/hwloc-2* && \
cd hwloc-2* && \
./configure --prefix=${HWLOC_INSTALL_PATH} > /dev/null && \
make > /dev/null && \
make install > /dev/null && \
cd .. && \
rm -rf /opt/hpc/local/src /opt/hpc/local/build/*
ENV LD_LIBRARY_PATH="$HWLOC_INSTALL_PATH/bin:$LIBEVENT_INSTALL_PATH/lib:${LD_LIBRARY_PATH}"
# -----------------------------
# Allow forced rebuild from this point
# -----------------------------
COPY .build-timestamp /root/
# ------------------------------------------------------------
# PMIx Install
# ------------------------------------------------------------
ENV PMIX_ROOT=/opt/hpc/external/pmix
ENV LD_LIBRARY_PATH="$PMIX_ROOT/lib:${LD_LIBRARY_PATH}"
RUN cd /opt/hpc/local/build && \
git clone -q -b master https://github.com/openpmix/openpmix.git && \
cd openpmix && \
./autogen.pl && \
./configure --prefix=${PMIX_ROOT} \
--with-hwloc=${HWLOC_INSTALL_PATH} \
--with-libevent=${LIBEVENT_INSTALL_PATH} 2>&1 | tee configure.log.$$ 2>&1 && \
make -j 10 2>&1 | tee make.log.$$ 2>&1 && \
make -j 10 install 2>&1 | tee make.install.log.$$ && \
cd .. && rm -rf /opt/hpc/local/build/*
# ------------------------------------------------------------
# PRRTE Install
# ------------------------------------------------------------
ENV PRRTE_ROOT=/opt/hpc/external/prrte
ENV PATH="$PRRTE_ROOT/bin:${PATH}"
ENV LD_LIBRARY_PATH="$PRRTE_ROOT/lib:${LD_LIBRARY_PATH}"
RUN cd /opt/hpc/local/build && \
git clone -q -b master https://github.com/openpmix/prrte.git && \
cd prrte && \
./autogen.pl && \
./configure --prefix=${PRRTE_ROOT} \
--with-hwloc=${HWLOC_INSTALL_PATH} \
--with-libevent=${LIBEVENT_INSTALL_PATH} \
--with-pmix=${PMIX_ROOT} 2>&1 | tee configure.log.$$ 2>&1 && \
make -j 10 2>&1 | tee make.log.$$ 2>&1 && \
make install 2>&1 | tee make.install.log.$$ 2>&1 && \
rm -rf /opt/hpc/local/build/*
# ------------------------------------------------------------
# Open MPI Install
# ------------------------------------------------------------
ENV MPI_ROOT=/opt/hpc/external/ompi
ENV PATH="$MPI_ROOT/bin:${PATH}"
ENV LD_LIBRARY_PATH="$MPI_ROOT/lib:${LD_LIBRARY_PATH}"
ARG _BUILD_OMPI_VERSION=4.0.3
ENV _BUILD_OMPI_VERSION=${_BUILD_OMPI_VERSION}
ARG _BUILD_OMPI_BASE_VERSION=4.0
ENV _BUILD_OMPI_BASE_VERSION=${_BUILD_OMPI_BASE_VERSION}
# Testing a release tarball of OMPI
RUN cd /opt/hpc/local/build && \
wget -q https://download.open-mpi.org/release/open-mpi/v${_BUILD_OMPI_BASE_VERSION}/openmpi-${_BUILD_OMPI_VERSION}.tar.gz && \
tar -zxf openmpi-${_BUILD_OMPI_VERSION}.tar.gz && \
cd openmpi-${_BUILD_OMPI_VERSION} && \
./configure --prefix=${MPI_ROOT} \
--with-hwloc=${HWLOC_INSTALL_PATH} \
--with-libevent=${LIBEVENT_INSTALL_PATH} \
--with-pmix=${PMIX_ROOT} \
--enable-mpirun-prefix-by-default 2>&1 | tee configure.log.$$ 2>&1 && \
make -j 10 2>&1 | tee make.log.$$ 2>&1 && \
make install 2>&1 | tee make.install.log.$$ 2>&1
# ------------------------------------------------------------
# Flush but keep the build directory
# - We will mount in the pmix/prrte/ompi source in there
# ------------------------------------------------------------
RUN rm -rf /opt/hpc/local/build && mkdir -p /opt/hpc/local/build
# ------------------------------------------------------------
# Copy in an MPI test program
# ------------------------------------------------------------
RUN mkdir -p /opt/hpc/examples && chmod og+rwX /opt/hpc/examples && \
mkdir -p /opt/hpc/etc && chmod og+rwX /opt/hpc/etc
COPY tests /opt/hpc/examples
RUN cd /opt/hpc/examples && make
# ------------------------------------------------------------
# Fixup the ssh login
# ------------------------------------------------------------
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N "" && \
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N "" && \
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" && \
echo " LogLevel ERROR" >> /etc/ssh/ssh_config && \
echo " StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
echo " UserKnownHostsFile=/dev/null" >> /etc/ssh/ssh_config
# ------------------------------------------------------------
# Adjust default ulimit for core files
# ------------------------------------------------------------
RUN echo '* hard core -1' >> /etc/security/limits.conf && \
echo '* soft core -1' >> /etc/security/limits.conf && \
echo 'ulimit -c unlimited' >> /root/.bashrc
# ------------------------------------------------------------
# Create a user account
# ------------------------------------------------------------
RUN groupadd -r mpiuser && useradd --no-log-init -r -m -b /home -g mpiuser -G wheel mpiuser
USER mpiuser
RUN cd /home/mpiuser && \
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa && chmod og+rX . && \
cd .ssh && cat id_rsa.pub > authorized_keys && chmod 644 authorized_keys && \
exit
# ------------------------------------------------------------
# Give the user passwordless sudo powers
# ------------------------------------------------------------
USER root
RUN echo "mpiuser ALL = NOPASSWD: ALL" >> /etc/sudoers
# ------------------------------------------------------------
# Adjust the default environment
# ------------------------------------------------------------
USER root
ENV PRRTE_MCA_prrte_default_hostfile=/opt/hpc/etc/hostfile.txt
# Need to do this so that the 'mpiuser' can have them too, not just root
RUN echo "export PMIX_ROOT=/opt/hpc/external/pmix" >> /etc/bashrc && \
echo "export PRRTE_ROOT=/opt/hpc/external/prrte" >> /etc/bashrc && \
echo "export MPI_ROOT=/opt/hpc/external/ompi" >> /etc/bashrc && \
echo "export PATH=\$MPI_ROOT/bin:\$PATH" >> /etc/bashrc && \
echo "export PATH=\$PRRTE_ROOT/bin:\$MPI_ROOT/bin:\$PATH" >> /etc/bashrc && \
echo "export LD_LIBRARY_PATH=\$MPI_ROOT/lib:\$LD_LIBRARY_PATH" >> /etc/bashrc && \
echo "export LD_LIBRARY_PATH=\$PMIX_ROOT/lib:\$LD_LIBRARY_PATH" >> /etc/bashrc && \
echo "export LD_LIBRARY_PATH=$HWLOC_INSTALL_PATH/lib:$LIBEVENT_INSTALL_PATH/lib:\$LD_LIBRARY_PATH" >> /etc/bashrc && \
echo "export LD_LIBRARY_PATH=\$PRRTE_ROOT/lib:\$LD_LIBRARY_PATH" >> /etc/bashrc && \
echo "export PRRTE_MCA_prrte_default_hostfile=$PRRTE_MCA_prrte_default_hostfile" >> /etc/bashrc && \
echo "export LIBEVENT_INSTALL_PATH=/opt/hpc/local/libevent" >> /etc/bashrc && \
echo "export HWLOC_INSTALL_PATH=/opt/hpc/local/hwloc" >> /etc/bashrc && \
echo "ulimit -c unlimited" >> /etc/bashrc && \
echo "alias pd=pushd" >> /etc/bashrc
# ------------------------------------------------------------
# Kick off the ssh daemon
# ------------------------------------------------------------
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]