Docker: Add error message for missing spack cache

This commit is contained in:
Ole Schütt 2025-05-22 16:02:49 +02:00 committed by Ole Schütt
parent 6d377b8c9f
commit 0977f2f4e1
3 changed files with 29 additions and 6 deletions

View file

@ -0,0 +1,23 @@
#!/bin/bash -e
# author: Ole Schuett
if [[ -n "${SPACK_CACHE}" ]]; then
if [[ "${SPACK_CACHE}" == *"http://localhost:9000"* ]]; then
if ! wget -q --tries=1 "http://localhost:9000/spack-cache"; then
echo ""
echo "ERROR: Could not connect to local Spack cache."
echo " Start the cache by running ./start_spack_cache.sh and then pass --network=host to podman."
echo " Alternatively, disable the cache by passing --build-arg SPACK_CACHE=\"\" to podman."
echo " See also: https://manual.cp2k.org/trunk/getting-started/build-with-spack.html"
echo ""
exit 1
fi
fi
echo "Adding Spack cache: ${SPACK_CACHE}"
spack mirror add --autopush --unsigned local-cache "${SPACK_CACHE}"
else
echo "No Spack cache provided."
fi
#EOF