2020-01-31 09:19:55 +08:00
|
|
|
Bootstrap: docker
|
2020-11-18 03:25:13 +08:00
|
|
|
From: {{ build.image }}
|
2020-01-31 09:19:55 +08:00
|
|
|
Stage: build
|
|
|
|
|
|
|
|
%post
|
2020-11-18 03:25:13 +08:00
|
|
|
{% if os_packages_build.list %}
|
|
|
|
# Update, install and cleanup of system packages needed at build-time
|
|
|
|
{% if os_package_update %}
|
|
|
|
{{ os_packages_build.update }}
|
|
|
|
{% endif %}
|
|
|
|
{{ os_packages_build.install }} {{ os_packages_build.list | join | replace('\n', ' ') }}
|
|
|
|
{{ os_packages_build.clean }}
|
|
|
|
|
|
|
|
{% endif %}
|
2020-01-31 09:19:55 +08:00
|
|
|
# Create the manifest file for the installation in /opt/spack-environment
|
|
|
|
mkdir {{ paths.environment }} && cd {{ paths.environment }}
|
|
|
|
cat << EOF > spack.yaml
|
|
|
|
{{ manifest }}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Install all the required software
|
|
|
|
. /opt/spack/share/spack/setup-env.sh
|
2020-07-01 07:17:58 +08:00
|
|
|
spack env activate .
|
2022-07-07 14:49:40 +08:00
|
|
|
spack install --fail-fast
|
2020-01-31 09:19:55 +08:00
|
|
|
spack gc -y
|
2020-07-01 07:17:58 +08:00
|
|
|
spack env deactivate
|
2020-01-31 09:19:55 +08:00
|
|
|
spack env activate --sh -d . >> {{ paths.environment }}/environment_modifications.sh
|
|
|
|
{% if strip %}
|
|
|
|
|
|
|
|
# Strip the binaries to reduce the size of the image
|
|
|
|
find -L {{ paths.view }}/* -type f -exec readlink -f '{}' \; | \
|
|
|
|
xargs file -i | \
|
|
|
|
grep 'charset=binary' | \
|
|
|
|
grep 'x-executable\|x-archive\|x-sharedlib' | \
|
|
|
|
awk -F: '{print $1}' | xargs strip -s
|
|
|
|
{% endif %}
|
|
|
|
{% if extra_instructions.build %}
|
|
|
|
{{ extra_instructions.build }}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% if apps %}
|
|
|
|
{% for application, help_text in apps.items() %}
|
|
|
|
|
|
|
|
%apprun {{ application }}
|
|
|
|
exec /opt/view/bin/{{ application }} "$@"
|
|
|
|
|
|
|
|
%apphelp {{ application }}
|
|
|
|
{{help_text }}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
Bootstrap: docker
|
|
|
|
From: {{ run.image }}
|
|
|
|
Stage: final
|
|
|
|
|
|
|
|
%files from build
|
|
|
|
{{ paths.environment }} /opt
|
|
|
|
{{ paths.store }} /opt
|
2022-06-29 21:39:18 +08:00
|
|
|
{{ paths.hidden_view }} /opt
|
2020-01-31 09:19:55 +08:00
|
|
|
{{ paths.view }} /opt
|
|
|
|
{{ paths.environment }}/environment_modifications.sh {{ paths.environment }}/environment_modifications.sh
|
|
|
|
|
|
|
|
%post
|
2020-11-18 03:25:13 +08:00
|
|
|
{% if os_packages_final.list %}
|
|
|
|
# Update, install and cleanup of system packages needed at run-time
|
|
|
|
{% if os_package_update %}
|
|
|
|
{{ os_packages_final.update }}
|
|
|
|
{% endif %}
|
|
|
|
{{ os_packages_final.install }} {{ os_packages_final.list | join | replace('\n', ' ') }}
|
|
|
|
{{ os_packages_final.clean }}
|
2020-01-31 09:19:55 +08:00
|
|
|
{% endif %}
|
|
|
|
# Modify the environment without relying on sourcing shell specific files at startup
|
|
|
|
cat {{ paths.environment }}/environment_modifications.sh >> $SINGULARITY_ENVIRONMENT
|
|
|
|
{% if extra_instructions.final %}
|
|
|
|
{{ extra_instructions.final }}
|
|
|
|
{% endif %}
|
|
|
|
{% if runscript %}
|
2020-11-18 03:25:13 +08:00
|
|
|
|
2020-01-31 09:19:55 +08:00
|
|
|
%runscript
|
|
|
|
{{ runscript }}
|
|
|
|
{% endif %}
|
|
|
|
{% if startscript %}
|
2020-11-18 03:25:13 +08:00
|
|
|
|
2020-01-31 09:19:55 +08:00
|
|
|
%startscript
|
|
|
|
{{ startscript }}
|
|
|
|
{% endif %}
|
|
|
|
{% if test %}
|
2020-11-18 03:25:13 +08:00
|
|
|
|
2020-01-31 09:19:55 +08:00
|
|
|
%test
|
|
|
|
{{ test }}
|
|
|
|
{% endif %}
|
|
|
|
{% if help %}
|
2020-11-18 03:25:13 +08:00
|
|
|
|
2020-01-31 09:19:55 +08:00
|
|
|
%help
|
|
|
|
{{ help }}
|
|
|
|
{% endif %}
|
|
|
|
{% if labels %}
|
2020-11-18 03:25:13 +08:00
|
|
|
|
2020-01-31 09:19:55 +08:00
|
|
|
%labels
|
|
|
|
{% for label, value in labels.items() %}
|
|
|
|
{{ label }} {{ value }}
|
|
|
|
{% endfor %}
|
2020-07-01 07:17:58 +08:00
|
|
|
{% endif %}
|