summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorGlenn Johnson <glenn-johnson@uiowa.edu>2020-06-30 18:17:58 -0500
committerGitHub <noreply@github.com>2020-06-30 18:17:58 -0500
commit37d7b5b199af0c2f735c84fb0dd01676b7ec4cc8 (patch)
treed14b90bf82b278a2c05e407d3957b99b83ac48c2 /share
parentcec55577d4b789a8860045cddc58d57161007119 (diff)
downloadspack-37d7b5b199af0c2f735c84fb0dd01676b7ec4cc8.tar.gz
spack-37d7b5b199af0c2f735c84fb0dd01676b7ec4cc8.tar.bz2
spack-37d7b5b199af0c2f735c84fb0dd01676b7ec4cc8.tar.xz
spack-37d7b5b199af0c2f735c84fb0dd01676b7ec4cc8.zip
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`.
Diffstat (limited to 'share')
-rw-r--r--share/spack/templates/container/Dockerfile2
-rw-r--r--share/spack/templates/container/singularity.def4
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 %}