Dockerfile 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. FROM debian:bullseye-slim
  2. # an image with OpenMPI4.1, used without root privileges for sshd
  3. # XMP and telegraf
  4. # ------------------------------------------------------------
  5. # Do basic install
  6. # ------------------------------------------------------------
  7. RUN apt-get update \
  8. && mkdir -p /usr/share/man/man1 \
  9. && apt-get install -y gcc ssh wget vim curl net-tools bison flex openjdk-11-jdk-headless autoconf make libtool m4 automake bzip2 libxml2 libxml2-dev gfortran g++ iputils-ping pkg-config colordiff nano git sudo lsof gawk emacs jq neofetch libtdl* astyle cmake gdb strace binutils-dev dnsutils netcat libgomp1 googletest supervisor \
  10. && adduser --uid 1000 --home /home/mpiuser --shell /bin/bash \
  11. --disabled-password --gecos '' mpiuser \
  12. && passwd -d mpiuser \
  13. && apt-get install -y openssh-server \
  14. && mkdir -p /run/sshd /home/mpiuser/.ssh /home/mpiuser/.ssh-source \
  15. && echo "StrictHostKeyChecking no" > /home/mpiuser/.ssh/config \
  16. && chown -R mpiuser /home/mpiuser \
  17. && sed -i s/#PermitRootLogin.*/PermitRootLogin\ no/ /etc/ssh/sshd_config \
  18. && sed -i s/#PubkeyAuthentication.*/PubkeyAuthentication\ no/ /etc/ssh/sshd_config \
  19. && sed -i s/.*UsePAM.*/UsePAM\ no/ /etc/ssh/sshd_config \
  20. && sed -i s/#PasswordAuthentication.*/PasswordAuthentication\ yes/ /etc/ssh/sshd_config \
  21. && sed -i s/#PermitEmptyPasswords.*/PermitEmptyPasswords\ yes/ /etc/ssh/sshd_config \
  22. && sed -i s/#ChallengeResponse.*/ChallengeResponseAuthentication\ no/ /etc/ssh/sshd_config \
  23. && sed -i s/#PermitUserEnvironment.*/PermitUserEnvironment\ yes/ /etc/ssh/sshd_config \
  24. && adduser mpiuser sudo
  25. ENV PREFIX=/usr/local \
  26. OPENMPI_VERSION=4.1.4 \
  27. LD_LIBRARY_PATH=/usr/local/lib \
  28. DEBCONF_NOWARNINGS=yes
  29. # ------------------------------------------------------------
  30. # Install OpenMPI 4.1
  31. # https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.4.tar.gz
  32. # ------------------------------------------------------------
  33. # OpenMPI v4.1
  34. RUN repo="https://download.open-mpi.org/release/open-mpi/v4.1" \
  35. && curl --location --silent --show-error --output openmpi.tar.gz \
  36. "${repo}/openmpi-${OPENMPI_VERSION}.tar.gz" \
  37. && tar xzf openmpi.tar.gz -C /tmp/ \
  38. && cd /tmp/openmpi-${OPENMPI_VERSION} \
  39. && env CFLAGS="-O2 -std=gnu99 -fopenmp" \
  40. && ./configure --prefix=${PREFIX} \
  41. && make \
  42. && make install \
  43. && ldconfig \
  44. && cd / \
  45. && rm -rf /tmp/openmpi-${OPENMPI_VERSION} /home/mpiuser/openmpi.tar.gz
  46. # ------------------------------------------------------------
  47. # Add some parameters for MPI, mpishare - a folder shared through the nodes
  48. # ------------------------------------------------------------
  49. RUN mkdir -p /usr/local/var/mpishare
  50. RUN chown -R 1000:1000 /usr/local/var/mpishare
  51. RUN echo "mpiuser ALL=(ALL) NOPASSWD:ALL\n" >> /etc/sudoers
  52. RUN rm -fr /home/mpiuser/.openmpi && mkdir -p /home/mpiuser/.openmpi
  53. RUN cd /home/mpiuser/.openmpi \
  54. && echo "btl = tcp,self \n" \
  55. "btl_tcp_if_include = eth0 \n" \
  56. "plm_rsh_no_tree_spawn = 1 \n" >> default-mca-params.conf
  57. RUN chown -R 1000:1000 /home/mpiuser/.openmpi
  58. RUN echo "rmaps_base_oversubscribe = 1\n" >> /usr/local/etc/openmpi-mca-params.conf
  59. RUN echo "rmaps_base_inherit = 1\n" >> /usr/local/etc/openmpi-mca-params.conf
  60. # ------------------------------------------------------------
  61. # Start mpi python install / user mpiuser
  62. # ------------------------------------------------------------
  63. RUN apt-get install -y --no-install-recommends python3-dev python3-numpy python3-pip python3-virtualenv python3-scipy 2to3 \
  64. && apt-get clean && apt-get purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  65. RUN pip install --upgrade pip
  66. # in order to have python related to mpiuser account
  67. USER mpiuser
  68. RUN pip install --user -U setuptools \
  69. && pip install --user mpi4py
  70. USER root
  71. # ------------------------------------------------------------
  72. # Copy MPI4PY example scripts
  73. # ------------------------------------------------------------
  74. ADD ./mpi4py_benchmarks /home/mpiuser/mpi4py_benchmarks
  75. RUN chown -R mpiuser:mpiuser /home/mpiuser/mpi4py_benchmarks
  76. RUN cd /home/mpiuser/mpi4py_benchmarks && 2to3 -w --no-diffs *.py
  77. # ------------------------------------------------------------
  78. # Load omni-compiler 1.3.4 from a public repo
  79. # ------------------------------------------------------------
  80. RUN mkdir -p /home/mpiuser/YMLEnvironment
  81. WORKDIR /home/mpiuser/YMLEnvironment
  82. RUN wget --no-check-certificate --content-disposition https://omni-compiler.org/download/stable/omnicompiler-1.3.4.tar.bz2
  83. RUN bunzip2 omnicompiler-1.3.4.tar.bz2 \
  84. && tar xvf omnicompiler-1.3.4.tar \
  85. && rm /home/mpiuser/YMLEnvironment/omnicompiler-1.3.4.tar
  86. # ------------------------------------------------------------
  87. # Install omnicompiler-1.3.4 : requested javac
  88. # ------------------------------------------------------------
  89. WORKDIR /home/mpiuser/YMLEnvironment/omnicompiler-1.3.4
  90. RUN cd /home/mpiuser/YMLEnvironment/omnicompiler-1.3.4 \
  91. && export FCFLAGS="-w -fallow-argument-mismatch -O2" \
  92. && export FFLAGS="-w -fallow-argument-mismatch -O2" \
  93. && export MPI_FCFLAGS="-fopenmp -fallow-argument-mismatch -O2" \
  94. && export CPPFLAGS="-fallow-argument-mismatch -DOMNI_CPU_X86_64 -DOMNI_OS_LINUX -DGNU_SOURCE -D_REENTRANT" \
  95. && ./configure --prefix=${PREFIX} --with-libxml2=/usr \
  96. && make && make install && make clean && ldconfig
  97. # ------------------------------------------------------------
  98. # Install test-spawn-xmp
  99. # ------------------------------------------------------------
  100. USER mpiuser
  101. COPY test-spawn-xmp /home/mpiuser/YMLEnvironment/test-spawn-xmp
  102. USER root
  103. RUN chown -R mpiuser:mpiuser /home/mpiuser/YMLEnvironment
  104. # ------------------------------------------------------------
  105. # Install telegraf
  106. # ------------------------------------------------------------
  107. RUN apt-get update && apt-get install -y --no-install-recommends gpgv ca-certificates apt-transport-https gnupg lsb-release
  108. RUN wget -qO- https://repos.influxdata.com/influxdb.key | apt-key add -
  109. RUN echo "deb https://repos.influxdata.com/debian $(lsb_release -cs) stable"| tee /etc/apt/sources.list.d/influxdb.list
  110. RUN apt-get update && apt-get install -y --no-install-recommends telegraf && apt-get clean && apt-get purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  111. # ------------------------------------------------------------
  112. # The .ssh-source dir contains RSA keys - put in place with docker-compose
  113. # ------------------------------------------------------------
  114. RUN touch /home/mpiuser/.ssh-source/authorized_keys
  115. RUN touch /home/mpiuser/.ssh-source/id_rsa
  116. # ------------------------------------------------------------
  117. # Do SSHd parameter to enable mpiuser to run it
  118. # ------------------------------------------------------------
  119. RUN sed -i s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation\ no/ /etc/ssh/sshd_config
  120. RUN mkdir -p /home/mpiuser/ssh
  121. RUN ssh-keygen -q -N "" -t dsa -f /home/mpiuser/ssh/ssh_host_dsa_key \
  122. && ssh-keygen -q -N "" -t rsa -b 4096 -f /home/mpiuser/ssh/ssh_host_rsa_key \
  123. && ssh-keygen -q -N "" -t ecdsa -f /home/mpiuser/ssh/ssh_host_ecdsa_key \
  124. && ssh-keygen -q -N "" -t ed25519 -f /home/mpiuser/ssh/ssh_host_ed25519_key
  125. RUN cp /etc/ssh/sshd_config /home/mpiuser/ssh/
  126. RUN sed -i s/#HostKey\ \\/etc\\/ssh/HostKey\ \\/home\\/mpiuser\\/ssh/ /home/mpiuser/ssh/sshd_config
  127. RUN sed -i s/#PidFile\ \\/var\\/run/PidFile\ \\/home\\/mpiuser\\/ssh/ /home/mpiuser/ssh/sshd_config
  128. RUN sed -i s/#LogLevel.*/LogLevel\ DEBUG3/ /home/mpiuser/ssh/sshd_config
  129. RUN sed -i s/PubkeyAuthentication\ no/PubkeyAuthentication\ yes/ /home/mpiuser/ssh/sshd_config
  130. RUN chown -R mpiuser:mpiuser /home/mpiuser/ssh
  131. # ------------------------------------------------------------
  132. # supervisord to run entrypoint
  133. # ------------------------------------------------------------
  134. COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
  135. # ------------------------------------------------------------
  136. # telegraf to run entrypoint
  137. # ------------------------------------------------------------
  138. COPY telegraf.conf /etc/telegraf/telegraf.conf
  139. EXPOSE 22 80 8125
  140. WORKDIR /home/mpiuser
  141. CMD cp -R /home/mpiuser/.ssh-source/* /home/mpiuser/.ssh \
  142. && chmod 700 /home/mpiuser/.ssh/authorized_keys \
  143. && chmod 700 /home/mpiuser/.ssh/id_rsa \
  144. && chown -R mpiuser:mpiuser /home/mpiuser/.ssh \
  145. && exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
  146. # && exec /usr/sbin/sshd -D -f /home/mpiuser/ssh/sshd_config -E /tmp/sshd.log
  147. # do not detach (-D), log to stderr (-e)
  148. # CMD ["/usr/sbin/sshd", "-D", "-e"]