mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 22:25:32 -04:00
120 lines
3.8 KiB
Text
120 lines
3.8 KiB
Text
#
|
|
# This file was created by generate_dockerfiles.py.
|
|
# Usage: podman build --shm-size=1g -f ./Dockerfile.test_spack ../../
|
|
#
|
|
|
|
FROM ubuntu:24.04
|
|
|
|
# Install packages required to build the CP2K dependencies with Spack
|
|
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
|
|
bzip2 \
|
|
ca-certificates \
|
|
cmake \
|
|
g++ \
|
|
gcc \
|
|
gfortran \
|
|
git \
|
|
gnupg \
|
|
hwloc \
|
|
libhwloc-dev \
|
|
libssh-dev \
|
|
libssl-dev \
|
|
libtool \
|
|
libtool-bin \
|
|
lsb-release \
|
|
make \
|
|
ninja-build \
|
|
patch \
|
|
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
|
|
|
|
# Retrieve the number of available CPU cores
|
|
ARG NUM_PROCS
|
|
ENV NUM_PROCS=${NUM_PROCS:-32}
|
|
|
|
# Install Spack and Spack packages
|
|
WORKDIR /root/spack
|
|
ARG SPACK_VERSION
|
|
ENV SPACK_VERSION=${SPACK_VERSION:-1.0.0}
|
|
ARG SPACK_PACKAGES_VERSION
|
|
ENV SPACK_PACKAGES_VERSION=${SPACK_PACKAGES_VERSION:-2025.07.0}
|
|
ARG SPACK_REPO=https://github.com/spack/spack
|
|
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/v${SPACK_VERSION}.tar.gz \
|
|
&& tar -xzf v${SPACK_VERSION}.tar.gz -C /opt && rm -f v${SPACK_VERSION}.tar.gz \
|
|
&& mkdir -p ${SPACK_PACKAGES_ROOT} \
|
|
&& wget -q ${SPACK_PACKAGES_REPO}/archive/v${SPACK_PACKAGES_VERSION}.tar.gz \
|
|
&& tar -xzf v${SPACK_PACKAGES_VERSION}.tar.gz -C /opt && rm -f v${SPACK_PACKAGES_VERSION}.tar.gz
|
|
|
|
ENV PATH="${SPACK_ROOT}/bin:${PATH}"
|
|
|
|
# Add Spack packages builtin repository
|
|
RUN spack repo add --scope site ${SPACK_PACKAGES_ROOT}/repos/spack_repo/builtin
|
|
|
|
# Find all compilers
|
|
RUN spack compiler find
|
|
|
|
# Find all external packages
|
|
RUN spack external find --all --not-buildable
|
|
|
|
# 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}_${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"
|
|
RUN spack -e myenv env depfile -o spack_makefile && \
|
|
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.
|
|
WORKDIR /opt/cp2k
|
|
COPY ./src ./src
|
|
COPY ./data ./data
|
|
COPY ./tests ./tests
|
|
COPY ./tools/build_utils ./tools/build_utils
|
|
COPY ./cmake ./cmake
|
|
COPY ./CMakeLists.txt .
|
|
|
|
# Build CP2K with CMake and run regression tests.
|
|
ARG TESTOPTS=""
|
|
COPY ./tools/docker/scripts/build_cp2k_cmake.sh ./tools/docker/scripts/test_regtest_cmake.sh ./
|
|
RUN /bin/bash -o pipefail -c " \
|
|
TESTOPTS='${TESTOPTS}' \
|
|
./test_regtest_cmake.sh spack_all psmp |& tee report.log && \
|
|
rm -rf regtesting"
|
|
|
|
# Output the report if the image is old and was therefore pulled from the build cache.
|
|
CMD cat $(find ./report.log -mmin +10) | sed '/^Summary:/ s/$/ (cached)/'
|
|
ENTRYPOINT []
|
|
|
|
#EOF
|