Sync Spack test with CSCS CI

This commit is contained in:
Matthias Krack 2025-07-18 17:13:42 +02:00
parent b03fed0400
commit fa52cf20e1
2 changed files with 56 additions and 56 deletions

View file

@ -36,32 +36,36 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
xz-utils \
zstd && rm -rf /var/lib/apt/lists/*
# Create and activate a virtual environment for Python packages.
# Create and activate a virtual environment for Python packages
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:${PATH}"
RUN pip3 install --quiet boto3==1.38.11 google-cloud-storage==3.1.0
# Install Spack and Spack packages
# Retrieve the number of available CPU cores
ARG NUM_PROCS
ENV NUM_PROCS=${NUM_PROCS:-32}
# Install Spack and Spack packages from July 17, 2025
WORKDIR /root/spack
ARG SPACK_VERSION
ENV SPACK_VERSION=${SPACK_VERSION:-2e7168b4cfe9222a94becf0c2c5b401f513181ec}
ENV SPACK_VERSION=${SPACK_VERSION:-a572692b6da3ae74633b53b236023862f7284ad4}
ARG SPACK_PACKAGES_VERSION
ENV SPACK_PACKAGES_VERSION=${SPACK_PACKAGES_VERSION:-c63151a5baffcd96978966cd5ed83a6b8328e026}
ENV SPACK_PACKAGES_VERSION=${SPACK_PACKAGES_VERSION:-97d47813671327ab07a5c840fa549d130baacbb2}
ARG SPACK_REPO=https://github.com/spack/spack
ENV SPACK_ROOT=/opt/spack-$SPACK_VERSION
ENV SPACK_ROOT=/opt/spack-${SPACK_VERSION}
ARG SPACK_PACKAGES_REPO=https://github.com/spack/spack-packages
ENV SPACK_PACKAGES_ROOT=/opt/spack-packages-$SPACK_PACKAGES_VERSION
RUN mkdir -p $SPACK_ROOT \
&& wget -q $SPACK_REPO/archive/$SPACK_VERSION.tar.gz \
&& tar -xzf $SPACK_VERSION.tar.gz -C /opt && rm -f $SPACK_VERSION.tar.gz \
&& mkdir -p $SPACK_PACKAGES_ROOT \
&& wget -q $SPACK_PACKAGES_REPO/archive/$SPACK_PACKAGES_VERSION.tar.gz \
&& tar -xzf $SPACK_PACKAGES_VERSION.tar.gz -C /opt && rm -f $SPACK_PACKAGES_VERSION.tar.gz
ENV SPACK_PACKAGES_ROOT=/opt/spack-packages-${SPACK_PACKAGES_VERSION}
RUN mkdir -p ${SPACK_ROOT} \
&& wget -q ${SPACK_REPO}/archive/${SPACK_VERSION}.tar.gz \
&& tar -xzf ${SPACK_VERSION}.tar.gz -C /opt && rm -f ${SPACK_VERSION}.tar.gz \
&& mkdir -p ${SPACK_PACKAGES_ROOT} \
&& wget -q ${SPACK_PACKAGES_REPO}/archive/${SPACK_PACKAGES_VERSION}.tar.gz \
&& tar -xzf ${SPACK_PACKAGES_VERSION}.tar.gz -C /opt && rm -f ${SPACK_PACKAGES_VERSION}.tar.gz
ENV PATH="$SPACK_ROOT/bin:${PATH}"
ENV PATH="${SPACK_ROOT}/bin:${PATH}"
# Add Spack packages builtin repository
RUN spack repo add --scope site $SPACK_PACKAGES_ROOT/repos/spack_repo/builtin
RUN spack repo add --scope site ${SPACK_PACKAGES_ROOT}/repos/spack_repo/builtin
# Find all compilers
RUN spack compiler find
@ -69,31 +73,27 @@ RUN spack compiler find
# Find all external packages
RUN spack external find --all --not-buildable
# Add local Spack cache.
# Add local Spack cache
ARG SPACK_CACHE="s3://spack-cache --s3-endpoint-url=http://localhost:9000"
COPY ./tools/docker/scripts/setup_spack_cache.sh ./
RUN ./setup_spack_cache.sh
# Copy Spack configuration and build recipes
ARG CP2K_VERSION
ENV CP2K_VERSION=${CP2K_VERSION:-psmp}
ARG CP2K_BUILD_TYPE
ENV CP2K_BUILD_TYPE=${CP2K_BUILD_TYPE:-all}
COPY ./tools/spack/cp2k_deps_${CP2K_BUILD_TYPE}_psmp.yaml ./
COPY ./tools/spack/cp2k_dev_repo $SPACK_PACKAGES_ROOT/repos/spack_repo/cp2k_dev_repo/
RUN spack repo add --scope site $SPACK_PACKAGES_ROOT/repos/spack_repo/cp2k_dev_repo/
# Sarus containers must be dynamically linked to an MPI implementation that is ABI-compatible
# with the MPI on the compute nodes at CSCS like MPICH@3
ARG MPICH_VERSION
ENV MPICH_VERSION=${MPICH_VERSION:-4.3.0}
RUN sed -i -e "s/mpich@[0-9.]*/mpich@${MPICH_VERSION}/" cp2k_deps_${CP2K_BUILD_TYPE}_psmp.yaml && \
spack env create myenv cp2k_deps_${CP2K_BUILD_TYPE}_psmp.yaml && \
COPY ./tools/spack/cp2k_deps_${CP2K_BUILD_TYPE}_${CP2K_VERSION}.yaml ./
COPY ./tools/spack/cp2k_dev_repo ${SPACK_PACKAGES_ROOT}/repos/spack_repo/cp2k_dev_repo/
RUN spack repo add --scope site ${SPACK_PACKAGES_ROOT}/repos/spack_repo/cp2k_dev_repo/
RUN spack env create myenv cp2k_deps_${CP2K_BUILD_TYPE}_${CP2K_VERSION}.yaml && \
spack -e myenv repo list
# Install CP2K dependencies via Spack
RUN spack -e myenv concretize -f
ENV SPACK_ENV_VIEW="$SPACK_ROOT/var/spack/environments/myenv/spack-env/view"
ENV SPACK_ENV_VIEW="${SPACK_ROOT}/var/spack/environments/myenv/spack-env/view"
RUN spack -e myenv env depfile -o spack_makefile && \
make -j32 --file=spack_makefile SPACK_COLOR=never --output-sync=recurse && \
make -j${NUM_PROCS} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse && \
cp -ar ${SPACK_ENV_VIEW}/bin ${SPACK_ENV_VIEW}/include ${SPACK_ENV_VIEW}/lib /opt/spack
# Install CP2K sources.

