mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 14:15:19 -04:00
Use make_cp2k.sh script for CI/CD testing
This commit is contained in:
parent
cd22e438c1
commit
1bb5f7d1d6
2 changed files with 30 additions and 123 deletions
|
|
@ -3,81 +3,46 @@
|
|||
# A stand-alone build in this folder can be performed with:
|
||||
# podman build --build-arg DEPS_IMAGE=<image id> --shm-size=1g -f build_cp2k_spack.Dockerfile ../../
|
||||
#
|
||||
# Author: Matthias Krack
|
||||
# Author: Matthias Krack (MK)
|
||||
#
|
||||
# Stage 2a: Build CP2K
|
||||
|
||||
ARG BASE_IMAGE="ubuntu:24.04"
|
||||
ARG DEPS_IMAGE=""
|
||||
|
||||
FROM ${DEPS_IMAGE} AS build_cp2k
|
||||
###### Stage 2a: Build CP2K ######
|
||||
|
||||
FROM "${DEPS_IMAGE}" AS build_cp2k
|
||||
|
||||
# Store build arguments from base image needed in next stage
|
||||
RUN echo "${CP2K_VERSION}" >/CP2K_VERSION
|
||||
|
||||
# Build CP2K with CMake
|
||||
WORKDIR /opt/cp2k
|
||||
COPY ./CMakeLists.txt ./
|
||||
COPY ./benchmarks/CI ./benchmarks/CI
|
||||
COPY ./cmake ./cmake
|
||||
COPY ./data ./data
|
||||
COPY ./src ./src
|
||||
COPY ./tests ./tests
|
||||
COPY ./tools/build_utils ./tools/build_utils
|
||||
|
||||
# Run CMake
|
||||
RUN /bin/bash -c -o pipefail "source ./cmake/cmake_cp2k.sh spack ${CP2K_VERSION}"
|
||||
# Build CP2K
|
||||
RUN /bin/bash -o pipefail -c "source ./make_cp2k.sh -cv ${CP2K_VERSION}"
|
||||
|
||||
# Compile CP2K
|
||||
ARG LOG_LINES
|
||||
ENV LOG_LINES=${LOG_LINES:-200}
|
||||
WORKDIR /opt/cp2k/build
|
||||
RUN /bin/bash -c -o pipefail " \
|
||||
echo -e '\nCompiling CP2K ... \c'; \
|
||||
if ninja --verbose &>ninja.log; then \
|
||||
echo -e 'done\n'; \
|
||||
echo -e 'Installing CP2K ... \c'; \
|
||||
if ninja --verbose install &>install.log; then \
|
||||
echo -e 'done\n'; \
|
||||
else \
|
||||
echo -e 'failed\n'; \
|
||||
tail -n ${LOG_LINES} install.log; \
|
||||
fi; \
|
||||
cat cmake.log ninja.log install.log | gzip >build_cp2k.log.gz; \
|
||||
else \
|
||||
echo -e 'failed\n'; \
|
||||
tail -n ${LOG_LINES} ninja.log; \
|
||||
cat cmake.log ninja.log | gzip >build_cp2k.log.gz; \
|
||||
fi"
|
||||
###### Stage 2: Install CP2K ######
|
||||
|
||||
# Stage 2b: Install CP2K
|
||||
FROM ${BASE_IMAGE} AS install_cp2k
|
||||
FROM "${BASE_IMAGE}" AS install_cp2k
|
||||
|
||||
# Install required packages
|
||||
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
|
||||
g++ \
|
||||
gcc \
|
||||
gfortran \
|
||||
hwloc \
|
||||
libhwloc-dev \
|
||||
python3 && rm -rf /var/lib/apt/lists/*
|
||||
python3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Import build arguments from base image
|
||||
COPY --from=build_cp2k /CP2K_VERSION /
|
||||
|
||||
# Install CP2K dependencies built with Spack
|
||||
WORKDIR /opt
|
||||
COPY --from=build_cp2k /opt/spack ./spack
|
||||
|
||||
# Install CP2K binaries
|
||||
WORKDIR /opt/cp2k
|
||||
COPY --from=build_cp2k /opt/cp2k/bin ./bin
|
||||
|
||||
# Install CP2K libraries
|
||||
COPY --from=build_cp2k /opt/cp2k/lib ./lib
|
||||
# Install CP2K dependencies built with spack
|
||||
COPY --from=build_cp2k /opt/cp2k/spack/spack-1.1.0/opt/spack ./spack/spack-1.1.0/opt/spack
|
||||
|
||||
# Install CP2K database files
|
||||
COPY --from=build_cp2k /opt/cp2k/share ./share
|
||||
# Install CP2K
|
||||
COPY --from=build_cp2k /opt/cp2k/install ./install
|
||||
|
||||
# Install CP2K regression tests
|
||||
COPY --from=build_cp2k /opt/cp2k/tests ./tests
|
||||
|
|
@ -86,35 +51,10 @@ COPY --from=build_cp2k /opt/cp2k/src/grid/sample_tasks ./src/grid/sample_tasks
|
|||
# Install CP2K/Quickstep CI benchmarks
|
||||
COPY --from=build_cp2k /opt/cp2k/benchmarks/CI ./benchmarks/CI
|
||||
|
||||
# Import compressed build log file
|
||||
COPY --from=build_cp2k /opt/cp2k/build/build_cp2k.log.gz /opt/cp2k/build/build_cp2k.log.gz
|
||||
# Run CP2K regression test
|
||||
RUN /bin/bash -o pipefail -c "/opt/cp2k/install/bin/entrypoint.sh /opt/cp2k/install/bin/run_tests"
|
||||
|
||||
# Create links to CP2K binaries
|
||||
WORKDIR /opt/cp2k/bin
|
||||
RUN CP2K_VERSION=$(cat /CP2K_VERSION) && \
|
||||
ln -sf cp2k.${CP2K_VERSION} cp2k && \
|
||||
ln -sf cp2k.${CP2K_VERSION} cp2k.$(echo ${CP2K_VERSION} | sed "s/smp/opt/") && \
|
||||
ln -sf cp2k.${CP2K_VERSION} cp2k_shell
|
||||
|
||||
# Update library search path
|
||||
RUN echo "/opt/cp2k/lib\n/opt/spack/view/lib\n/opt/spack/view/lib/MiMiC\n$(dirname $(find /opt/spack ! -type l -name libtorch.so 2>/dev/null || true) 2>/dev/null || true)" >/etc/ld.so.conf.d/cp2k.conf && ldconfig
|
||||
|
||||
# Create entrypoint script file
|
||||
RUN printf "#!/bin/bash\n\
|
||||
ulimit -c 0 -s unlimited\n\
|
||||
\
|
||||
export OMP_STACKSIZE=64M\n\
|
||||
export PATH=/opt/cp2k/bin:/opt/spack/view/bin:\${PATH}\n\
|
||||
exec \"\$@\"" \
|
||||
>/opt/cp2k/bin/entrypoint.sh && chmod 755 /opt/cp2k/bin/entrypoint.sh
|
||||
|
||||
# Create shortcut for regression test
|
||||
RUN printf "/opt/cp2k/tests/do_regtest.py \$* /opt/cp2k/bin $(cat /CP2K_VERSION)" \
|
||||
>/opt/cp2k/bin/run_tests && chmod 755 /opt/cp2k/bin/run_tests
|
||||
|
||||
# Define entrypoint
|
||||
# Create entrypoint and finalise container build
|
||||
WORKDIR /mnt
|
||||
ENTRYPOINT ["/opt/cp2k/bin/entrypoint.sh"]
|
||||
ENTRYPOINT ["/opt/cp2k/install/bin/entrypoint.sh"]
|
||||
CMD ["cp2k", "--help"]
|
||||
|
||||
# EOF
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
# A stand-alone build in this folder can be performed with:
|
||||
# podman build --shm-size=1g -f build_deps_spack.Dockerfile ../../
|
||||
#
|
||||
# Author: Matthias Krack
|
||||
# Author: Matthias Krack (MK)
|
||||
#
|
||||
# Stage 1: Create a base image providing the dependencies for building a CP2K binary
|
||||
|
||||
ARG BASE_IMAGE="ubuntu:24.04"
|
||||
|
||||
FROM ${BASE_IMAGE} AS build_deps
|
||||
FROM "${BASE_IMAGE}" AS build_deps
|
||||
|
||||
# Install packages required to build the CP2K dependencies with Spack
|
||||
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
|
||||
|
|
@ -21,8 +21,6 @@ RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
|
|||
gfortran \
|
||||
git \
|
||||
gnupg \
|
||||
hwloc \
|
||||
libhwloc-dev \
|
||||
libssh-dev \
|
||||
libssl-dev \
|
||||
libtool \
|
||||
|
|
@ -34,57 +32,26 @@ 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/*
|
||||
zstd \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 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.1.0}
|
||||
ARG SPACK_PACKAGES_VERSION
|
||||
ENV SPACK_PACKAGES_VERSION=${SPACK_PACKAGES_VERSION:-2025.11.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
|
||||
|
||||
# Copy Spack configuration and build recipes
|
||||
ARG CP2K_VERSION
|
||||
ENV CP2K_VERSION=${CP2K_VERSION:-psmp}
|
||||
COPY ./tools/spack/cp2k_deps_${CP2K_VERSION}.yaml ./
|
||||
RUN sed -i -e "s/~xpmem/+xpmem/" cp2k_deps_${CP2K_VERSION}.yaml
|
||||
COPY ./tools/spack/spack_repo/cp2k_dev ${SPACK_PACKAGES_ROOT}/repos/spack_repo/cp2k_dev/
|
||||
RUN spack repo add --scope site ${SPACK_PACKAGES_ROOT}/repos/spack_repo/cp2k_dev/
|
||||
RUN spack env create myenv cp2k_deps_${CP2K_VERSION}.yaml && \
|
||||
spack -e myenv repo list
|
||||
|
||||
# Install CP2K dependencies via Spack
|
||||
RUN spack -e myenv concretize -f
|
||||
RUN spack -e myenv env depfile -o spack_makefile
|
||||
RUN make -j${NUM_PROCS} --file=spack_makefile SPACK_COLOR=never --output-sync=recurse
|
||||
# Copy CP2K repository into container
|
||||
WORKDIR /opt
|
||||
COPY . cp2k/
|
||||
|
||||
# EOF
|
||||
# Build CP2K dependencies
|
||||
WORKDIR /opt/cp2k
|
||||
RUN /bin/bash -o pipefail -c "source ./make_cp2k.sh -bd_only -cray -cv ${CP2K_VERSION}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue