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`.
This commit is contained in:
Glenn Johnson 2020-06-30 18:17:58 -05:00 committed by GitHub
parent cec55577d4
commit 37d7b5b199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -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

View file

@ -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 %}
{% endif %}