mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-29 06:35:28 -04:00
Docker: Add local Spack cache
This commit is contained in:
parent
273e611c39
commit
5d671136cc
7 changed files with 80 additions and 11 deletions
|
|
@ -28,12 +28,19 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
|
|||
pkgconf \
|
||||
python3 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
unzip \
|
||||
wget \
|
||||
xxd \
|
||||
xz-utils \
|
||||
zstd && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create and activate a virtual environment for Python packages.
|
||||
RUN python3 -m venv /opt/venv
|
||||
ENV PATH="/opt/venv/bin:$PATH"
|
||||
RUN pip3 install --quiet boto3==1.38.11 google-cloud-storage==3.1.0
|
||||
|
||||
# Install a recent Spack version
|
||||
WORKDIR /root/spack
|
||||
ARG SPACK_VERSION
|
||||
|
|
@ -50,12 +57,15 @@ RUN spack compiler find
|
|||
# Find all external packages
|
||||
RUN spack external find --all --not-buildable
|
||||
|
||||
# Enable Spack build cache from the latest development version
|
||||
ARG SPACK_BUILD_CACHE
|
||||
ENV SPACK_BUILD_CACHE="${SPACK_BUILD_CACHE:-develop-2025-04-27}"
|
||||
RUN spack mirror add ${SPACK_BUILD_CACHE} https://binaries.spack.io/${SPACK_BUILD_CACHE} && \
|
||||
# Add public Spack cache from https://cache.spack.io
|
||||
RUN spack mirror add ${SPACK_VERSION}-cache https://binaries.spack.io/${SPACK_VERSION} && \
|
||||
spack buildcache keys --install --trust --force && \
|
||||
spack mirror remove ${SPACK_BUILD_CACHE}
|
||||
spack mirror remove ${SPACK_VERSION}-cache
|
||||
|
||||
# Add local Spack cache.
|
||||
ARG SPACK_CACHE
|
||||
ENV SPACK_CACHE=${SPACK_CACHE:-"s3://spack-cache --s3-endpoint-url=http://localhost:9000"}
|
||||
RUN spack mirror add --autopush --unsigned local-cache ${SPACK_CACHE}
|
||||
|
||||
# Copy Spack configuration and build recipes
|
||||
ARG CP2K_BUILD_TYPE
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ This directory hosts docker files for testing cp2k. They are mostly used by the
|
|||
To run a test one simply has to build the image:
|
||||
|
||||
```shell
|
||||
docker build --shm-size=1g -f Dockerfile.test_sdbg -t cp2k_test_sdbg ../../
|
||||
./spack_cache_start.sh
|
||||
docker build --network=host --shm-size=1g -f Dockerfile.test_sdbg -t cp2k_test_sdbg ../../
|
||||
```
|
||||
|
||||
To retrieve the cached report of an old image simply run it:
|
||||
|
|
|
|||
|
|
@ -854,12 +854,19 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
|
|||
pkgconf \
|
||||
python3 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
unzip \
|
||||
wget \
|
||||
xxd \
|
||||
xz-utils \
|
||||
zstd && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create and activate a virtual environment for Python packages.
|
||||
RUN python3 -m venv /opt/venv
|
||||
ENV PATH="/opt/venv/bin:$PATH"
|
||||
RUN pip3 install --quiet boto3==1.38.11 google-cloud-storage==3.1.0
|
||||
|
||||
# Install a recent Spack version
|
||||
WORKDIR /root/spack
|
||||
ARG SPACK_VERSION
|
||||
|
|
@ -876,12 +883,15 @@ RUN spack compiler find
|
|||
# Find all external packages
|
||||
RUN spack external find --all --not-buildable
|
||||
|
||||
# Enable Spack build cache from the latest development version
|
||||
ARG SPACK_BUILD_CACHE
|
||||
ENV SPACK_BUILD_CACHE="${{SPACK_BUILD_CACHE:-develop-2025-04-27}}"
|
||||
RUN spack mirror add ${{SPACK_BUILD_CACHE}} https://binaries.spack.io/${{SPACK_BUILD_CACHE}} && \
|
||||
# Add public Spack cache from https://cache.spack.io
|
||||
RUN spack mirror add ${{SPACK_VERSION}}-cache https://binaries.spack.io/${{SPACK_VERSION}} && \
|
||||
spack buildcache keys --install --trust --force && \
|
||||
spack mirror remove ${{SPACK_BUILD_CACHE}}
|
||||
spack mirror remove ${{SPACK_VERSION}}-cache
|
||||
|
||||
# Add local Spack cache.
|
||||
ARG SPACK_CACHE
|
||||
ENV SPACK_CACHE=${{SPACK_CACHE:-"s3://spack-cache --s3-endpoint-url=http://localhost:9000"}}
|
||||
RUN spack mirror add --autopush --unsigned local-cache ${{SPACK_CACHE}}
|
||||
|
||||
# Copy Spack configuration and build recipes
|
||||
ARG CP2K_BUILD_TYPE
|
||||
|
|
|
|||
7
tools/docker/spack_cache_list.sh
Executable file
7
tools/docker/spack_cache_list.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# author: Ole Schuett
|
||||
|
||||
docker exec spack-cache mc ls --recursive --summarize local/spack-cache
|
||||
|
||||
#EOF
|
||||
7
tools/docker/spack_cache_remove.sh
Executable file
7
tools/docker/spack_cache_remove.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# author: Ole Schuett
|
||||
|
||||
docker rm spack-cache
|
||||
|
||||
#EOF
|
||||
27
tools/docker/spack_cache_start.sh
Executable file
27
tools/docker/spack_cache_start.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# author: Ole Schuett
|
||||
|
||||
if docker start spack-cache; then
|
||||
echo "Re-started existing spack cache."
|
||||
|
||||
else
|
||||
# Start MinIO server.
|
||||
docker run --name spack-cache --detach -p 9000:9000 -p 9001:9001 \
|
||||
quay.io/minio/minio server /data --console-address ":9001"
|
||||
|
||||
sleep 3
|
||||
docker container logs spack-cache
|
||||
|
||||
# Configure localhost.
|
||||
docker exec spack-cache mc alias set local http://localhost:9000 minioadmin minioadmin
|
||||
|
||||
# Create bucket.
|
||||
docker exec spack-cache mc mb local/spack-cache
|
||||
|
||||
# Make bucket public.
|
||||
docker exec spack-cache mc anonymous set public local/spack-cache
|
||||
echo "Started new spack cache."
|
||||
fi
|
||||
|
||||
#EOF
|
||||
7
tools/docker/spack_cache_stop.sh
Executable file
7
tools/docker/spack_cache_stop.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# author: Ole Schuett
|
||||
|
||||
docker container stop spack-cache
|
||||
|
||||
#EOF
|
||||
Loading…
Add table
Add a link
Reference in a new issue