From 37d7b5b199af0c2f735c84fb0dd01676b7ec4cc8 Mon Sep 17 00:00:00 2001 From: Glenn Johnson Date: Tue, 30 Jun 2020 18:17:58 -0500 Subject: Activate environment in container file (#17316) * Activate environment in container file This PR will ensure that the container recipes will build the spack environment by first activating the environment. * Deactivate environment before environment collection For Singularity, the environment must be deactivated before running the command to collect the environment variables. This is because the environment collection uses `spack env activate`. --- share/spack/templates/container/Dockerfile | 2 +- share/spack/templates/container/singularity.def | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/share/spack/templates/container/Dockerfile b/share/spack/templates/container/Dockerfile index 740f46e9ee..2f1370fdb3 100644 --- a/share/spack/templates/container/Dockerfile +++ b/share/spack/templates/container/Dockerfile @@ -7,7 +7,7 @@ RUN mkdir {{ paths.environment }} \ {{ manifest }} > {{ paths.environment }}/spack.yaml # Install the software, remove unecessary deps -RUN cd {{ paths.environment }} && spack install && spack gc -y +RUN cd {{ paths.environment }} && spack env activate . && spack install && spack gc -y {% if strip %} # Strip all the binaries diff --git a/share/spack/templates/container/singularity.def b/share/spack/templates/container/singularity.def index 616e677f96..7ba0a3ff1b 100644 --- a/share/spack/templates/container/singularity.def +++ b/share/spack/templates/container/singularity.def @@ -11,8 +11,10 @@ EOF # Install all the required software . /opt/spack/share/spack/setup-env.sh + spack env activate . spack install spack gc -y + spack env deactivate spack env activate --sh -d . >> {{ paths.environment }}/environment_modifications.sh {% if strip %} @@ -87,4 +89,4 @@ Stage: final {% for label, value in labels.items() %} {{ label }} {{ value }} {% endfor %} -{% endif %} \ No newline at end of file +{% endif %} -- cgit v1.2.3-60-g2f50