Notes on Spack
Creating Docker images from Spack
Based on Build Caches tutorial.
Create a OCI registry in Inria GitLab
https://docs.gitlab.com/ee/user/packages/container_registry
- Go to a repository you are administrator of
- Go to Settings > General
- Open “Visibility, project features, permissions”, and enable “Container Registry”
Next, we will create some access tokens to push to the registry. Access tokens can be created with different scopes:
To create an Access Token for the project (repository):
- Go to the same repository
- Go to Settings > Access tokens
- “Add new token”
- Enable write_registry and read_registry
- Take note of your username and token keypair, we will use that in Spack
Crate a Spack environment
A spack environment can be created from a spack.yaml file, with the following
contents:
You have to fill out:
- target: fix the compilation target to have binaries that are compatible
with the target machine. For example:
x86_64_v1,sandybridge, etc. - owner and repo for the repository that holds the cache.
- cache name is a unique name, because a single repo may hold different. caches.
- user is your GitLab username and token the one we created before.
Warning
Make sure to not git commit your token
Build and push packages to the cache
If we hold the spack.yaml in /path/to/my_environment/spack.yaml:
After the packages are in disk, we can push our whole environment, or a single package to the buildcache:
Important
--base-image <BASE IMAGE> should point to a docker image that macthes your
host system. For example, I build my packages from Ubuntu 24.04, so I pass
--base-image ubuntu:24.04.
After everything is pushed, Spack will notify you about the OCI urls:
You can use the URI in docker run <uri> or singularity run docker://<uri>
Converting Docker images to Singularity
Simply: