From 687b1e88871eb2d80721db551b8e86a854cd130b Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Thu, 3 Jul 2025 11:53:53 +0100 Subject: [PATCH] chore: Don't hardcode versions in Dockerfiles and workflows (#2291) --- .github/actions/build_docker_image/action.yml | 4 +++ .github/workflows/update_docker_ci.yml | 31 ++++++++++++++----- docker/ci/Dockerfile | 7 +++-- docker/compilers/clang/Dockerfile | 10 +++--- docker/compilers/gcc/Dockerfile | 10 +++--- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/.github/actions/build_docker_image/action.yml b/.github/actions/build_docker_image/action.yml index 7bfe3fd0..761367fd 100644 --- a/.github/actions/build_docker_image/action.yml +++ b/.github/actions/build_docker_image/action.yml @@ -17,6 +17,9 @@ inputs: platforms: description: Platforms to build the image for (e.g. linux/amd64,linux/arm64) required: true + build_args: + description: List of build-time variables + required: false dockerhub_repo: description: DockerHub repository name @@ -61,6 +64,7 @@ runs: platforms: ${{ inputs.platforms }} push: ${{ inputs.push_image == 'true' }} tags: ${{ steps.meta.outputs.tags }} + build-args: ${{ inputs.build_args }} - name: Update DockerHub description if: ${{ inputs.push_image == 'true' && inputs.dockerhub_repo != '' }} diff --git a/.github/workflows/update_docker_ci.yml b/.github/workflows/update_docker_ci.yml index d566b5d3..6127dd2f 100644 --- a/.github/workflows/update_docker_ci.yml +++ b/.github/workflows/update_docker_ci.yml @@ -29,6 +29,10 @@ concurrency: cancel-in-progress: false env: + CLANG_MAJOR_VERSION: 16 + GCC_MAJOR_VERSION: 12 + GCC_VERSION: 12.3.0 + GHCR_REPO: ghcr.io/${{ github.repository_owner }} jobs: @@ -59,10 +63,13 @@ jobs: directory: docker/compilers/gcc tags: | type=raw,value=amd64-latest - type=raw,value=amd64-12 - type=raw,value=amd64-12.3.0 + type=raw,value=amd64-${{ env.GCC_MAJOR_VERSION }} + type=raw,value=amd64-${{ env.GCC_VERSION }} type=raw,value=amd64-${{ github.sha }} platforms: linux/amd64 + build_args: | + GCC_MAJOR_VERSION=${{ env.GCC_MAJOR_VERSION }} + GCC_VERSION=${{ env.GCC_VERSION }} dockerhub_repo: rippleci/clio_gcc dockerhub_description: GCC compiler for XRPLF/clio. @@ -93,10 +100,13 @@ jobs: directory: docker/compilers/gcc tags: | type=raw,value=arm64-latest - type=raw,value=arm64-12 - type=raw,value=arm64-12.3.0 + type=raw,value=arm64-${{ env.GCC_MAJOR_VERSION }} + type=raw,value=arm64-${{ env.GCC_VERSION }} type=raw,value=arm64-${{ github.sha }} platforms: linux/arm64 + build_args: | + GCC_MAJOR_VERSION=${{ env.GCC_MAJOR_VERSION }} + GCC_VERSION=${{ env.GCC_VERSION }} dockerhub_repo: rippleci/clio_gcc dockerhub_description: GCC compiler for XRPLF/clio. @@ -142,8 +152,8 @@ jobs: for image in ${{ env.GHCR_REPO_LC }}/clio-gcc rippleci/clio_gcc; do docker buildx imagetools create \ -t $image:latest \ - -t $image:12 \ - -t $image:12.3.0 \ + -t $image:${{ env.GCC_MAJOR_VERSION }} \ + -t $image:${{ env.GCC_VERSION }} \ -t $image:${{ github.sha }} \ $image:arm64-latest \ $image:amd64-latest @@ -176,9 +186,11 @@ jobs: directory: docker/compilers/clang tags: | type=raw,value=latest - type=raw,value=16 + type=raw,value=${{ env.CLANG_MAJOR_VERSION }} type=raw,value=${{ github.sha }} platforms: linux/amd64,linux/arm64 + build_args: | + CLANG_MAJOR_VERSION=${{ env.CLANG_MAJOR_VERSION }} dockerhub_repo: rippleci/clio_clang dockerhub_description: Clang compiler for XRPLF/clio. @@ -229,8 +241,11 @@ jobs: directory: docker/ci tags: | type=raw,value=latest - type=raw,value=gcc_12_clang_16 + type=raw,value=gcc_${{ env.GCC_MAJOR_VERSION }}_clang_${{ env.CLANG_MAJOR_VERSION }} type=raw,value=${{ github.sha }} platforms: linux/amd64,linux/arm64 + build_args: | + CLANG_MAJOR_VERSION=${{ env.CLANG_MAJOR_VERSION }} + GCC_VERSION=${{ env.GCC_VERSION }} dockerhub_repo: rippleci/clio_ci dockerhub_description: CI image for XRPLF/clio. diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfile index 99593b91..b8c6ea5a 100644 --- a/docker/ci/Dockerfile +++ b/docker/ci/Dockerfile @@ -1,7 +1,10 @@ -FROM ghcr.io/xrplf/clio-gcc:12.3.0 AS clio-gcc +ARG CLANG_MAJOR_VERSION=invalid +ARG GCC_VERSION=invalid + +FROM ghcr.io/xrplf/clio-gcc:${GCC_VERSION} AS clio-gcc FROM ghcr.io/xrplf/clio-tools:latest AS clio-tools -FROM ghcr.io/xrplf/clio-clang:16 +FROM ghcr.io/xrplf/clio-clang:${CLANG_MAJOR_VERSION} ARG DEBIAN_FRONTEND=noninteractive diff --git a/docker/compilers/clang/Dockerfile b/docker/compilers/clang/Dockerfile index 8219c13f..35d88797 100644 --- a/docker/compilers/clang/Dockerfile +++ b/docker/compilers/clang/Dockerfile @@ -8,8 +8,6 @@ SHELL ["/bin/bash", "-c"] USER root WORKDIR /root -ARG CLANG_VERSION=16 - RUN apt-get update \ && apt-get install -y --no-install-recommends --no-install-suggests \ wget \ @@ -18,13 +16,15 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* +ARG CLANG_MAJOR_VERSION=invalid + RUN wget --progress=dot:giga https://apt.llvm.org/llvm.sh \ && chmod +x llvm.sh \ - && ./llvm.sh ${CLANG_VERSION} \ + && ./llvm.sh ${CLANG_MAJOR_VERSION} \ && rm -rf llvm.sh \ && apt-get update \ && apt-get install -y --no-install-recommends --no-install-suggests \ - libc++-${CLANG_VERSION}-dev \ - libc++abi-${CLANG_VERSION}-dev \ + libc++-${CLANG_MAJOR_VERSION}-dev \ + libc++abi-${CLANG_MAJOR_VERSION}-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/docker/compilers/gcc/Dockerfile b/docker/compilers/gcc/Dockerfile index 94091b7d..804de780 100644 --- a/docker/compilers/gcc/Dockerfile +++ b/docker/compilers/gcc/Dockerfile @@ -1,16 +1,14 @@ ARG UBUNTU_VERSION=20.04 -ARG GCC_MAJOR_VERSION=12 +ARG GCC_MAJOR_VERSION=invalid FROM ubuntu:$UBUNTU_VERSION AS build ARG UBUNTU_VERSION ARG GCC_MAJOR_VERSION -ARG GCC_MINOR_VERSION=3 -ARG GCC_PATCH_VERSION=0 -ARG GCC_VERSION=${GCC_MAJOR_VERSION}.${GCC_MINOR_VERSION}.${GCC_PATCH_VERSION} -ARG BUILD_VERSION=6 + +ARG BUILD_VERSION=7 ARG DEBIAN_FRONTEND=noninteractive ARG TARGETARCH @@ -27,6 +25,8 @@ RUN apt-get update \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* +ARG GCC_VERSION + WORKDIR / RUN wget --progress=dot:giga https://gcc.gnu.org/pub/gcc/releases/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.gz \ && tar xf gcc-$GCC_VERSION.tar.gz