From c354cc51d0a35f09a7d67ace71115e56154a160e Mon Sep 17 00:00:00 2001 From: Jonathon Anderson <17242663+blue42u@users.noreply.github.com> Date: Fri, 9 Jun 2023 03:25:13 -0400 Subject: containerize: use an ENTRYPOINT script (#37769) --- share/spack/templates/container/Dockerfile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'share/spack/templates') diff --git a/share/spack/templates/container/Dockerfile b/share/spack/templates/container/Dockerfile index b4aee2ee78..92e89668e0 100644 --- a/share/spack/templates/container/Dockerfile +++ b/share/spack/templates/container/Dockerfile @@ -37,7 +37,7 @@ RUN find -L {{ paths.view }}/* -type f -exec readlink -f '{}' \; | \ # Modifications to the environment that are necessary to run RUN cd {{ paths.environment }} && \ - spack env activate --sh -d . >> /etc/profile.d/z10_spack_environment.sh + spack env activate --sh -d . > activate.sh {% if extra_instructions.build %} {{ extra_instructions.build }} @@ -53,7 +53,13 @@ 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 }} -COPY --from=builder /etc/profile.d/z10_spack_environment.sh /etc/profile.d/z10_spack_environment.sh + +RUN { \ + echo '#!/bin/sh' \ + && echo '.' {{ paths.environment }}/activate.sh \ + && echo 'exec "$@"'; \ + } > /entrypoint.sh \ +&& chmod a+x /entrypoint.sh {% block final_stage %} @@ -70,6 +76,6 @@ RUN {% if os_package_update %}{{ os_packages_final.update }} \ {% for label, value in labels.items() %} LABEL "{{ label }}"="{{ value }}" {% endfor %} -ENTRYPOINT ["/bin/bash", "--rcfile", "/etc/profile", "-l", "-c", "$*", "--" ] +ENTRYPOINT [ "/entrypoint.sh" ] CMD [ "/bin/bash" ] {% endif %} -- cgit v1.2.3-60-g2f50