Docker: Towards generated Dockerfiles

This commit is contained in:
Ole Schütt 2022-01-30 00:26:23 +01:00 committed by Ole Schütt
parent 007627045a
commit 2efb191b2d
8 changed files with 431 additions and 1 deletions

View file

@ -2,5 +2,6 @@ exe
lib
obj
regtesting
tools/toolchain
tools/toolchain/install
tools/toolchain/build
.git*

View file

@ -0,0 +1,61 @@
FROM ubuntu:20.04
USER root
# author: Ole Schuett
# Installs lean toolchain without MPI and relying mostly on Ubuntu packages.
# Install Ubuntu packages.
COPY ./tools/toolchain/install_requirements_ubuntu.sh .
RUN ./install_requirements_ubuntu.sh
# Install some more Ubuntu packages.
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && \
apt-get update -qq && apt-get install -qq --no-install-recommends \
cmake \
gcc-10 \
g++-10 \
gfortran-10 \
fftw3-dev \
libopenblas-dev \
libgsl-dev \
libhdf5-dev \
&& rm -rf /var/lib/apt/lists/*
# Create links.
RUN ln -sf gcc-10 /usr/bin/gcc && \
ln -sf g++-10 /usr/bin/g++ && \
ln -sf gfortran-10 /usr/bin/gfortran
# Build toolchain.
WORKDIR /opt/cp2k-toolchain
COPY ./tools/toolchain/scripts ./scripts
COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--mpi-mode=no \
--with-gcc=system \
--with-cmake=system \
--with-fftw=system \
--with-openblas=system \
--with-gsl=system \
--with-hdf5=system \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--libint-lmax=4 \
&& rm -rf ./build
WORKDIR /workspace
COPY ./tools/docker/scripts/install_basics.sh .
RUN ./install_basics.sh
COPY ./tools/docker/scripts/install_regtest.sh .
RUN ./install_regtest.sh local ssmp
COPY ./tools/docker/scripts/ci_entrypoint.sh ./tools/docker/scripts/test_regtest.sh ./
CMD ["./ci_entrypoint.sh", "./test_regtest.sh", "local", "ssmp"]
#EOF

View file

@ -0,0 +1,61 @@
FROM ubuntu:20.04
USER root
# author: Ole Schuett
# Installs lean toolchain without MPI and relying mostly on Ubuntu packages.
# Install Ubuntu packages.
COPY ./tools/toolchain/install_requirements_ubuntu.sh .
RUN ./install_requirements_ubuntu.sh
# Install some more Ubuntu packages.
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && \
apt-get update -qq && apt-get install -qq --no-install-recommends \
cmake \
gcc-7 \
g++-7 \
gfortran-7 \
fftw3-dev \
libopenblas-dev \
libgsl-dev \
libhdf5-dev \
&& rm -rf /var/lib/apt/lists/*
# Create links.
RUN ln -sf gcc-7 /usr/bin/gcc && \
ln -sf g++-7 /usr/bin/g++ && \
ln -sf gfortran-7 /usr/bin/gfortran
# Build toolchain.
WORKDIR /opt/cp2k-toolchain
COPY ./tools/toolchain/scripts ./scripts
COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--mpi-mode=no \
--with-gcc=system \
--with-cmake=system \
--with-fftw=system \
--with-openblas=system \
--with-gsl=system \
--with-hdf5=system \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--libint-lmax=4 \
&& rm -rf ./build
WORKDIR /workspace
COPY ./tools/docker/scripts/install_basics.sh .
RUN ./install_basics.sh
COPY ./tools/docker/scripts/install_regtest.sh .
RUN ./install_regtest.sh local ssmp
COPY ./tools/docker/scripts/ci_entrypoint.sh ./tools/docker/scripts/test_regtest.sh ./
CMD ["./ci_entrypoint.sh", "./test_regtest.sh", "local", "ssmp"]
#EOF

View file

@ -0,0 +1,61 @@
FROM ubuntu:20.04
USER root
# author: Ole Schuett
# Installs lean toolchain without MPI and relying mostly on Ubuntu packages.
# Install Ubuntu packages.
COPY ./tools/toolchain/install_requirements_ubuntu.sh .
RUN ./install_requirements_ubuntu.sh
# Install some more Ubuntu packages.
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && \
apt-get update -qq && apt-get install -qq --no-install-recommends \
cmake \
gcc-8 \
g++-8 \
gfortran-8 \
fftw3-dev \
libopenblas-dev \
libgsl-dev \
libhdf5-dev \
&& rm -rf /var/lib/apt/lists/*
# Create links.
RUN ln -sf gcc-8 /usr/bin/gcc && \
ln -sf g++-8 /usr/bin/g++ && \
ln -sf gfortran-8 /usr/bin/gfortran
# Build toolchain.
WORKDIR /opt/cp2k-toolchain
COPY ./tools/toolchain/scripts ./scripts
COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--mpi-mode=no \
--with-gcc=system \
--with-cmake=system \
--with-fftw=system \
--with-openblas=system \
--with-gsl=system \
--with-hdf5=system \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--libint-lmax=4 \
&& rm -rf ./build
WORKDIR /workspace
COPY ./tools/docker/scripts/install_basics.sh .
RUN ./install_basics.sh
COPY ./tools/docker/scripts/install_regtest.sh .
RUN ./install_regtest.sh local ssmp
COPY ./tools/docker/scripts/ci_entrypoint.sh ./tools/docker/scripts/test_regtest.sh ./
CMD ["./ci_entrypoint.sh", "./test_regtest.sh", "local", "ssmp"]
#EOF

View file

@ -0,0 +1,61 @@
FROM ubuntu:20.04
USER root
# author: Ole Schuett
# Installs lean toolchain without MPI and relying mostly on Ubuntu packages.
# Install Ubuntu packages.
COPY ./tools/toolchain/install_requirements_ubuntu.sh .
RUN ./install_requirements_ubuntu.sh
# Install some more Ubuntu packages.
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && \
apt-get update -qq && apt-get install -qq --no-install-recommends \
cmake \
gcc-9 \
g++-9 \
gfortran-9 \
fftw3-dev \
libopenblas-dev \
libgsl-dev \
libhdf5-dev \
&& rm -rf /var/lib/apt/lists/*
# Create links.
RUN ln -sf gcc-9 /usr/bin/gcc && \
ln -sf g++-9 /usr/bin/g++ && \
ln -sf gfortran-9 /usr/bin/gfortran
# Build toolchain.
WORKDIR /opt/cp2k-toolchain
COPY ./tools/toolchain/scripts ./scripts
COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--mpi-mode=no \
--with-gcc=system \
--with-cmake=system \
--with-fftw=system \
--with-openblas=system \
--with-gsl=system \
--with-hdf5=system \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--libint-lmax=4 \
&& rm -rf ./build
WORKDIR /workspace
COPY ./tools/docker/scripts/install_basics.sh .
RUN ./install_basics.sh
COPY ./tools/docker/scripts/install_regtest.sh .
RUN ./install_regtest.sh local ssmp
COPY ./tools/docker/scripts/ci_entrypoint.sh ./tools/docker/scripts/test_regtest.sh ./
CMD ["./ci_entrypoint.sh", "./test_regtest.sh", "local", "ssmp"]
#EOF

View file

@ -0,0 +1,61 @@
FROM i386/debian:11
USER root
# author: Ole Schuett
# Installs lean toolchain without MPI and relying mostly on Ubuntu packages.
# Install Ubuntu packages.
COPY ./tools/toolchain/install_requirements_ubuntu.sh .
RUN ./install_requirements_ubuntu.sh
# Install some more Ubuntu packages.
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && \
apt-get update -qq && apt-get install -qq --no-install-recommends \
cmake \
gcc-10 \
g++-10 \
gfortran-10 \
fftw3-dev \
libopenblas-dev \
libgsl-dev \
libhdf5-dev \
&& rm -rf /var/lib/apt/lists/*
# Create links.
RUN ln -sf gcc-10 /usr/bin/gcc && \
ln -sf g++-10 /usr/bin/g++ && \
ln -sf gfortran-10 /usr/bin/gfortran
# Build toolchain.
WORKDIR /opt/cp2k-toolchain
COPY ./tools/toolchain/scripts ./scripts
COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--mpi-mode=no \
--with-gcc=system \
--with-cmake=system \
--with-fftw=system \
--with-openblas=system \
--with-gsl=system \
--with-hdf5=system \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--libint-lmax=4 \
&& rm -rf ./build
WORKDIR /workspace
COPY ./tools/docker/scripts/install_basics.sh .
RUN ./install_basics.sh
COPY ./tools/docker/scripts/install_regtest.sh .
RUN ./install_regtest.sh local ssmp
COPY ./tools/docker/scripts/ci_entrypoint.sh ./tools/docker/scripts/test_regtest.sh ./
CMD ["./ci_entrypoint.sh", "./test_regtest.sh", "local", "ssmp"]
#EOF

View file

@ -0,0 +1,122 @@
#!/usr/bin/env python3
# author: Ole Schuett
from pathlib import Path
from typing import Any
import argparse
import io
# ======================================================================================
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--check", action="store_true")
args = parser.parse_args()
for gcc_version in 7, 8, 9, 10:
with OutputFile(f"Dockerfile.test_gcc{gcc_version}", args.check) as f:
f.write(toolchain_ubuntu_nompi(gcc_version=gcc_version) + regtest_ssmp())
with OutputFile("Dockerfile.test_i386", args.check) as f:
f.write(toolchain_ubuntu_nompi(base_image="i386/debian:11") + regtest_ssmp())
# ======================================================================================
def regtest_ssmp() -> str:
return fr"""
WORKDIR /workspace
COPY ./tools/docker/scripts/install_basics.sh .
RUN ./install_basics.sh
COPY ./tools/docker/scripts/install_regtest.sh .
RUN ./install_regtest.sh local ssmp
COPY ./tools/docker/scripts/ci_entrypoint.sh ./tools/docker/scripts/test_regtest.sh ./
CMD ["./ci_entrypoint.sh", "./test_regtest.sh", "local", "ssmp"]
#EOF
""".lstrip()
# ======================================================================================
def toolchain_ubuntu_nompi(
base_image: str = "ubuntu:20.04", gcc_version: int = 10, libint_lmax: int = 4
) -> str:
return fr"""
FROM {base_image}
USER root
# author: Ole Schuett
# Installs lean toolchain without MPI and relying mostly on Ubuntu packages.
# Install Ubuntu packages.
COPY ./tools/toolchain/install_requirements_ubuntu.sh .
RUN ./install_requirements_ubuntu.sh
# Install some more Ubuntu packages.
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && \
apt-get update -qq && apt-get install -qq --no-install-recommends \
cmake \
gcc-{gcc_version} \
g++-{gcc_version} \
gfortran-{gcc_version} \
fftw3-dev \
libopenblas-dev \
libgsl-dev \
libhdf5-dev \
&& rm -rf /var/lib/apt/lists/*
# Create links.
RUN ln -sf gcc-{gcc_version} /usr/bin/gcc && \
ln -sf g++-{gcc_version} /usr/bin/g++ && \
ln -sf gfortran-{gcc_version} /usr/bin/gfortran
# Build toolchain.
WORKDIR /opt/cp2k-toolchain
COPY ./tools/toolchain/scripts ./scripts
COPY ./tools/toolchain/install_cp2k_toolchain.sh .
RUN ./install_cp2k_toolchain.sh \
--mpi-mode=no \
--with-gcc=system \
--with-cmake=system \
--with-fftw=system \
--with-openblas=system \
--with-gsl=system \
--with-hdf5=system \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--with-libxc=install \
--with-libxsmm=install \
--with-libint=install \
--libint-lmax={libint_lmax} \
&& rm -rf ./build
""".lstrip()
# ======================================================================================
class OutputFile:
def __init__(self, filename: str, check: bool) -> None:
self.filename = filename
self.check = check
self.content = io.StringIO()
def __enter__(self) -> io.StringIO:
return self.content
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
output_path = Path(__file__).parent / self.filename
if self.check:
assert output_path.read_text(encoding="utf8") == self.content.getvalue()
print(f"File {output_path} is consisted with generator script.")
else:
output_path.write_text(self.content.getvalue(), encoding="utf8")
print(f"Wrote {output_path}")
# ======================================================================================
main()
# EOF

View file

@ -24,12 +24,14 @@ echo ""
run_test ./tools/prettify/prettify_test.py
run_test ./tools/minimax_tools/minimax_to_fortran_source.py --check
run_test ./tools/docker/generate_dockerfiles.py --check
run_test mypy --strict ./tools/minimax_tools/minimax_to_fortran_source.py
run_test mypy --strict ./tools/dashboard/generate_dashboard.py
run_test mypy --strict ./tools/regtesting/do_regtest.py
run_test mypy --strict ./tools/regtesting/optimize_test_dirs.py
run_test mypy --strict ./tools/precommit/check_file_properties.py
run_test mypy --strict ./tools/docker/generate_dockerfiles.py
# Test generate_dashboard.py. Running it twice to also execute its caching.
mkdir -p /workspace/artifacts/dashboard