From a2a52dfb2103d12e4348dec6824d4eaf68a68f58 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Mon, 14 Aug 2023 18:02:48 +0200 Subject: Fix containerize view symlink issue (#39419) --- share/spack/templates/container/Dockerfile | 8 +++++--- share/spack/templates/container/singularity.def | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'share') diff --git a/share/spack/templates/container/Dockerfile b/share/spack/templates/container/Dockerfile index 92e89668e0..27c2dbf5cf 100644 --- a/share/spack/templates/container/Dockerfile +++ b/share/spack/templates/container/Dockerfile @@ -51,15 +51,17 @@ FROM {{ run.image }} COPY --from=builder {{ paths.environment }} {{ paths.environment }} COPY --from=builder {{ paths.store }} {{ paths.store }} -COPY --from=builder {{ paths.hidden_view }} {{ paths.hidden_view }} -COPY --from=builder {{ paths.view }} {{ paths.view }} + +# paths.view is a symlink, so copy the parent to avoid dereferencing and duplicating it +COPY --from=builder {{ paths.view_parent }} {{ paths.view_parent }} RUN { \ echo '#!/bin/sh' \ && echo '.' {{ paths.environment }}/activate.sh \ && echo 'exec "$@"'; \ } > /entrypoint.sh \ -&& chmod a+x /entrypoint.sh +&& chmod a+x /entrypoint.sh \ +&& ln -s {{ paths.view }} {{ paths.former_view }} {% block final_stage %} diff --git a/share/spack/templates/container/singularity.def b/share/spack/templates/container/singularity.def index a67d25783d..4184db92b6 100644 --- a/share/spack/templates/container/singularity.def +++ b/share/spack/templates/container/singularity.def @@ -47,7 +47,7 @@ EOF {% for application, help_text in apps.items() %} %apprun {{ application }} - exec /opt/view/bin/{{ application }} "$@" + exec {{ paths.view }}/bin/{{ application }} "$@" %apphelp {{ application }} {{help_text }} @@ -61,11 +61,14 @@ Stage: final %files from build {{ paths.environment }} /opt {{ paths.store }} /opt - {{ paths.hidden_view }} /opt - {{ paths.view }} /opt + {{ paths.view_parent }} /opt {{ paths.environment }}/environment_modifications.sh {{ paths.environment }}/environment_modifications.sh %post + + # Symlink the old view location + ln -s {{ paths.view }} {{ paths.former_view }} + {% block final_stage %} {% if os_packages_final.list %} # Update, install and cleanup of system packages needed at run-time -- cgit v1.2.3-70-g09d2