diff --git a/.github/workflows/everything.yml b/.github/workflows/everything.yml index 2a1664ca64..ffd43dacc4 100644 --- a/.github/workflows/everything.yml +++ b/.github/workflows/everything.yml @@ -227,9 +227,10 @@ jobs: - code: scorpio repo: E3SM-Project/scorpio ref: scorpio-v1.2.1 + defaults: run: - shell: bash -c "docker exec adios2-ci spack-named-env adios2 bash -e $(echo {0} | sed 's|/home/runner/work|/__w|g')" + shell: bash -c "docker exec adios2-ci bash --login -e $(echo {0} | sed 's|/home/runner/work|/__w|g')" steps: - uses: actions/checkout@v2 diff --git a/scripts/ci/images/spack/Dockerfile b/scripts/ci/images/spack/Dockerfile index 95936cc349..5bd4398d21 100644 --- a/scripts/ci/images/spack/Dockerfile +++ b/scripts/ci/images/spack/Dockerfile @@ -12,18 +12,22 @@ RUN spack dev-build \ spack clean -a # Build the environment -RUN spack env create adios2 && \ +RUN spack env create --without-view adios2 && \ spack -e adios2 add $(spack find --format "/{hash}") && \ spack -e adios2 install -v && \ rm -rf /root/.spack && \ spack env activate adios2 && \ - spack env deactivate + spack env deactivate && \ + spack -e adios2 env loads # Initialize the first-use-of-environment stuff for the adios user WORKDIR /home/adios USER adios RUN spack env activate adios2 && \ - spack env deactivate + spack env deactivate && \ + echo "source /opt/spack/share/spack/setup-env.sh" >> ~/.bash_profile && \ + echo "module use ${SPACK_ROOT}/share/spack/modules/linux-ubuntu18.04-haswell" >> ~/.bash_profile && \ + echo "source ${SPACK_ROOT}/var/spack/environments/adios2/loads" >> ~/.bash_profile -ENTRYPOINT ["/usr/local/bin/spack-named-env", "adios2"] -CMD ["bash"] +ENTRYPOINT [] +CMD ["bash", "--login"] diff --git a/scripts/docker/Dockerfile.complete b/scripts/docker/Dockerfile.complete index fc310da51d..b6595154c6 100644 --- a/scripts/docker/Dockerfile.complete +++ b/scripts/docker/Dockerfile.complete @@ -7,19 +7,23 @@ RUN spack install \ adios2 && \ spack clean -a -# Build the envirponment -RUN spack env create adios2 && \ +# Build the environment +RUN spack env create --without-view adios2 && \ spack -e adios2 add $(spack find --format "/{hash}") && \ spack -e adios2 install && \ rm -rf /root/.spack && \ spack env activate adios2 && \ - spack env deactivate + spack env deactivate && \ + spack -e adios2 env loads # Initialize the first-use-of-environment stuff for the adios user WORKDIR /home/adios USER adios RUN spack env activate adios2 && \ - spack env deactivate + spack env deactivate && \ + echo "source /opt/spack/share/spack/setup-env.sh" >> ~/.bash_profile && \ + echo "module use ${SPACK_ROOT}/share/spack/modules/linux-ubuntu18.04-haswell" >> ~/.bash_profile && \ + echo "source ${SPACK_ROOT}/var/spack/environments/adios2/loads" >> ~/.bash_profile -ENTRYPOINT ["/usr/local/bin/spack-named-env", "adios2"] -CMD ["bash"] +ENTRYPOINT [] +CMD ["bash", "--login"] diff --git a/scripts/docker/Dockerfile.dependencies b/scripts/docker/Dockerfile.dependencies index 3600406dee..3a840b8c5e 100644 --- a/scripts/docker/Dockerfile.dependencies +++ b/scripts/docker/Dockerfile.dependencies @@ -14,15 +14,12 @@ RUN cd ${SPACK_ROOT} && \ git checkout -f develop && \ rm -rf .git -# Setup the modified entrypoint +# Fix the python version being used ENV SPACK_PYTHON=/usr/bin/python3.6 -COPY entrypoint.bash $SPACK_ROOT/share/spack/docker/entrypoint.bash -RUN rm -f /usr/local/bin/spack-named-env && \ - ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \ - /usr/local/bin/spack-named-env # Setup the default configuration COPY packages.yaml $SPACK_ROOT/etc/spack/packages.yaml +COPY modules.yaml $SPACK_ROOT/etc/spack/modules.yaml RUN rm -rf /root/.spack && \ spack compiler find --scope site diff --git a/scripts/docker/entrypoint.bash b/scripts/docker/entrypoint.bash deleted file mode 100755 index 513137422e..0000000000 --- a/scripts/docker/entrypoint.bash +++ /dev/null @@ -1,189 +0,0 @@ -#! /usr/bin/env bash -# -# Copyright 2013-2021 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) - -mode=oneshot - -if [ "$( basename "$0" )" '=' 'spack-env' ] ; then - mode=spackenv -elif [ "$( basename "$0" )" '=' 'spack-named-env' ] ; then - mode=namedenv - named_env="$1" - shift -elif [ "$( basename "$0" )" '=' 'docker-shell' ] ; then - mode=dockershell -elif [ "$( basename "$0" )" '=' 'interactive-shell' ] ; then - mode=interactiveshell -elif [ "$1" '=' 'spack-named-env' ] ; then - mode=namedenv - named_env="$2" - shift 2 -elif [ "$1" '=' 'docker-shell' ] ; then - mode=dockershell - shift -elif [ "$1" '=' 'interactive-shell' ] ; then - mode=interactiveshell - shift -fi - -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 "$@" - ;; - - "namedenv") - # Scenario 2: Run within a defiend spack environment 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 and also needs a spack - # environment pre-loaded. - # - # Roughly equivalent to - # docker run ... --entrypoint spack-env ... sh -c "spack activate && .." - # - # The shell script runs with both spack and a given environment - # pre-loaded and ready to use. - if [ -z "$named_env" ] ; then - ( - echo -n "It looks like you're trying to use a" - echo -n " named environment but didn't actually specify the" - echo -n " environment name to activate." - echo - ) >&2 - exit 1 - fi - . $SPACK_ROOT/share/spack/setup-env.sh - spack env activate $named_env - if [ $? -ne 0 ] ; then - ( - echo -n "It looks like you're trying to use a" - echo -n " named environment but the specified environment" - echo -n " \"$named_env\" was not able to activate." - echo - ) >&2 - exit 2 - fi - unset CURRENTLY_BUILDING_DOCKER_IMAGE - echo "$@" - exec "$@" - ;; - - "dockershell") - # Scenario 3: 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 "$*" - ;; - - "interactiveshell") - # Scenario 4: 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 - - echo -n "Make sure you run docker with the --interactive" - echo -n " and --tty options." - echo - ) >&2 - - exit 1 - fi - ;; - - "oneshot") - # Scenario 5: 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 - - 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/scripts/docker/modules.yaml b/scripts/docker/modules.yaml new file mode 100644 index 0000000000..b908a05880 --- /dev/null +++ b/scripts/docker/modules.yaml @@ -0,0 +1,9 @@ +modules: + enable: + - tcl + tcl: + hash_length: 0 + all: + autoload: 'direct' + projections: + all: '{name}/{version}' diff --git a/testing/contract/scorpio/depends.sh b/testing/contract/scorpio/depends.sh index 2547a731b9..5490f49950 100755 --- a/testing/contract/scorpio/depends.sh +++ b/testing/contract/scorpio/depends.sh @@ -3,6 +3,4 @@ set -x set -e -sudo /opt/spack/bin/spack install parallel-netcdf -sudo /opt/spack/bin/spack -e adios2 add parallel-netcdf -sudo /opt/spack/bin/spack -e adios2 install -v +sudo /opt/spack/bin/spack install -v parallel-netcdf diff --git a/testing/contract/scorpio/setup.sh b/testing/contract/scorpio/setup.sh index ca74ccf68a..08fbcaa5e2 100755 --- a/testing/contract/scorpio/setup.sh +++ b/testing/contract/scorpio/setup.sh @@ -7,3 +7,5 @@ echo "source_dir = \"${source_dir}\"" echo "build_dir = \"${build_dir}\"" echo "install_dir = \"${install_dir}\"" echo "test_dir = \"${test_dir}\"" + +module load parallel-netcdf