Skip to content

Instantly share code, notes, and snippets.

@tmadlener
Last active October 26, 2022 15:03
Show Gist options
  • Save tmadlener/bcb05d95011e480171c5a386cc987748 to your computer and use it in GitHub Desktop.
Save tmadlener/bcb05d95011e480171c5a386cc987748 to your computer and use it in GitHub Desktop.
spack containerized install
spack:
config:
install_tree:
root: /opt/software
projections:
all: ${PACKAGE}/${VERSION}/${target}-${os}-${$COMPILERNAME}${COMPILERVER}-opt/${HASH}
install_missing_compilers: true
include:
- packages.yaml
view: false
concretization: together
specs:
- key4hep-stack
packages:
all:
target: [x86_64]
variants: build_type=RelWithDebInfo cxxstd=17
buildable: true
version: []
providers:
gl: [mesa]
glu: [mesa]
compiler: [gcc@11.2.0]

spack containerize

In principle spack allows to containerize things. However, we have not tried this with key4hep yet as all installations are currently geared towards cvmfs. See the documentation on how the spack generated Dockerfiles look like. They include a build stage and some cleanup to make the resulting image smaller.

Key4hep build basics

Key4hep uses spack environments by default and they also use the key4hep fork of spack, where the package versions are usually kept more stable and where a few additions like setup script generation are present. Additionally, some additional packages live in key4hep-spack

Basic setup

Clone git repositories, setup spack, setup additional spack repositories...

git clone https://github.com/key4hep/spack
. spack/share/spack/setup.sh
git clone https://github.com/key4hep/key4hep-spack
spack repo add key4hep-spack

With this we should be able to install the environment defined in the attached spack.yaml file. The packages.yaml file that is included from there can be found in key4hep-spack/environments/key4hep-common.

The spack.yaml and the package.yaml file need to be put into a directory, in the following I assume this is in key4hep-container-env

Installing key4hep-stack

Before starting the installation the following environment variables have to be set

mkdir -p key4hep
export K4_LATEST_SETUP_PATH=/key4hep/setup.sh
export ILCSOFT_LATEST_SETUP_PATH=key4hep/init_ilcsoft.sh

Then installing is simply

cd key4hep-container-env
spack env activate .
spack install --fail-fast 

We can then see whether we want to do stripping and clenaup

@EnginEren
Copy link

Current error is

spack install --fail-fast 
==> Error: key4hep-stack is unsatisfiable, errors are:
  A conflict was triggered

    To see full clingo unsat cores, re-run with `spack --show-cores=full`
    For full, subset-minimal unsat cores, re-run with `spack --show-cores=minimized
    Warning: This may take (up to) hours for some specs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment