From e816b66c94410103e3f208f50b63d674599e27c2 Mon Sep 17 00:00:00 2001 From: Omar Padron Date: Tue, 16 Jun 2020 14:11:13 -0400 Subject: fix docker image entrypoints (#17105) Also removes extraneous prompt and ssh handling logic. --- share/spack/docker/centos-6.dockerfile | 74 ++++++------- share/spack/docker/centos-7.dockerfile | 74 ++++++------- share/spack/docker/entrypoint.bash | 160 +++++++++++++++++++++------ share/spack/docker/handle-prompt.sh | 173 ------------------------------ share/spack/docker/handle-ssh.sh | 50 --------- share/spack/docker/ubuntu-1604.dockerfile | 87 ++++++--------- share/spack/docker/ubuntu-1804.dockerfile | 87 ++++++--------- 7 files changed, 269 insertions(+), 436 deletions(-) delete mode 100644 share/spack/docker/handle-prompt.sh delete mode 100644 share/spack/docker/handle-ssh.sh (limited to 'share') diff --git a/share/spack/docker/centos-6.dockerfile b/share/spack/docker/centos-6.dockerfile index 72aa934f99..fe919f3c88 100644 --- a/share/spack/docker/centos-6.dockerfile +++ b/share/spack/docker/centos-6.dockerfile @@ -16,46 +16,42 @@ COPY share $SPACK_ROOT/share COPY var $SPACK_ROOT/var RUN mkdir -p $SPACK_ROOT/opt/spack -RUN yum update -y \ - && yum install -y epel-release \ - && yum update -y \ +RUN ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/docker-shell \ + && ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/interactive-shell \ + && ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/spack-env + +RUN yum update -y \ + && yum install -y epel-release \ + && yum update -y \ && yum --enablerepo epel groupinstall -y "Development Tools" \ - && yum --enablerepo epel install -y \ - curl findutils gcc-c++ gcc \ - gcc-gfortran git gnupg2 hostname \ - iproute Lmod make patch \ - openssh-server python python-pip tcl \ - unzip which \ - && pip install boto3 \ - && rm -rf /var/cache/yum \ + && yum --enablerepo epel install -y \ + curl \ + findutils \ + gcc-c++ \ + gcc \ + gcc-gfortran \ + git \ + gnupg2 \ + hostname \ + iproute \ + Lmod \ + make \ + patch \ + python \ + python-pip \ + tcl \ + unzip \ + which \ + && pip install boto3 \ + && rm -rf /var/cache/yum \ && yum clean all -RUN ( echo ". /usr/share/lmod/lmod/init/bash" \ - && echo ". \$SPACK_ROOT/share/spack/setup-env.sh" \ - && echo "if [ \"\$CURRENTLY_BUILDING_DOCKER_IMAGE\" '!=' '1' ]" \ - && echo "then" \ - && echo " . \$SPACK_ROOT/share/spack/spack-completion.bash" \ - && echo "fi" ) \ - >> /etc/profile.d/spack.sh \ - && ( echo "f=\"\$SPACK_ROOT/share/spack/docker/handle-ssh.sh\"" \ - && echo "if [ -f \"\$f\" ]" \ - && echo "then" \ - && echo " . \"\$f\"" \ - && echo "else" \ - && cat $SPACK_ROOT/share/spack/docker/handle-ssh.sh \ - && echo "fi" ) \ - >> /etc/profile.d/handle-ssh.sh \ - && ( echo "f=\"\$SPACK_ROOT/share/spack/docker/handle-prompt.sh\"" \ - && echo "if [ -f \"\$f\" ]" \ - && echo "then" \ - && echo " . \"\$f\"" \ - && echo "else" \ - && cat $SPACK_ROOT/share/spack/docker/handle-prompt.sh \ - && echo "fi" ) \ - >> /etc/profile.d/handle-prompt.sh \ - && mkdir -p /root/.spack \ - && cp $SPACK_ROOT/share/spack/docker/modules.yaml \ - /root/.spack/modules.yaml \ +RUN mkdir -p /root/.spack \ + && cp $SPACK_ROOT/share/spack/docker/modules.yaml \ + /root/.spack/modules.yaml \ && rm -rf /root/*.* /run/nologin $SPACK_ROOT/.git # [WORKAROUND] @@ -66,10 +62,10 @@ RUN [ -f ~/.profile ] \ || true WORKDIR /root -SHELL ["/bin/bash", "-l", "-c"] +SHELL ["docker-shell"] # TODO: add a command to Spack that (re)creates the package cache RUN spack spec hdf5+mpi ENTRYPOINT ["/bin/bash", "/opt/spack/share/spack/docker/entrypoint.bash"] -CMD ["docker-shell"] +CMD ["interactive-shell"] diff --git a/share/spack/docker/centos-7.dockerfile b/share/spack/docker/centos-7.dockerfile index 6aa969fef8..67affa1af9 100644 --- a/share/spack/docker/centos-7.dockerfile +++ b/share/spack/docker/centos-7.dockerfile @@ -16,46 +16,42 @@ COPY share $SPACK_ROOT/share COPY var $SPACK_ROOT/var RUN mkdir -p $SPACK_ROOT/opt/spack -RUN yum update -y \ - && yum install -y epel-release \ - && yum update -y \ +RUN ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/docker-shell \ + && ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/interactive-shell \ + && ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/spack-env + +RUN yum update -y \ + && yum install -y epel-release \ + && yum update -y \ && yum --enablerepo epel groupinstall -y "Development Tools" \ - && yum --enablerepo epel install -y \ - curl findutils gcc-c++ gcc \ - gcc-gfortran git gnupg2 hostname \ - iproute Lmod make patch \ - openssh-server python python-pip tcl \ - unzip which \ - && pip install boto3 \ - && rm -rf /var/cache/yum \ + && yum --enablerepo epel install -y \ + curl \ + findutils \ + gcc-c++ \ + gcc \ + gcc-gfortran \ + git \ + gnupg2 \ + hostname \ + iproute \ + Lmod \ + make \ + patch \ + python \ + python-pip \ + tcl \ + unzip \ + which \ + && pip install boto3 \ + && rm -rf /var/cache/yum \ && yum clean all -RUN ( echo ". /usr/share/lmod/lmod/init/bash" \ - && echo ". \$SPACK_ROOT/share/spack/setup-env.sh" \ - && echo "if [ \"\$CURRENTLY_BUILDING_DOCKER_IMAGE\" '!=' '1' ]" \ - && echo "then" \ - && echo " . \$SPACK_ROOT/share/spack/spack-completion.bash" \ - && echo "fi" ) \ - >> /etc/profile.d/spack.sh \ - && ( echo "f=\"\$SPACK_ROOT/share/spack/docker/handle-ssh.sh\"" \ - && echo "if [ -f \"\$f\" ]" \ - && echo "then" \ - && echo " . \"\$f\"" \ - && echo "else" \ - && cat $SPACK_ROOT/share/spack/docker/handle-ssh.sh \ - && echo "fi" ) \ - >> /etc/profile.d/handle-ssh.sh \ - && ( echo "f=\"\$SPACK_ROOT/share/spack/docker/handle-prompt.sh\"" \ - && echo "if [ -f \"\$f\" ]" \ - && echo "then" \ - && echo " . \"\$f\"" \ - && echo "else" \ - && cat $SPACK_ROOT/share/spack/docker/handle-prompt.sh \ - && echo "fi" ) \ - >> /etc/profile.d/handle-prompt.sh \ - && mkdir -p /root/.spack \ - && cp $SPACK_ROOT/share/spack/docker/modules.yaml \ - /root/.spack/modules.yaml \ +RUN mkdir -p /root/.spack \ + && cp $SPACK_ROOT/share/spack/docker/modules.yaml \ + /root/.spack/modules.yaml \ && rm -rf /root/*.* /run/nologin $SPACK_ROOT/.git # [WORKAROUND] @@ -66,10 +62,10 @@ RUN [ -f ~/.profile ] \ || true WORKDIR /root -SHELL ["/bin/bash", "-l", "-c"] +SHELL ["docker-shell"] # TODO: add a command to Spack that (re)creates the package cache RUN spack spec hdf5+mpi ENTRYPOINT ["/bin/bash", "/opt/spack/share/spack/docker/entrypoint.bash"] -CMD ["docker-shell"] +CMD ["interactive-shell"] diff --git a/share/spack/docker/entrypoint.bash b/share/spack/docker/entrypoint.bash index 775747d904..fbd7baf2bc 100755 --- a/share/spack/docker/entrypoint.bash +++ b/share/spack/docker/entrypoint.bash @@ -1,45 +1,143 @@ -#! /usr/bin/env bash -e +#! /usr/bin/env bash # # Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -unset CURRENTLY_BUILDING_DOCKER_IMAGE +mode=oneshot -if [ "$1" '=' 'docker-shell' ] ; then - if [ -t 0 ] ; then - exec bash -il - else - ( - echo -n "It looks like you're trying to run an intractive shell" - echo -n " session, but either no psuedo-TTY is allocateed for this" - echo -n " container's STDIN, or it is closed." - echo +if [ "$( basename "$0" )" '=' 'spack-env' ] ; then + mode=spackenv +elif [ "$( basename "$0" )" '=' 'docker-shell' ] ; then + mode=dockershell +elif [ "$( basename "$0" )" '=' 'interactive-shell' ] ; then + mode=interactiveshell +elif [ "$1" '=' 'docker-shell' ] ; then + mode=dockershell + shift +elif [ "$1" '=' 'interactive-shell' ] ; then + mode=interactiveshell + shift +fi - echo -n "Make sure you run docker with the --interactive and --tty" - echo -n " options." - echo - ) >&2 +case "$mode" in + "spackenv") + # Scenario 1: Run as if the image had no ENTRYPOINT + # + # Necessary for use cases where the command to run and all + # arguments must be accepted in the CMD portion. (e.g.: Gitlab CI + # Runners) + # + # Roughly equivalent to + # docker run ... --entrypoint spack-env ... sh -c "..." + # + # The shell script runs with spack pre-loaded and ready to use. + . $SPACK_ROOT/share/spack/setup-env.sh + unset CURRENTLY_BUILDING_DOCKER_IMAGE + exec "$@" + ;; - exit 1 - fi -else - exec 3>&1 - exec 4>&2 + "dockershell") + # Scenario 2: Accept shell code from a RUN command in a + # Dockerfile + # + # For new Docker images that start FROM this image as its base. + # Prepared so that subsequent RUN commands can take advantage of + # Spack without having to manually (re)initialize. + # + # Example: + # FROM spack/centos7 + # COPY spack.yaml . + # RUN spack install # <- Spack is loaded and ready to use. + # # No manual initialization necessary. + . $SPACK_ROOT/share/spack/setup-env.sh + exec bash -c "$*" + ;; - exec 1>&- - exec 2>&- + "interactiveshell") + # Scenario 3: Run an interactive shell session with Spack + # preloaded. + # + # Create a container meant for an interactive shell session. + # Additional checks are performed to ensure that stdin is a tty + # and additional shell completion files are sourced. The user is + # presented with a shell prompt from which they may issue Spack + # commands. + # + # This is the default behavior when running with no CMD or + # ENTRYPOINT overrides: + # docker run -it spack/centos7 + if [ -t 0 ] ; then + . $SPACK_ROOT/share/spack/setup-env.sh + . $SPACK_ROOT/share/spack/spack-completion.bash + unset CURRENTLY_BUILDING_DOCKER_IMAGE + exec bash -i + else + ( + echo -n "It looks like you're trying to run an" + echo -n " intractive shell session, but either no" + echo -n " psuedo-TTY is allocated for this container's" + echo " STDIN, or it is closed." + echo - source /etc/profile.d/spack.sh - source /etc/profile.d/handle-ssh.sh + echo -n "Make sure you run docker with the --interactive" + echo -n " and --tty options." + echo + ) >&2 - exec 1>&3 - exec 2>&4 + exit 1 + fi + ;; - exec 3>&- - exec 4>&- + "oneshot") + # Scenario 4: Run a one-shot Spack command from the host command + # line. + # + # Triggered by providing arguments to `docker run`. Arguments + # are passed along to the container's underlying spack + # installation, allowing users to use the image as if it were + # spack, itself. Pass volume mount information to `docker run` + # to persist the effects of running in this mode. + # + # This is the default behavior when running with a CMD override. + # + # Examples: + # # concretize the same spec on different OSes + # docker run --rm spack/ubuntu-xenial spec zlib + # docker run --rm spack/centos7 spec zlib + # + # # a "wetter" dry-run; + # # install a package and then throw away the results. + # docker run --rm spack/centos7 install libiconv + # docker run --rm spack/centos7 find libiconv + # ==> No package matches the query: libiconv + # + # # use docker volumes to persist changes + # docker run --rm -v ...:/spack spack/centos7 install ... + # docker run --rm -v ...:/spack spack/centos7 install ... + # docker run --rm -v ...:/spack spack/centos7 install ... + exec 3>&1 + exec 4>&2 - spack "$@" - exit $? -fi + exec 1>&- + exec 2>&- + + . $SPACK_ROOT/share/spack/setup-env.sh + unset CURRENTLY_BUILDING_DOCKER_IMAGE + + exec 1>&3 + exec 2>&4 + + exec 3>&- + exec 4>&- + + spack "$@" + exit $? + ;; + + *) + echo "INTERNAL ERROR - UNRECOGNIZED MODE: $mode" >&2 + exit 1 + ;; +esac diff --git a/share/spack/docker/handle-prompt.sh b/share/spack/docker/handle-prompt.sh deleted file mode 100644 index a01047463e..0000000000 --- a/share/spack/docker/handle-prompt.sh +++ /dev/null @@ -1,173 +0,0 @@ -# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other -# Spack Project Developers. See the top-level COPYRIGHT file for details. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) - -if [ "$CURRENTLY_BUILDING_DOCKER_IMAGE" '!=' '1' ] ; then - -if [ x$SPACK_PROMPT '!=' x0 ] ; then - -__tmp="`mktemp -d`" - -__trylock() { - local dir - dir="$__tmp/$1.lock" - mkdir "$dir" &>/dev/null - return $? -} - -__queue_init() { - local r - local w - - mkdir "$__tmp/$1.read.lock" ; r=$? - mkdir "$__tmp/$1.write.lock" ; w=$? - - if [ "$r" '=' '0' -a "$w" '=' '0' ] ; then - return 0 - else - return 1 - fi -} - -__queue_try_read() { - __trylock "$1.read" - return $? -} - -__queue_try_write() { - __trylock "$1.write" - return $? -} - -__queue_make_readable() { - rm -r "$__tmp/$1.read.lock" &>/dev/null - return $? -} - -__queue_make_writable() { - rm -r "$__tmp/$1.write.lock" &>/dev/null - return $? -} - -__read() { - cat "$__tmp/$1" 2> /dev/null - return $? -} - -__write() { - cat > "$__tmp/$1" 2> /dev/null - return $? -} - -__revparse_head() { - head="`git -C "$SPACK_ROOT" rev-parse $@ HEAD 2>/dev/null`" - result="$?" - if [ "$result" '!=' '0' ] ; then - head="`git --git-dir="$SPACK_ROOT"/.git \\ - --work-tree="$SPACK_ROOT" rev-parse $@ HEAD 2>/dev/null`" - result="$?" - fi - - echo "$head" - return $result -} - -__git_head() { - head="`__revparse_head --abbrev-ref`" - if [ "$?" '=' '0' ] ; then - if [ "$head" '=' 'HEAD' ] ; then - head="`__revparse_head | cut -c1-8`..." - fi - - echo "$head" - fi -} - -__update_prompt() { - local prompt - prompt='' - linux_distro="$DOCKERFILE_DISTRO" - if [ -n "$linux_distro" ] ; then - linux_distro='\[\e[1;34m\][\[\e[0;34m\]'"$linux_distro"'\[\e[1;34m\]]' - if [ -n "$prompt" ] ; then - prompt="$prompt " - fi - prompt="$prompt$linux_distro" - fi - - git_head="`__git_head`" - - if [ -n "$git_head" ] ; then - git_head='\[\e[1;32m\](\[\e[0;32m\]'"$git_head"'\[\e[1;32m\])' - if [ -n "$prompt" ] ; then - prompt="$prompt " - fi - prompt="$prompt$git_head" - fi - - if [ -n "$prompt" ] ; then - prompt="$prompt " - fi - prompt="$prompt"'\[\e[0;m\]\W: ' - echo "$prompt" | __write prompt -} - -set -m -( - __queue_init query - __queue_init prompt - - __update_prompt - __queue_make_readable prompt - - __queue_make_writable query - - while sleep 0.010 ; do - last_q_time='' - - while sleep 0.010 ; do - q_time="`date +%s%N`" - if __queue_try_read query ; then - last_q_time="$q_time" - __queue_make_writable query - fi - - if [ -n "$last_q_time" -a \ - "$(( (q_time - last_q_time)/10000000 > 100 ))" '=' '1' ] ; then - break - fi - done - - __update_prompt - __queue_make_readable prompt - done -) &>/dev/null & -set +m - -__update_prompt_main_first_call=1 -__update_prompt_main() { - if [ "$__update_prompt_main_first_call" '=' '1' ] ; then - while sleep 0.001 ; do - if __queue_try_read prompt ; then - PS1="`__read prompt`" - break - fi - done - __update_prompt_main_first_call=0 - else - if __queue_try_read prompt ; then - PS1="`__read prompt`" - fi - fi - - if __queue_try_write query ; then - __queue_make_readable query - fi -} - -PROMPT_COMMAND=__update_prompt_main - -fi # [ x$SPACK_PROMPT '!=' x0 ] - -fi # [ "$CURRENTLY_BUILDING_DOCKER_IMAGE" '!=' '1' ] diff --git a/share/spack/docker/handle-ssh.sh b/share/spack/docker/handle-ssh.sh deleted file mode 100644 index 18e5ae259d..0000000000 --- a/share/spack/docker/handle-ssh.sh +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other -# Spack Project Developers. See the top-level COPYRIGHT file for details. -# -# SPDX-License-Identifier: (Apache-2.0 OR MIT) - -if [ "$CURRENTLY_BUILDING_DOCKER_IMAGE" '!=' '1' ] ; then - -uid="`id -u`" -if [ "$uid" '=' '0' ] ; then - key_types="dsa ecdsa rsa" - if [ "$DOCKERFILE_BASE" '!=' 'centos:6' ] ; then - key_types="${key_types} ed25519" - fi - - for key_type in $key_types ; do - private_key_file="/etc/ssh/ssh_host_${key_type}_key" - public_key_file="$private_key_file.pub" - - if [ '!' -f "$private_key_file" ] ; then - ssh-keygen \ - -q -t "$key_type" -N "" -f "$private_key_file" - chmod 600 "$private_key_file" - chmod 644 "$public_key_file" - fi - done - - mkdir -p /var/run/sshd - - pgrep -u 0 -U 0 sshd &> /dev/null - if [ '!' "$?" '=' '0' ] ; then - nohup /usr/sbin/sshd -f /etc/ssh/sshd_config < /dev/null &> /dev/null - fi -fi - -if [ '!' -f "$HOME/.ssh/id_rsa" ] ; then - ssh-keygen \ - -t rsa -C "spack.developer@docker.host" -N "" -f "$HOME/.ssh/id_rsa" - cat "$HOME/.ssh/id_rsa.pub" >> "$HOME/.ssh/authorized_keys" - chmod 600 "$HOME/.ssh/authorized_keys" - - docker_ip="`ip address show dev eth0 | - grep inet | - cut -d' ' -f 6 | - cut -d/ -f 1`" - - ssh-keyscan -t rsa 127.0.0.1 localhost "$docker_ip" "`hostname`" \ - > "$HOME/.ssh/known_hosts" 2> /dev/null -fi - -fi # [ "$CURRENTLY_BUILDING_DOCKER_IMAGE" '!=' '1' ] diff --git a/share/spack/docker/ubuntu-1604.dockerfile b/share/spack/docker/ubuntu-1604.dockerfile index e7a6783d24..7891c5a261 100644 --- a/share/spack/docker/ubuntu-1604.dockerfile +++ b/share/spack/docker/ubuntu-1604.dockerfile @@ -16,29 +16,35 @@ COPY share $SPACK_ROOT/share COPY var $SPACK_ROOT/var RUN mkdir -p $SPACK_ROOT/opt/spack -RUN apt-get -yqq update \ - && apt-get -yqq install --no-install-recommends \ - build-essential \ - ca-certificates \ - curl \ - file \ - g++ \ - gcc \ - gfortran \ - git \ - gnupg2 \ - iproute2 \ - lmod \ - locales \ - lua-posix \ - make \ - openssh-server \ - python3 \ - python3-pip \ - tcl \ - unzip \ - && locale-gen en_US.UTF-8 \ - && pip3 install boto3 \ +RUN ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/docker-shell \ + && ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/interactive-shell \ + && ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/spack-env + +RUN apt-get -yqq update \ + && apt-get -yqq install --no-install-recommends \ + build-essential \ + ca-certificates \ + curl \ + file \ + g++ \ + gcc \ + gfortran \ + git \ + gnupg2 \ + iproute2 \ + lmod \ + locales \ + lua-posix \ + make \ + python3 \ + python3-pip \ + tcl \ + unzip \ + && locale-gen en_US.UTF-8 \ + && pip3 install boto3 \ && rm -rf /var/lib/apt/lists/* # Add LANG default to en_US.UTF-8 @@ -46,33 +52,10 @@ ENV LANGUAGE en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LC_ALL en_US.UTF-8 -RUN ( echo ". /usr/share/lmod/lmod/init/bash" \ - && echo ". \$SPACK_ROOT/share/spack/setup-env.sh" \ - && echo "if [ \"\$CURRENTLY_BUILDING_DOCKER_IMAGE\" '!=' '1' ]" \ - && echo "then" \ - && echo " . \$SPACK_ROOT/share/spack/spack-completion.bash" \ - && echo "fi" ) \ - >> /etc/profile.d/spack.sh \ - && ( echo "f=\"\$SPACK_ROOT/share/spack/docker/handle-ssh.sh\"" \ - && echo "if [ -f \"\$f\" ]" \ - && echo "then" \ - && echo " . \"\$f\"" \ - && echo "else" \ - && cat $SPACK_ROOT/share/spack/docker/handle-ssh.sh \ - && echo "fi" ) \ - >> /etc/profile.d/handle-ssh.sh \ - && ( echo "f=\"\$SPACK_ROOT/share/spack/docker/handle-prompt.sh\"" \ - && echo "if [ -f \"\$f\" ]" \ - && echo "then" \ - && echo " . \"\$f\"" \ - && echo "else" \ - && cat $SPACK_ROOT/share/spack/docker/handle-prompt.sh \ - && echo "fi" ) \ - >> /etc/profile.d/handle-prompt.sh \ - && mkdir -p /root/.spack \ - && cp $SPACK_ROOT/share/spack/docker/modules.yaml \ - /root/.spack/modules.yaml \ - && rm -rf /root/*.* $SPACK_ROOT/.git +RUN mkdir -p /root/.spack \ + && cp $SPACK_ROOT/share/spack/docker/modules.yaml \ + /root/.spack/modules.yaml \ + && rm -rf /root/*.* /run/nologin $SPACK_ROOT/.git # [WORKAROUND] # https://superuser.com/questions/1241548/ @@ -82,10 +65,10 @@ RUN [ -f ~/.profile ] \ || true WORKDIR /root -SHELL ["/bin/bash", "-l", "-c"] +SHELL ["docker-shell"] # TODO: add a command to Spack that (re)creates the package cache RUN spack spec hdf5+mpi ENTRYPOINT ["/bin/bash", "/opt/spack/share/spack/docker/entrypoint.bash"] -CMD ["docker-shell"] +CMD ["interactive-shell"] diff --git a/share/spack/docker/ubuntu-1804.dockerfile b/share/spack/docker/ubuntu-1804.dockerfile index 5950908e1e..c079331476 100644 --- a/share/spack/docker/ubuntu-1804.dockerfile +++ b/share/spack/docker/ubuntu-1804.dockerfile @@ -16,29 +16,35 @@ COPY share $SPACK_ROOT/share COPY var $SPACK_ROOT/var RUN mkdir -p $SPACK_ROOT/opt/spack -RUN apt-get -yqq update \ - && apt-get -yqq install --no-install-recommends \ - build-essential \ - ca-certificates \ - curl \ - file \ - g++ \ - gcc \ - gfortran \ - git \ - gnupg2 \ - iproute2 \ - lmod \ - locales \ - lua-posix \ - make \ - openssh-server \ - python3 \ - python3-pip \ - tcl \ - unzip \ - && locale-gen en_US.UTF-8 \ - && pip3 install boto3 \ +RUN ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/docker-shell \ + && ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/interactive-shell \ + && ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ + /usr/local/bin/spack-env + +RUN apt-get -yqq update \ + && apt-get -yqq install --no-install-recommends \ + build-essential \ + ca-certificates \ + curl \ + file \ + g++ \ + gcc \ + gfortran \ + git \ + gnupg2 \ + iproute2 \ + lmod \ + locales \ + lua-posix \ + make \ + python3 \ + python3-pip \ + tcl \ + unzip \ + && locale-gen en_US.UTF-8 \ + && pip3 install boto3 \ && rm -rf /var/lib/apt/lists/* # Add LANG default to en_US.UTF-8 @@ -46,33 +52,10 @@ ENV LANGUAGE en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LC_ALL en_US.UTF-8 -RUN ( echo ". /usr/share/lmod/lmod/init/bash" \ - && echo ". \$SPACK_ROOT/share/spack/setup-env.sh" \ - && echo "if [ \"\$CURRENTLY_BUILDING_DOCKER_IMAGE\" '!=' '1' ]" \ - && echo "then" \ - && echo " . \$SPACK_ROOT/share/spack/spack-completion.bash" \ - && echo "fi" ) \ - >> /etc/profile.d/spack.sh \ - && ( echo "f=\"\$SPACK_ROOT/share/spack/docker/handle-ssh.sh\"" \ - && echo "if [ -f \"\$f\" ]" \ - && echo "then" \ - && echo " . \"\$f\"" \ - && echo "else" \ - && cat $SPACK_ROOT/share/spack/docker/handle-ssh.sh \ - && echo "fi" ) \ - >> /etc/profile.d/handle-ssh.sh \ - && ( echo "f=\"\$SPACK_ROOT/share/spack/docker/handle-prompt.sh\"" \ - && echo "if [ -f \"\$f\" ]" \ - && echo "then" \ - && echo " . \"\$f\"" \ - && echo "else" \ - && cat $SPACK_ROOT/share/spack/docker/handle-prompt.sh \ - && echo "fi" ) \ - >> /etc/profile.d/handle-prompt.sh \ - && mkdir -p /root/.spack \ - && cp $SPACK_ROOT/share/spack/docker/modules.yaml \ - /root/.spack/modules.yaml \ - && rm -rf /root/*.* $SPACK_ROOT/.git +RUN mkdir -p /root/.spack \ + && cp $SPACK_ROOT/share/spack/docker/modules.yaml \ + /root/.spack/modules.yaml \ + && rm -rf /root/*.* /run/nologin $SPACK_ROOT/.git # [WORKAROUND] # https://superuser.com/questions/1241548/ @@ -86,10 +69,10 @@ RUN [ -f ~/.profile ] \ RUN ln -s posix_c.so /usr/lib/x86_64-linux-gnu/lua/5.2/posix.so WORKDIR /root -SHELL ["/bin/bash", "-l", "-c"] +SHELL ["docker-shell"] # TODO: add a command to Spack that (re)creates the package cache RUN spack spec hdf5+mpi ENTRYPOINT ["/bin/bash", "/opt/spack/share/spack/docker/entrypoint.bash"] -CMD ["docker-shell"] +CMD ["interactive-shell"] -- cgit v1.2.3-60-g2f50