From 9b1fcb96ff1a075927bd631438a6802b14742e6c Mon Sep 17 00:00:00 2001 From: rbanka1 Date: Fri, 23 May 2025 22:04:27 +0200 Subject: [PATCH] Build dockers I added a new Docker image for Ubuntu 24.04 and updated the others. I also created two new workflows that check for changes in the Docker files. If any changes are detected, the relevant Docker image will be rebuilt and pushed (unless it's a pull request). The rebuilt images will be available after the merge. --- .github/docker/ubuntu-20.04.Dockerfile | 29 +++++---- .github/docker/ubuntu-22.04.Dockerfile | 22 ++++--- .github/docker/ubuntu-24.04.Dockerfile | 66 ++++++++++++++++++++ .github/workflows/detect_changes.yml | 44 +++++++++++++ .github/workflows/reusable_dockers_build.yml | 42 +++++++++++++ CONTRIBUTING.md | 8 +++ 6 files changed, 192 insertions(+), 19 deletions(-) create mode 100644 .github/docker/ubuntu-24.04.Dockerfile create mode 100644 .github/workflows/detect_changes.yml create mode 100644 .github/workflows/reusable_dockers_build.yml diff --git a/.github/docker/ubuntu-20.04.Dockerfile b/.github/docker/ubuntu-20.04.Dockerfile index a6a45a8c1..8869303b7 100644 --- a/.github/docker/ubuntu-20.04.Dockerfile +++ b/.github/docker/ubuntu-20.04.Dockerfile @@ -1,10 +1,10 @@ -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # # Dockerfile - a 'recipe' for Docker to build an image of ubuntu-based -# environment for building the Unified Memory Framework project. +# environment for building the Unified Memory Framework project. # # Pull base image ("20.04") @@ -22,43 +22,50 @@ ARG BASE_DEPS="\ cmake \ git" -# UMF's dependencies -ARG UMF_DEPS="\ - libhwloc-dev \ - libtbb-dev" +# Hwloc installation dependencies +ARG HWLOC_DEPS="\ + libtool" # Dependencies for tests (optional) ARG TEST_DEPS="\ - libnuma-dev" + libnuma-dev \ + libtbb-dev \ + valgrind" # Miscellaneous for our builds/CI (optional) ARG MISC_DEPS="\ automake \ clang \ g++-7 \ + lcov \ python3-pip \ sudo \ whois" +# libhwloc-dev is required - installed via script because hwloc version is too old on this OS +COPY .github/scripts/install_hwloc.sh /opt/umf/install_hwloc.sh + # Update and install required packages RUN apt-get update \ && apt-get install -y --no-install-recommends \ ${BASE_DEPS} \ - ${UMF_DEPS} \ ${TEST_DEPS} \ ${MISC_DEPS} \ + ${HWLOC_DEPS} \ + && /opt/umf/install_hwloc.sh \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean all # Prepare a dir (accessible by anyone) -RUN mkdir --mode 777 /opt/umf/ +RUN mkdir -p --mode 777 /opt/umf/ # Additional dependencies (installed via pip) +# It's actively used and tested only on selected distros. Be aware +# they may not work, because pip packages list differ from OS to OS. COPY third_party/requirements.txt /opt/umf/requirements.txt -RUN pip3 install --no-cache-dir -r /opt/umf/requirements.txt # Add a new (non-root) 'test_user' ENV USER test_user ENV USERPASS pass -RUN useradd -m "${USER}" -g sudo -p "$(mkpasswd ${USERPASS})" +RUN useradd -m -u 1001 "${USER}" -g sudo -p "$(mkpasswd ${USERPASS})" USER test_user diff --git a/.github/docker/ubuntu-22.04.Dockerfile b/.github/docker/ubuntu-22.04.Dockerfile index 75c71c526..915d92c26 100644 --- a/.github/docker/ubuntu-22.04.Dockerfile +++ b/.github/docker/ubuntu-22.04.Dockerfile @@ -1,4 +1,4 @@ -# Copyright (C) 2024 Intel Corporation +# Copyright (C) 2024-2025 Intel Corporation # Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception @@ -17,24 +17,30 @@ ENV NOTTY 1 ENV DEBIAN_FRONTEND noninteractive # Base development packages +# It seems that libtool is not directly needed +# but it is still required when Building UMF ARG BASE_DEPS="\ build-essential \ cmake \ - git" + git \ + libtool \ + wget" # UMF's dependencies ARG UMF_DEPS="\ - libhwloc-dev \ - libtbb-dev" + libhwloc-dev" # Dependencies for tests (optional) ARG TEST_DEPS="\ - libnuma-dev" + libnuma-dev \ + libtbb-dev \ + valgrind" # Miscellaneous for our builds/CI (optional) ARG MISC_DEPS="\ automake \ clang \ + lcov \ python3-pip \ sudo \ whois" @@ -43,14 +49,14 @@ ARG MISC_DEPS="\ RUN apt-get update \ && apt-get install -y --no-install-recommends \ ${BASE_DEPS} \ - ${UMF_DEPS} \ ${TEST_DEPS} \ ${MISC_DEPS} \ + ${UMF_DEPS} \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean all # Prepare a dir (accessible by anyone) -RUN mkdir --mode 777 /opt/umf/ +RUN mkdir -p --mode 777 /opt/umf/ # Additional dependencies (installed via pip) COPY third_party/requirements.txt /opt/umf/requirements.txt @@ -59,5 +65,5 @@ RUN pip3 install --no-cache-dir -r /opt/umf/requirements.txt # Add a new (non-root) 'test_user' ENV USER test_user ENV USERPASS pass -RUN useradd -m "${USER}" -g sudo -p "$(mkpasswd ${USERPASS})" +RUN useradd -m -u 1001 "${USER}" -g sudo -p "$(mkpasswd ${USERPASS})" USER test_user diff --git a/.github/docker/ubuntu-24.04.Dockerfile b/.github/docker/ubuntu-24.04.Dockerfile new file mode 100644 index 000000000..e56338ab9 --- /dev/null +++ b/.github/docker/ubuntu-24.04.Dockerfile @@ -0,0 +1,66 @@ +# Copyright (C) 2025 Intel Corporation +# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# +# Dockerfile - a 'recipe' for Docker to build an image of ubuntu-based +# environment for building the Unified Memory Framework project. +# + +# Pull base image ("24.04") +FROM registry.hub.docker.com/library/ubuntu@sha256:72297848456d5d37d1262630108ab308d3e9ec7ed1c3286a32fe09856619a782 + +# Set environment variables +ENV OS ubuntu +ENV OS_VER 24.04 +ENV NOTTY 1 +ENV DEBIAN_FRONTEND noninteractive + +# Base development packages +ARG BASE_DEPS="\ + build-essential \ + cmake \ + git \ + wget" + +# UMF's dependencies +ARG UMF_DEPS="\ + libhwloc-dev" + +# Dependencies for tests (optional) +ARG TEST_DEPS="\ + libnuma-dev \ + libtbb-dev \ + valgrind" + +# Miscellaneous for our builds/CI (optional) +ARG MISC_DEPS="\ + automake \ + clang \ + lcov \ + python3-pip \ + sudo \ + whois" + +# Update and install required packages +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ${BASE_DEPS} \ + ${TEST_DEPS} \ + ${MISC_DEPS} \ + ${UMF_DEPS} \ + && rm -rf /var/lib/apt/lists/* \ + && apt-get clean all + +# Prepare a dir (accessible by anyone) +RUN mkdir -p --mode 777 /opt/umf/ + +# Additional dependencies (installed via pip) +COPY third_party/requirements.txt /opt/umf/requirements.txt +RUN pip3 install --no-cache-dir --break-system-packages -r /opt/umf/requirements.txt + +# Add a new (non-root) 'test_user' +ENV USER test_user +ENV USERPASS pass +RUN useradd -m "${USER}" -g sudo -p "$(mkpasswd ${USERPASS})" +USER test_user diff --git a/.github/workflows/detect_changes.yml b/.github/workflows/detect_changes.yml new file mode 100644 index 000000000..93a6c3994 --- /dev/null +++ b/.github/workflows/detect_changes.yml @@ -0,0 +1,44 @@ +name: DetectChanges + +on: + pull_request: + paths: + - '.github/docker/*.Dockerfile' + - '.github/scripts/*' + push: + paths: + - '.github/docker/*.Dockerfile' + - '.github/scripts/*' + +permissions: + contents: read + +jobs: + DetectChanges: + runs-on: ubuntu-latest + outputs: + changed_files: ${{ steps.changed-files.outputs.all_changed_files }} + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c #v46.0.5 + + - name: List all changed files + env: + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + run: | + echo "Changed files: $ALL_CHANGED_FILES" + + BuildDocker: + needs: DetectChanges + if: ${{ contains(join(needs.DetectChanges.outputs.changed_files, ' '), '.github/docker/') }} + uses: ./.github/workflows/reusable_dockers_build.yml + permissions: + contents: read + packages: write + secrets: inherit diff --git a/.github/workflows/reusable_dockers_build.yml b/.github/workflows/reusable_dockers_build.yml new file mode 100644 index 000000000..f0899c80c --- /dev/null +++ b/.github/workflows/reusable_dockers_build.yml @@ -0,0 +1,42 @@ +# Build and push Docker images to GHCR +name: BuildDockers + +on: + workflow_call: + workflow_dispatch: + +permissions: + packages: write + contents: read + +jobs: + build-dockers: + runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] + env: + IMG: ghcr.io/bb-ur/umf-${{ matrix.os }}:latest + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Build ${{ matrix.os }} Docker image + run: | + docker build -f .github/docker/${{ matrix.os }}.Dockerfile -t ${{ env.IMG }} . + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@30f019fb76bb54d03ec1e716054622be511a13b2 # v3.2.0 + with: + registry: ghcr.io + username: bb-ur + password: ${{ secrets.BB_GHCR_TOKEN }} + + - name: Push ${{ matrix.os }} Docker image + if: github.event_name != 'pull_request' + run: | + docker push ${{ env.IMG }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6a050c0ae..cb2f9de1f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,6 +6,7 @@ - [Opening new issues](#opening-new-issues) - [Submitting Pull Requests](#submitting-pull-requests) - [Building and testing](#building-and-testing) + - [Building/Rebuilding Docker Images](#buildingrebuilding-docker-images) - [Code style](#code-style) - [When my PR is merged?](#when-my-pr-is-merged) - [Extending public API](#extending-public-api) @@ -67,6 +68,13 @@ To enable additional checks (including `-Werror` / `/WX` compilation flag), swit `UMF_DEVELOPER_MODE`. To read more about all available CMake options please see ["CMake standard options"](./README.md#cmake-standard-options) section in the top-level Readme. +### Building/Rebuilding Docker Images + +If you want to rebuild existing Docker images or add a new one, you must open a separate pull +request dedicated to Docker-related changes. This PR must be merged into the main branch first. + +The updated Docker images will be available for use in workflows only when this PR is merged. + ### Code style We use `clang-format` to verify and apply code style changes to C/C++ source files. To see all rules we require, please take a look at `.clang-format` file in the