Skip to content

Commit

Permalink
Simplify CMake installation in Dockerfiles (#222)
Browse files Browse the repository at this point in the history
* simplify Dockerfile for clang CI

* Use correct public key to verify CMake binary signature

* [skip ci] Add documentation

* Add example of CMake release URL in CONTRIBUTING.md

* Add missing licenses

* merge CONTIRUBINT.md into README.md under docker

* add package write permission in CI

---------

Co-authored-by: Yuuichi Asahi <[email protected]>
Co-authored-by: Paul Zehner <[email protected]>
  • Loading branch information
3 people authored Jan 27, 2025
1 parent 6743d46 commit ccdedaa
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 65 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/__build_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ env:
jobs:
build_base:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

strategy:
matrix:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
if: ${{ needs.check_docker_files.outputs.docker_files_have_changed == 'true' }}

uses: ./.github/workflows/__build_base.yaml
permissions:
contents: read
packages: write

with:
image_suffix: ${{ needs.check_docker_files.outputs.image_suffix }}
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pre_build_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
build_base:
needs: check_docker_files

permissions:
contents: read
packages: write

# run inconditionnaly on schedule or manual mode or if Docker files changed on other modes
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || needs.check_docker_files.outputs.docker_files_have_changed == 'true' }}

Expand Down
27 changes: 27 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
SPDX-FileCopyrightText: (C) The kokkos-fft development team, see COPYRIGHT.md file
SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
-->

# Dockerfiles

Those Dockerfiles are mainly used for CI.
Each backend/compiler has a corresponding Dockerfile.

# Contributing

## CMake installation in Dockerfiles

As the project requires CMake v3.23 at least, and as some Dockerfiles are based on Ubuntu 20.04 images, CMake has to be installed manually.
The installer is downloaded, its signature is verified, then its checksum is verified.
To check the signature, the public key of the person who signed the binary is required.
This public key can be extracted from the key ID.

When updating the Dockerfiles for a newer version of CMake (if needed), the process to get the right public key is as follows:

