-
Notifications
You must be signed in to change notification settings - Fork 25
/
Dockerfile
65 lines (53 loc) · 2.13 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
ARG UBUNTU_BASED_BASE_IMAGE
FROM $UBUNTU_BASED_BASE_IMAGE
MAINTAINER Shingo OMURA <https://github.com/everpeace>
ARG OPENMPI_VERSION
ARG WITH_CUDA="false"
# Disable prompts from apt.
ENV DEBIAN_FRONTEND noninteractive
# install ssh and basic dependencies
RUN apt-get update && \
apt-get install -yq --no-install-recommends \
locales wget ca-certificates ssh build-essential && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
#
# install openmpi
#
RUN echo "WITH_CUDA=$WITH_CUDA"
RUN cd /tmp && \
wget -q https://www.open-mpi.org/software/ompi/v$(echo $OPENMPI_VERSION | sed -e s'/\(.*\)\.[0-9]/\1/')/downloads/openmpi-$OPENMPI_VERSION.tar.bz2 && \
tar -xjf openmpi-$OPENMPI_VERSION.tar.bz2 && \
cd /tmp/openmpi-$OPENMPI_VERSION && \
if [ "$WITH_CUDA" = "true" ]; then export WITH_CUDA_OPT="--with-cuda"; else export WITH_CUDA_OPT=""; fi && \
echo "WITH_CUDA_OPT=$WITH_CUDA_OPT" && \
./configure --prefix=/usr $WITH_CUDA_OPT && \
make -j2 && \
make install && \
rm -r /tmp/openmpi-$OPENMPI_VERSION
# Create ssh user(openmpi) and setup ssh key dir
# - ssh identity file and authorized key file is expected to
# be mounted at /ssh-keys/$SSH_USER
ARG SSH_USER=openmpi
ENV SSH_USER=$SSH_USER
ARG SSH_UID=1000
ARG SSH_GID=1000
RUN addgroup --gid $SSH_GID $SSH_USER
RUN adduser -q --gecos "" --disabled-password --uid $SSH_UID --gid $SSH_GID $SSH_USER
RUN mkdir -p /ssh-key/$SSH_USER && chown -R $SSH_USER:$SSH_USER /ssh-key/$SSH_USER
RUN mkdir -p /.sshd/host_keys && \
chown -R $SSH_USER:$SSH_USER /.sshd/host_keys && chmod 700 /.sshd/host_keys
RUN mkdir -p /.sshd/user_keys/$SSH_USER && \
chown -R $SSH_USER:$SSH_USER /.sshd/user_keys/$SSH_USER && chmod 700 /.sshd/user_keys/$SSH_USER
VOLUME /ssh-key/$SSH_USER
ARG HOME=/home/$SSH_USER
RUN mkdir -p $HOME && chown $SSH_USER:$SSH_USER $HOME && chmod 755 $HOME
VOLUME $HOME
COPY rootfs /
# check if open mpi was successfully built with cuda support.
RUN if [ "$WITH_CUDA" = "true" ]; then \
if ! ompi_info --parsable --all | grep -q "mpi_built_with_cuda_support:value:true" ; then \
exit 1; \
fi; fi;
EXPOSE 2022
# sshd can be run either by root or $SSH_USER
CMD ["/init.sh"]