View file

@ -872,32 +872,36 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
xz-utils \
zstd && rm -rf /var/lib/apt/lists/*
# Create and activate a virtual environment for Python packages.
# Create and activate a virtual environment for Python packages
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:${{PATH}}"
RUN pip3 install --quiet boto3==1.38.11 google-cloud-storage==3.1.0
# Install Spack and Spack packages
# Retrieve the number of available CPU cores
ARG NUM_PROCS
ENV NUM_PROCS=${{NUM_PROCS:-32}}
# Install Spack and Spack packages from July 17, 2025
WORKDIR /root/spack
ARG SPACK_VERSION
ENV SPACK_VERSION=${{SPACK_VERSION:-2e7168b4cfe9222a94becf0c2c5b401f513181ec}}
ENV SPACK_VERSION=${{SPACK_VERSION:-a572692b6da3ae74633b53b236023862f7284ad4}}
ARG SPACK_PACKAGES_VERSION
ENV SPACK_PACKAGES_VERSION=${{SPACK_PACKAGES_VERSION:-c63151a5baffcd96978966cd5ed83a6b8328e026}}
ENV SPACK_PACKAGES_VERSION=${{SPACK_PACKAGES_VERSION:-97d47813671327ab07a5c840fa549d130baacbb2}}
ARG SPACK_REPO=https://github.com/spack/spack
ENV SPACK_ROOT=/opt/spack-$SPACK_VERSION
ENV SPACK_ROOT=/opt/spack-${{SPACK_VERSION}}
ARG SPACK_PACKAGES_REPO=https://github.com/spack/spack-packages
ENV SPACK_PACKAGES_ROOT=/opt/spack-packages-$SPACK_PACKAGES_VERSION
RUN mkdir -p $SPACK_ROOT \
&& wget -q $SPACK_REPO/archive/$SPACK_VERSION.tar.gz \
&& tar -xzf $SPACK_VERSION.tar.gz -C /opt && rm -f $SPACK_VERSION.tar.gz \
&& mkdir -p $SPACK_PACKAGES_ROOT \
&& wget -q $SPACK_PACKAGES_REPO/archive/$SPACK_PACKAGES_VERSION.tar.gz \
&& tar -xzf $SPACK_PACKAGES_VERSION.tar.gz -C /opt && rm -f $SPACK_PACKAGES_VERSION.tar.gz
ENV SPACK_PACKAGES_ROOT=/opt/spack-packages-${{SPACK_PACKAGES_VERSION}}
RUN mkdir -p ${{SPACK_ROOT}} \
&& wget -q ${{SPACK_REPO}}/archive/${{SPACK_VERSION}}.tar.gz \
&& tar -xzf ${{SPACK_VERSION}}.tar.gz -C /opt && rm -f ${{SPACK_VERSION}}.tar.gz \
&& mkdir -p ${{SPACK_PACKAGES_ROOT}} \
&& wget -q ${{SPACK_PACKAGES_REPO}}/archive/${{SPACK_PACKAGES_VERSION}}.tar.gz \
&& tar -xzf ${{SPACK_PACKAGES_VERSION}}.tar.gz -C /opt && rm -f ${{SPACK_PACKAGES_VERSION}}.tar.gz
ENV PATH="$SPACK_ROOT/bin:${{PATH}}"
ENV PATH="${{SPACK_ROOT}}/bin:${{PATH}}"
# Add Spack packages builtin repository
RUN spack repo add --scope site $SPACK_PACKAGES_ROOT/repos/spack_repo/builtin
RUN spack repo add --scope site ${{SPACK_PACKAGES_ROOT}}/repos/spack_repo/builtin
# Find all compilers
RUN spack compiler find
@ -905,31 +909,27 @@ RUN spack compiler find
# Find all external packages
RUN spack external find --all --not-buildable
# Add local Spack cache.
# Add local Spack cache
ARG SPACK_CACHE="s3://spack-cache --s3-endpoint-url=http://localhost:9000"
COPY ./tools/docker/scripts/setup_spack_cache.sh ./
RUN ./setup_spack_cache.sh
# Copy Spack configuration and build recipes
ARG CP2K_VERSION
ENV CP2K_VERSION=${{CP2K_VERSION:-{version}}}
ARG CP2K_BUILD_TYPE
ENV CP2K_BUILD_TYPE=${{CP2K_BUILD_TYPE:-all}}
COPY ./tools/spack/cp2k_deps_${{CP2K_BUILD_TYPE}}_{version}.yaml ./
COPY ./tools/spack/cp2k_dev_repo $SPACK_PACKAGES_ROOT/repos/spack_repo/cp2k_dev_repo/
RUN spack repo add --scope site $SPACK_PACKAGES_ROOT/repos/spack_repo/cp2k_dev_repo/
# Sarus containers must be dynamically linked to an MPI implementation that is ABI-compatible
# with the MPI on the compute nodes at CSCS like MPICH@3
ARG MPICH_VERSION
ENV MPICH_VERSION=${{MPICH_VERSION:-4.3.0}}
RUN sed -i -e "s/mpich@[0-9.]*/mpich@${{MPICH_VERSION}}/" cp2k_deps_${{CP2K_BUILD_TYPE}}_{version}.yaml && \
spack env create myenv cp2k_deps_${{CP2K_BUILD_TYPE}}_{version}.yaml && \
COPY ./tools/spack/cp2k_deps_${{CP2K_BUILD_TYPE}}_${{CP2K_VERSION}}.yaml ./
COPY ./tools/spack/cp2k_dev_repo ${{SPACK_PACKAGES_ROOT}}/repos/spack_repo/cp2k_dev_repo/
RUN spack repo add --scope site ${{SPACK_PACKAGES_ROOT}}/repos/spack_repo/cp2k_dev_repo/
RUN spack env create myenv cp2k_deps_${{CP2K_BUILD_TYPE}}_${{CP2K_VERSION}}.yaml && \
spack -e myenv repo list
# Install CP2K dependencies via Spack
RUN spack -e myenv concretize -f
ENV SPACK_ENV_VIEW="$SPACK_ROOT/var/spack/environments/myenv/spack-env/view"
ENV SPACK_ENV_VIEW="${{SPACK_ROOT}}/var/spack/environments/myenv/spack-env/view"
RUN spack -e myenv env depfile -o spack_makefile && \
make -j32 --file=spack_makefile SPACK_COLOR=never --output-sync=recurse && \
make -j${{NUM_PROCS}} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse && \
cp -ar ${{SPACK_ENV_VIEW}}/bin ${{SPACK_ENV_VIEW}}/include ${{SPACK_ENV_VIEW}}/lib /opt/spack
"""