1. Identify the release on GitHub (e.g. https://github.com/Kitware/CMake/releases/tag/v3.23.2);
2. Copy the key ID in the line "PGP sign by XXXXXXXX";
3. Paste it in `https://keys.openpgp.org/` to retrieve the URL of the public key file;
4. Copy the last part in the URL `https://keys.openpgp.org/vks/v1/by-fingerprint/YYYYYYYY`;
5. Update the Dockrfiles with this value.
25 changes: 12 additions & 13 deletions docker/clang/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,26 @@ RUN apt-get update && apt-get install -y \
clang-tidy-19 \
&& rm -rf /var/lib/apt/lists/*

RUN KEYDUMP_URL=https://cloud.cees.ornl.gov/download && \
KEYDUMP_FILE=keydump && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE} && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE}.sig && \
gpg --import ${KEYDUMP_FILE} && \
gpg --verify ${KEYDUMP_FILE}.sig ${KEYDUMP_FILE} && \
rm ${KEYDUMP_FILE}*

# Install newer CMake manually
ARG CMAKE_VERSION=3.23.2

ENV CMAKE_DIR=/opt/cmake
RUN CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION} && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-Linux-x86_64.sh && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-linux-x86_64.sh && \
CMAKE_SHA256=cmake-${CMAKE_VERSION}-SHA-256.txt && \
CMAKE_SIGNATURE=cmake-${CMAKE_VERSION}-SHA-256.txt.asc && \
PUBLIC_KEY_ID=CBA23971357C2E6590D9EFD3EC8FEF3A7BFB4EDA && \
PUBLIC_KEY_URL=https://keys.openpgp.org/vks/v1/by-fingerprint/${PUBLIC_KEY_ID} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256}.asc && \
wget --quiet ${CMAKE_URL}/${CMAKE_SIGNATURE} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SCRIPT} && \
gpg --verify ${CMAKE_SHA256}.asc ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sed -e s/linux/Linux/ | sha256sum --check && \
wget --quiet ${PUBLIC_KEY_URL} && \
gpg --import ${PUBLIC_KEY_ID} && \
gpg --verify ${CMAKE_SIGNATURE} ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sha256sum --check && \
mkdir -p ${CMAKE_DIR} && \
sh ${CMAKE_SCRIPT} --skip-license --prefix=${CMAKE_DIR} && \
rm cmake*
rm cmake* ${PUBLIC_KEY_ID}
ENV PATH=${CMAKE_DIR}/bin:$PATH

# Set Clang 19 as the default Clang and Clang++
Expand Down
25 changes: 12 additions & 13 deletions docker/gcc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,26 @@ ENV FFTWDIR "/usr"

RUN git config --global --add safe.directory "*"

RUN KEYDUMP_URL=https://cloud.cees.ornl.gov/download && \
KEYDUMP_FILE=keydump && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE} && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE}.sig && \
gpg --import ${KEYDUMP_FILE} && \
gpg --verify ${KEYDUMP_FILE}.sig ${KEYDUMP_FILE} && \
rm ${KEYDUMP_FILE}*

# Install newer CMake manually
ARG CMAKE_VERSION=3.23.2

ENV CMAKE_DIR=/opt/cmake
RUN CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION} && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-Linux-x86_64.sh && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-linux-x86_64.sh && \
CMAKE_SHA256=cmake-${CMAKE_VERSION}-SHA-256.txt && \
CMAKE_SIGNATURE=cmake-${CMAKE_VERSION}-SHA-256.txt.asc && \
PUBLIC_KEY_ID=CBA23971357C2E6590D9EFD3EC8FEF3A7BFB4EDA && \
PUBLIC_KEY_URL=https://keys.openpgp.org/vks/v1/by-fingerprint/${PUBLIC_KEY_ID} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256}.asc && \
wget --quiet ${CMAKE_URL}/${CMAKE_SIGNATURE} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SCRIPT} && \
gpg --verify ${CMAKE_SHA256}.asc ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sed -e s/linux/Linux/ | sha256sum --check && \
wget --quiet ${PUBLIC_KEY_URL} && \
gpg --import ${PUBLIC_KEY_ID} && \
gpg --verify ${CMAKE_SIGNATURE} ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sha256sum --check && \
mkdir -p ${CMAKE_DIR} && \
sh ${CMAKE_SCRIPT} --skip-license --prefix=${CMAKE_DIR} && \
rm cmake*
rm cmake* ${PUBLIC_KEY_ID}
ENV PATH=${CMAKE_DIR}/bin:$PATH

WORKDIR /work
Expand Down
25 changes: 12 additions & 13 deletions docker/intel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,26 @@ ENV FFTWDIR "/usr"

RUN git config --global --add safe.directory "*"

RUN KEYDUMP_URL=https://cloud.cees.ornl.gov/download && \
KEYDUMP_FILE=keydump && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE} && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE}.sig && \
gpg --import ${KEYDUMP_FILE} && \
gpg --verify ${KEYDUMP_FILE}.sig ${KEYDUMP_FILE} && \
rm ${KEYDUMP_FILE}*

# Install newer CMake manually
ARG CMAKE_VERSION=3.25.2

ENV CMAKE_DIR=/opt/cmake
RUN CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION} && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-Linux-x86_64.sh && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-linux-x86_64.sh && \
CMAKE_SHA256=cmake-${CMAKE_VERSION}-SHA-256.txt && \
CMAKE_SIGNATURE=cmake-${CMAKE_VERSION}-SHA-256.txt.asc && \
PUBLIC_KEY_ID=CBA23971357C2E6590D9EFD3EC8FEF3A7BFB4EDA && \
PUBLIC_KEY_URL=https://keys.openpgp.org/vks/v1/by-fingerprint/${PUBLIC_KEY_ID} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256}.asc && \
wget --quiet ${CMAKE_URL}/${CMAKE_SIGNATURE} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SCRIPT} && \
gpg --verify ${CMAKE_SHA256}.asc ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sed -e s/linux/Linux/ | sha256sum --check && \
wget --quiet ${PUBLIC_KEY_URL} && \
gpg --import ${PUBLIC_KEY_ID} && \
gpg --verify ${CMAKE_SIGNATURE} ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sha256sum --check && \
mkdir -p ${CMAKE_DIR} && \
sh ${CMAKE_SCRIPT} --skip-license --prefix=${CMAKE_DIR} && \
rm cmake*
rm cmake* ${PUBLIC_KEY_ID}
ENV PATH=${CMAKE_DIR}/bin:$PATH

WORKDIR /work
Expand Down
25 changes: 12 additions & 13 deletions docker/nvcc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,26 @@ ENV FFTWDIR "/usr"

RUN git config --global --add safe.directory "*"

RUN KEYDUMP_URL=https://cloud.cees.ornl.gov/download && \
KEYDUMP_FILE=keydump && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE} && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE}.sig && \
gpg --import ${KEYDUMP_FILE} && \
gpg --verify ${KEYDUMP_FILE}.sig ${KEYDUMP_FILE} && \
rm ${KEYDUMP_FILE}*

# Install newer CMake manually
ARG CMAKE_VERSION=3.23.2

ENV CMAKE_DIR=/opt/cmake
RUN CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION} && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-Linux-x86_64.sh && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-linux-x86_64.sh && \
CMAKE_SHA256=cmake-${CMAKE_VERSION}-SHA-256.txt && \
CMAKE_SIGNATURE=cmake-${CMAKE_VERSION}-SHA-256.txt.asc && \
PUBLIC_KEY_ID=CBA23971357C2E6590D9EFD3EC8FEF3A7BFB4EDA && \
PUBLIC_KEY_URL=https://keys.openpgp.org/vks/v1/by-fingerprint/${PUBLIC_KEY_ID} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256}.asc && \
wget --quiet ${CMAKE_URL}/${CMAKE_SIGNATURE} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SCRIPT} && \
gpg --verify ${CMAKE_SHA256}.asc ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sed -e s/linux/Linux/ | sha256sum --check && \
wget --quiet ${PUBLIC_KEY_URL} && \
gpg --import ${PUBLIC_KEY_ID} && \
gpg --verify ${CMAKE_SIGNATURE} ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sha256sum --check && \
mkdir -p ${CMAKE_DIR} && \
sh ${CMAKE_SCRIPT} --skip-license --prefix=${CMAKE_DIR} && \
rm cmake*
rm cmake* ${PUBLIC_KEY_ID}
ENV PATH=${CMAKE_DIR}/bin:$PATH

WORKDIR /work
Expand Down
25 changes: 12 additions & 13 deletions docker/rocm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,26 @@ ENV CMAKE_PREFIX_PATH /opt/rocm/hip/:/opt/rocm/:$CMAKE_PREFIX_PATH

RUN git config --global --add safe.directory "*"

RUN KEYDUMP_URL=https://cloud.cees.ornl.gov/download && \
KEYDUMP_FILE=keydump && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE} && \
wget --quiet ${KEYDUMP_URL}/${KEYDUMP_FILE}.sig && \
gpg --import ${KEYDUMP_FILE} && \
gpg --verify ${KEYDUMP_FILE}.sig ${KEYDUMP_FILE} && \
rm ${KEYDUMP_FILE}*

# Install newer CMake manually
ARG CMAKE_VERSION=3.23.2

ENV CMAKE_DIR=/opt/cmake
RUN CMAKE_URL=https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION} && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-Linux-x86_64.sh && \
CMAKE_SCRIPT=cmake-${CMAKE_VERSION}-linux-x86_64.sh && \
CMAKE_SHA256=cmake-${CMAKE_VERSION}-SHA-256.txt && \
CMAKE_SIGNATURE=cmake-${CMAKE_VERSION}-SHA-256.txt.asc && \
PUBLIC_KEY_ID=CBA23971357C2E6590D9EFD3EC8FEF3A7BFB4EDA && \
PUBLIC_KEY_URL=https://keys.openpgp.org/vks/v1/by-fingerprint/${PUBLIC_KEY_ID} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SHA256}.asc && \
wget --quiet ${CMAKE_URL}/${CMAKE_SIGNATURE} && \
wget --quiet ${CMAKE_URL}/${CMAKE_SCRIPT} && \
gpg --verify ${CMAKE_SHA256}.asc ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sed -e s/linux/Linux/ | sha256sum --check && \
wget --quiet ${PUBLIC_KEY_URL} && \
gpg --import ${PUBLIC_KEY_ID} && \
gpg --verify ${CMAKE_SIGNATURE} ${CMAKE_SHA256} && \
grep -i ${CMAKE_SCRIPT} ${CMAKE_SHA256} | sha256sum --check && \
mkdir -p ${CMAKE_DIR} && \
sh ${CMAKE_SCRIPT} --skip-license --prefix=${CMAKE_DIR} && \
rm cmake*
rm cmake* ${PUBLIC_KEY_ID}
ENV PATH=${CMAKE_DIR}/bin:$PATH

WORKDIR /work
Expand Down

0 comments on commit ccdedaa

Please sign in to comment.