diff --git a/.gitignore b/.gitignore index a6692a457..5dfe84d50 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,12 @@ _output/ bin/ profile.cov + +# Folders that don't influence the controller binaries +.github/ +deploy/ +examples/ +hack/ +manifests/ +proposals/ +sdk/ diff --git a/Makefile b/Makefile index eff825290..c54f9d501 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,12 @@ images: .PHONY: test_images test_images: + ${IMG_BUILDER} build -t mpioperator/base examples/base + ${IMG_BUILDER} build -t mpioperator/openmpi examples/base -f examples/base/openmpi.Dockerfile + ${IMG_BUILDER} build -t mpioperator/openmpi-builder examples/base -f examples/base/openmpi-builder.Dockerfile ${IMG_BUILDER} build -t mpioperator/mpi-pi:openmpi examples/pi + ${IMG_BUILDER} build -t mpioperator/intel examples/base -f examples/base/intel.Dockerfile + ${IMG_BUILDER} build -t mpioperator/intel-builder examples/base -f examples/base/intel-builder.Dockerfile ${IMG_BUILDER} build -t mpioperator/mpi-pi:intel examples/pi -f examples/pi/intel.Dockerfile .PHONY: tidy diff --git a/examples/base/Dockerfile b/examples/base/Dockerfile new file mode 100644 index 000000000..bc6692ae3 --- /dev/null +++ b/examples/base/Dockerfile @@ -0,0 +1,24 @@ +FROM debian:buster + +RUN apt update && apt install -y --no-install-recommends \ + openssh-server \ + openssh-client \ + && rm -rf /var/lib/apt/lists/* +# Add priviledge separation directoy to run sshd as root. +RUN mkdir -p /var/run/sshd +# Add capability to run sshd as non-root. +RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/sshd + +# Allow OpenSSH to talk to containers without asking for confirmation +# by disabling StrictHostKeyChecking. +# mpi-operator mounts the .ssh folder from a Secret. For that to work, we need +# to disable UserKnownHostsFile to avoid write permissions. +# Disabling StrictModes avoids directory and files read permission checks. +RUN sed -i 's/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g' /etc/ssh/ssh_config \ + && echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config \ + && sed -i 's/#\(StrictModes \).*/\1no/g' /etc/ssh/sshd_config + +RUN useradd -m mpiuser +WORKDIR /home/mpiuser +# Configurations for running sshd as non-root. +COPY --chown=mpiuser sshd_config .sshd_config diff --git a/examples/base/intel-builder.Dockerfile b/examples/base/intel-builder.Dockerfile new file mode 100644 index 000000000..ed798bd1e --- /dev/null +++ b/examples/base/intel-builder.Dockerfile @@ -0,0 +1,24 @@ +FROM bash AS downloader + +RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB -O key.PUB + +FROM debian:buster + +COPY --from=downloader key.PUB /tmp/key.PUB + +# Install Intel oneAPI keys. +RUN apt update \ + && apt install -y --no-install-recommends gnupg2 ca-certificates \ + && apt-key add /tmp/key.PUB \ + && rm /tmp/key.PUB \ + && echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list \ + && apt remove -y gnupg2 ca-certificates \ + && apt autoremove -y \ + && apt update \ + && apt install -y --no-install-recommends \ + libstdc++-8-dev binutils \ + intel-oneapi-compiler-dpcpp-cpp \ + intel-oneapi-mpi-devel \ + && rm -rf /var/lib/apt/lists/* + +ENV I_MPI_CC=clang I_MPI_CXX=clang++ diff --git a/examples/pi/intel-entrypoint.sh b/examples/base/intel-entrypoint.sh similarity index 100% rename from examples/pi/intel-entrypoint.sh rename to examples/base/intel-entrypoint.sh diff --git a/examples/base/intel.Dockerfile b/examples/base/intel.Dockerfile new file mode 100644 index 000000000..f527777a0 --- /dev/null +++ b/examples/base/intel.Dockerfile @@ -0,0 +1,25 @@ +FROM bash AS downloader + +RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB -O key.PUB + + +FROM mpioperator/base + +COPY --from=downloader key.PUB /tmp/key.PUB + +# Install Intel oneAPI keys. +RUN apt update \ + && apt install -y --no-install-recommends gnupg2 ca-certificates \ + && apt-key add /tmp/key.PUB \ + && rm /tmp/key.PUB \ + && echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list \ + && apt remove -y gnupg2 ca-certificates \ + && apt autoremove -y \ + && apt update \ + && apt install -y --no-install-recommends \ + dnsutils \ + intel-oneapi-mpi \ + && rm -rf /var/lib/apt/lists/* + +COPY intel-entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/examples/base/openmpi-builder.Dockerfile b/examples/base/openmpi-builder.Dockerfile new file mode 100644 index 000000000..d4145a84c --- /dev/null +++ b/examples/base/openmpi-builder.Dockerfile @@ -0,0 +1,6 @@ +FROM debian:buster as builder + +RUN apt update && apt install -y --no-install-recommends \ + g++ \ + libopenmpi-dev \ + && rm -rf /var/lib/apt/lists/* diff --git a/examples/base/openmpi.Dockerfile b/examples/base/openmpi.Dockerfile new file mode 100644 index 000000000..7189ca65a --- /dev/null +++ b/examples/base/openmpi.Dockerfile @@ -0,0 +1,5 @@ +FROM mpioperator/base + +RUN apt update && \ + apt install -y --no-install-recommends openmpi-bin && \ + rm -rf /var/lib/apt/lists/* diff --git a/examples/pi/sshd_config b/examples/base/sshd_config similarity index 100% rename from examples/pi/sshd_config rename to examples/base/sshd_config diff --git a/examples/pi/Dockerfile b/examples/pi/Dockerfile index 684cfd211..4506f8a8e 100644 --- a/examples/pi/Dockerfile +++ b/examples/pi/Dockerfile @@ -1,35 +1,9 @@ -FROM debian:buster as builder - -RUN apt update && apt install -y --no-install-recommends \ - g++ \ - libopenmpi-dev \ - && rm -rf /var/lib/apt/lists/* +FROM mpioperator/openmpi-builder as builder COPY pi.cc /src/pi.cc RUN mpic++ /src/pi.cc -o /pi -FROM debian:buster - -RUN apt update && apt install -y --no-install-recommends \ - openmpi-bin \ - openssh-server \ - openssh-client \ - && rm -rf /var/lib/apt/lists/* -# Add priviledge separation directoy to run sshd as root. -RUN mkdir -p /var/run/sshd -# Add capability to run sshd as non-root. -RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/sshd +FROM mpioperator/openmpi -RUN useradd -m mpiuser -WORKDIR /home/mpiuser -COPY --chown=mpiuser sshd_config .sshd_config -# Allow OpenSSH to talk to containers without asking for confirmation -# by disabling StrictHostKeyChecking. -# mpi-operator mounts the .ssh folder from a Secret. For that to work, we need -# to disable UserKnownHostsFile to avoid write permissions. -# Disabling StrictModes avoids directory and files read permission checks. -RUN sed -i 's/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g' /etc/ssh/ssh_config && \ - echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config && \ - sed -i 's/#\(StrictModes \).*/\1no/g' /etc/ssh/sshd_config COPY --from=builder /pi /home/mpiuser/pi \ No newline at end of file diff --git a/examples/pi/intel.Dockerfile b/examples/pi/intel.Dockerfile index 75e4ab7bd..5aa8dfe44 100644 --- a/examples/pi/intel.Dockerfile +++ b/examples/pi/intel.Dockerfile @@ -1,64 +1,9 @@ -FROM bash AS downloader +FROM mpioperator/intel-builder as builder -RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB -O key.PUB - - -FROM debian:buster as base - -COPY --from=downloader key.PUB /tmp/key.PUB - -# Install Intel oneAPI keys. -RUN apt update \ - && apt install -y --no-install-recommends gnupg2 ca-certificates \ - && apt-key add /tmp/key.PUB \ - && rm /tmp/key.PUB \ - && echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list \ - && apt remove -y gnupg2 ca-certificates \ - && apt autoremove -y \ - && rm -rf /var/lib/apt/lists/* - - -FROM base as builder - -RUN apt update \ - && apt install -y --no-install-recommends \ - libstdc++-8-dev binutils \ - intel-oneapi-compiler-dpcpp-cpp \ - intel-oneapi-mpi-devel \ - && rm -rf /var/lib/apt/lists/* - -ENV I_MPI_CC=clang I_MPI_CXX=clang++ COPY pi.cc /src/pi.cc RUN bash -c "source /opt/intel/oneapi/setvars.sh && mpicxx /src/pi.cc -o /pi" -FROM base - -RUN apt update \ - && apt install -y --no-install-recommends \ - openssh-server \ - openssh-client \ - dnsutils \ - intel-oneapi-mpi \ - && rm -rf /var/lib/apt/lists/* - -# Add priviledge separation directoy to run sshd as root. -RUN mkdir -p /var/run/sshd -# Add capability to run sshd as non-root. -RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/sshd - -RUN useradd -m mpiuser -WORKDIR /home/mpiuser -COPY intel-entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] -COPY --chown=mpiuser sshd_config .sshd_config -# Allow OpenSSH to talk to containers without asking for confirmation -# by disabling StrictHostKeyChecking. -# mpi-operator mounts the .ssh folder from a Secret. For that to work, we need -# to disable UserKnownHostsFile to avoid write permissions. -# Disabling StrictModes avoids directory and files read permission checks. -RUN sed -i 's/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g' /etc/ssh/ssh_config && \ - echo " UserKnownHostsFile /dev/null" >> /etc/ssh/ssh_config && \ - sed -i 's/#\(StrictModes \).*/\1no/g' /etc/ssh/sshd_config +FROM mpioperator/intel COPY --from=builder /pi /home/mpiuser/pi \ No newline at end of file