From 65dfcd18d49a9ebd0f9a195a7f109c9c0452b0e2 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 23 Sep 2023 11:13:00 -0400 Subject: [PATCH 1/5] refactor: clang-tools Dockerfiles --- .github/workflows/CI.yml | 62 ++++++------- .pre-commit-config.yaml | 1 + 10/Dockerfile | 26 ------ 11/Dockerfile | 26 ------ 12/Dockerfile | 26 ------ 13/Dockerfile | 31 ------- 14/Dockerfile | 31 ------- 14/sources.list.jammy | 42 --------- 15/Dockerfile | 31 ------- 15/sources.list.kinetic | 42 --------- 16/Dockerfile | 30 ------- 6/Dockerfile | 26 ------ 7/Dockerfile | 26 ------ 9/Dockerfile | 26 ------ CONTRIBUTING.md | 10 +-- 8/Dockerfile => Dockerfile | 23 +++-- 11-alpine/Dockerfile => Dockerfile.11-alpine | 0 12-alpine/Dockerfile => Dockerfile.12-alpine | 0 all/Dockerfile => Dockerfile.all | 9 +- all/sources.list.jammy | 42 --------- docker-bake.hcl | 91 ++++++++++++++++---- install.sh | 38 ++++++++ 13/sources.list.jammy => sources.list.jammy | 0 23 files changed, 157 insertions(+), 482 deletions(-) delete mode 100644 10/Dockerfile delete mode 100644 11/Dockerfile delete mode 100644 12/Dockerfile delete mode 100644 13/Dockerfile delete mode 100644 14/Dockerfile delete mode 100644 14/sources.list.jammy delete mode 100644 15/Dockerfile delete mode 100644 15/sources.list.kinetic delete mode 100644 16/Dockerfile delete mode 100644 6/Dockerfile delete mode 100644 7/Dockerfile delete mode 100644 9/Dockerfile rename 8/Dockerfile => Dockerfile (55%) rename 11-alpine/Dockerfile => Dockerfile.11-alpine (100%) rename 12-alpine/Dockerfile => Dockerfile.12-alpine (100%) rename all/Dockerfile => Dockerfile.all (90%) delete mode 100644 all/sources.list.jammy create mode 100755 install.sh rename 13/sources.list.jammy => sources.list.jammy (100%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index cbd3ce2..fea3aab 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -4,12 +4,12 @@ on: push: branches: [ master ] paths: - - '**Dockerfile' + - 'Dockerfile*' - 'docker-bake.hcl' pull_request: branches: [ master ] paths: - - '**Dockerfile' + - 'Dockerfile*' - 'docker-bake.hcl' workflow_dispatch: @@ -25,10 +25,6 @@ jobs: - name: Check formatting run: make install-deps && make lint - - name: Get changed files - id: changed-files - uses: tj-actions/changed-files@v18.4 - - name: Login container registries run: | echo $CR_PAT | docker login ghcr.io -u shenxianpeng --password-stdin @@ -36,42 +32,32 @@ jobs: env: CR_PAT: ${{ secrets.CR_PAT }} - - name: Build & Test Images - run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - if [[ "$file" == *"Dockerfile" ]]; then - set -e - tag=`dirname $file` - echo "start to build clang-tools:$tag" - docker buildx bake --file docker-bake.hcl clang-tools-$tag + - name: Check buildx bake + run: docker buildx bake --file docker-bake.hcl --print - echo "start to test clang-tools:$tag" - if [ $tag == "all" ]; then - clang_versions="16 15 14 13 12 11 10 9 8" - for clang_version in ${clang_versions}; do - docker run ghcr.io/cpp-linter/clang-tools:$tag clang-format-$clang_version --version | grep -E "clang-format version $clang_version" - docker run ghcr.io/cpp-linter/clang-tools:$tag clang-tidy-$clang_version --version | grep "LLVM version $clang_version" - done - elif [[ "$tag" == *"alpine"* ]]; then - docker run ghcr.io/cpp-linter/clang-tools:$tag-3.18 clang-format --version | grep -E "clang-format version" - docker run ghcr.io/cpp-linter/clang-tools:$tag-3.18 clang-tidy --version | grep "LLVM version" - else - docker run ghcr.io/cpp-linter/clang-tools:$tag clang-format --version | grep -E "clang-format version $tag" - docker run ghcr.io/cpp-linter/clang-tools:$tag clang-tidy --version | grep "LLVM version $tag" - fi - fi - done + - name: Build all images + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + run: docker buildx bake --file docker-bake.hcl - - name: Publish Images + - name: Test all images if: github.event_name == 'push' && github.ref == 'refs/heads/master' run: | - for file in ${{ steps.changed-files.outputs.all_changed_files }}; do - if [[ "$file" == *"Dockerfile" ]]; then - tag=`dirname $file` - docker buildx bake --file docker-bake.hcl --push clang-tools-$tag - fi + echo "start to test clang-tools:all" + clang_versions="17 16 15 14 13 12 11 10 9" + for clang_version in ${clang_versions}; do + docker run ghcr.io/cpp-linter/clang-tools:all clang-format-$clang_version --version | grep -E "clang-format version $clang_version" + docker run ghcr.io/cpp-linter/clang-tools:all clang-tidy-$clang_version --version | grep "LLVM version $clang_version" + done + + all_tags="17 16 15 14 13 12 11 10 9 8 7" + for tag in ${all_tags}; do + echo "start to test clang-tools:tag" + docker run ghcr.io/cpp-linter/clang-tools:$tag clang-format --version | grep -E "clang-format version $tag" + docker run ghcr.io/cpp-linter/clang-tools:$tag clang-tidy --version | grep "LLVM version $tag" done + # docker run ghcr.io/cpp-linter/clang-tools:$tag-3.18 clang-format --version | grep -E "clang-format version" + # docker run ghcr.io/cpp-linter/clang-tools:$tag-3.18 clang-tidy --version | grep "LLVM version" - - name: Publish All Images + - name: Publish all images if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master' - run: docker buildx bake --file docker-bake.hcl --push clang-tools + run: docker buildx bake --file docker-bake.hcl --push diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2d7241d..ccf57d9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,7 @@ repos: - id: hadolint-docker args: [ + --ignore,DL3006, --ignore,DL3008, --ignore,DL3018, --ignore,SC2086, diff --git a/10/Dockerfile b/10/Dockerfile deleted file mode 100644 index d1f2cdb..0000000 --- a/10/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:20.04 - -ENV CLANG_VERSION 10 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/11/Dockerfile b/11/Dockerfile deleted file mode 100644 index 75b2b70..0000000 --- a/11/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:22.04 - -ENV CLANG_VERSION 11 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/12/Dockerfile b/12/Dockerfile deleted file mode 100644 index 239ab32..0000000 --- a/12/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:22.04 - -ENV CLANG_VERSION 12 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/13/Dockerfile b/13/Dockerfile deleted file mode 100644 index 0b0a62e..0000000 --- a/13/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM ubuntu:22.04 - -ENV CLANG_VERSION 13 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN mv /etc/apt/sources.list /etc/apt/sources.list.focal - -COPY 13/sources.list.jammy /etc/apt/sources.list - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && mv /etc/apt/sources.list.focal /etc/apt/sources.list \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/14/Dockerfile b/14/Dockerfile deleted file mode 100644 index 8d6b1a4..0000000 --- a/14/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM ubuntu:22.04 - -ENV CLANG_VERSION 14 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN mv /etc/apt/sources.list /etc/apt/sources.list.focal - -COPY 14/sources.list.jammy /etc/apt/sources.list - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && mv /etc/apt/sources.list.focal /etc/apt/sources.list \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/14/sources.list.jammy b/14/sources.list.jammy deleted file mode 100644 index f9510d3..0000000 --- a/14/sources.list.jammy +++ /dev/null @@ -1,42 +0,0 @@ -# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to -# newer versions of the distribution. -deb http://archive.ubuntu.com/ubuntu/ jammy main restricted -# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted - -## Major bug fix updates produced after the final release of the -## distribution. -deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team. Also, please note that software in universe WILL NOT receive any -## review or updates from the Ubuntu security team. -deb http://archive.ubuntu.com/ubuntu/ jammy universe -# deb-src http://archive.ubuntu.com/ubuntu/ jammy universe -deb http://archive.ubuntu.com/ubuntu/ jammy-updates universe -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates universe - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb http://archive.ubuntu.com/ubuntu/ jammy multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy multiverse -deb http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse - -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse - -deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted -deb http://security.ubuntu.com/ubuntu/ jammy-security universe -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universe -deb http://security.ubuntu.com/ubuntu/ jammy-security multiverse -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiverse diff --git a/15/Dockerfile b/15/Dockerfile deleted file mode 100644 index e37e0f8..0000000 --- a/15/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM ubuntu:22.04 - -ENV CLANG_VERSION 15 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN mv /etc/apt/sources.list /etc/apt/sources.list.focal - -COPY 15/sources.list.kinetic /etc/apt/sources.list - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && mv /etc/apt/sources.list.focal /etc/apt/sources.list \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/15/sources.list.kinetic b/15/sources.list.kinetic deleted file mode 100644 index 647ae45..0000000 --- a/15/sources.list.kinetic +++ /dev/null @@ -1,42 +0,0 @@ -# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to -# newer versions of the distribution. -deb http://archive.ubuntu.com/ubuntu/ kinetic main restricted -# deb-src http://archive.ubuntu.com/ubuntu/ kinetic main restricted - -## Major bug fix updates produced after the final release of the -## distribution. -deb http://archive.ubuntu.com/ubuntu/ kinetic-updates main restricted -# deb-src http://archive.ubuntu.com/ubuntu/ kinetic-updates main restricted - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team. Also, please note that software in universe WILL NOT receive any -## review or updates from the Ubuntu security team. -deb http://archive.ubuntu.com/ubuntu/ kinetic universe -# deb-src http://archive.ubuntu.com/ubuntu/ kinetic universe -deb http://archive.ubuntu.com/ubuntu/ kinetic-updates universe -# deb-src http://archive.ubuntu.com/ubuntu/ kinetic-updates universe - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb http://archive.ubuntu.com/ubuntu/ kinetic multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ kinetic multiverse -deb http://archive.ubuntu.com/ubuntu/ kinetic-updates multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ kinetic-updates multiverse - -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -deb http://archive.ubuntu.com/ubuntu/ kinetic-backports main restricted universe multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ kinetic-backports main restricted universe multiverse - -deb http://security.ubuntu.com/ubuntu/ kinetic-security main restricted -# deb-src http://security.ubuntu.com/ubuntu/ kinetic-security main restricted -deb http://security.ubuntu.com/ubuntu/ kinetic-security universe -# deb-src http://security.ubuntu.com/ubuntu/ kinetic-security universe -deb http://security.ubuntu.com/ubuntu/ kinetic-security multiverse -# deb-src http://security.ubuntu.com/ubuntu/ kinetic-security multiverse diff --git a/16/Dockerfile b/16/Dockerfile deleted file mode 100644 index 43fb0ef..0000000 --- a/16/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -FROM ubuntu:22.04 - -ENV CLANG_VERSION 16 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -WORKDIR /src - -RUN apt-get update \ - && apt-get --no-install-recommends -y install lsb-release wget software-properties-common gnupg \ - && wget --quiet https://apt.llvm.org/llvm.sh \ - && chmod +x llvm.sh \ - && ./llvm.sh $CLANG_VERSION && rm -rf llvm.sh \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -CMD [""] diff --git a/6/Dockerfile b/6/Dockerfile deleted file mode 100644 index 4d5d4e4..0000000 --- a/6/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:20.04 - -ENV CLANG_VERSION 6.0 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/7/Dockerfile b/7/Dockerfile deleted file mode 100644 index d08282a..0000000 --- a/7/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:20.04 - -ENV CLANG_VERSION 7 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/9/Dockerfile b/9/Dockerfile deleted file mode 100644 index 70caae9..0000000 --- a/9/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:20.04 - -ENV CLANG_VERSION 9 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /src - -CMD [""] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 454ef36..4fc88da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,15 +15,15 @@ Please note that by contributing any code or documentation to this repository (b ## Build image with [`docker buildx bake`](https://docs.docker.com/engine/reference/commandline/buildx_bake/) > **Note** -> Becasue I used buildx [matrix-builds](https://docs.docker.com/build/bake/configuring-build/#matrix-builds), `buildx` version must be v0.11.0 or above. +> I used buildx [matrix-builds](https://docs.docker.com/build/bake/configuring-build/#matrix-builds), so `buildx` version must be v0.11.0 or above. ```bash -# Build all docker iamges -docker buildx bake --file docker-bake.hcl clang-tools +# Build all docker images +docker buildx bake --file docker-bake.hcl # Build specific version of clang-tools docker images -docker buildx bake --file docker-bake.hcl clang-tools:16 +docker buildx bake --file docker-bake.hcl 16 # If want to docker build and push images, add `--push` flag. -docker buildx bake --file docker-bake.hcl --push clang-tools:16 +docker buildx bake --file docker-bake.hcl --push 16 ``` diff --git a/8/Dockerfile b/Dockerfile similarity index 55% rename from 8/Dockerfile rename to Dockerfile index c99ce7c..14e4914 100644 --- a/8/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ -FROM ubuntu:20.04 +ARG BASE_IMAGE +FROM $BASE_IMAGE -ENV CLANG_VERSION 8 +ARG CLANG_VERSION LABEL \ org.opencontainers.image.vendor="cpp-linter team" \ @@ -11,16 +12,14 @@ LABEL \ org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ org.opencontainers.image.licenses="MIT" -RUN apt-get update \ - && apt-get --no-install-recommends -y install clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION \ - && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ - && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version \ - && rm -rf /var/lib/apt/lists/* - WORKDIR /src +COPY install.sh install.sh + +RUN apt-get update \ + && chmod +x install.sh \ + && ./install.sh "$CLANG_VERSION" \ + && rm -rf /var/lib/apt/lists/* \ + && rm install.sh + CMD [""] diff --git a/11-alpine/Dockerfile b/Dockerfile.11-alpine similarity index 100% rename from 11-alpine/Dockerfile rename to Dockerfile.11-alpine diff --git a/12-alpine/Dockerfile b/Dockerfile.12-alpine similarity index 100% rename from 12-alpine/Dockerfile rename to Dockerfile.12-alpine diff --git a/all/Dockerfile b/Dockerfile.all similarity index 90% rename from all/Dockerfile rename to Dockerfile.all index c933665..e6e71e6 100644 --- a/all/Dockerfile +++ b/Dockerfile.all @@ -1,4 +1,5 @@ -FROM ubuntu:20.04 +ARG BASE_IMAGE +FROM $BASE_IMAGE LABEL \ org.opencontainers.image.vendor="cpp-linter team" \ @@ -9,7 +10,7 @@ LABEL \ org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ org.opencontainers.image.licenses="MIT" -ENV CLANG_VERSIONS="12 11 10 9 8" +ENV CLANG_VERSIONS="12 11 10 9" RUN set -ex \ && apt-get update \ @@ -18,7 +19,7 @@ RUN set -ex \ && rm -rf /var/lib/apt/lists/* -ENV CLANG_VERSIONS="16 15 14 13" +ENV CLANG_VERSIONS="17 16 15 14 13" WORKDIR /tmp @@ -35,7 +36,7 @@ RUN set -ex \ # Integrity testing -ENV CLANG_VERSIONS="16 15 14 13 12 11 10 9 8" +ENV CLANG_VERSIONS="17 16 15 14 13 12 11 10 9" RUN set -ex \ && for VERSION in $CLANG_VERSIONS; do \ clang-format-$VERSION --version \ diff --git a/all/sources.list.jammy b/all/sources.list.jammy deleted file mode 100644 index f9510d3..0000000 --- a/all/sources.list.jammy +++ /dev/null @@ -1,42 +0,0 @@ -# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to -# newer versions of the distribution. -deb http://archive.ubuntu.com/ubuntu/ jammy main restricted -# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted - -## Major bug fix updates produced after the final release of the -## distribution. -deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team. Also, please note that software in universe WILL NOT receive any -## review or updates from the Ubuntu security team. -deb http://archive.ubuntu.com/ubuntu/ jammy universe -# deb-src http://archive.ubuntu.com/ubuntu/ jammy universe -deb http://archive.ubuntu.com/ubuntu/ jammy-updates universe -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates universe - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb http://archive.ubuntu.com/ubuntu/ jammy multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy multiverse -deb http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse - -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse - -deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted -deb http://security.ubuntu.com/ubuntu/ jammy-security universe -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universe -deb http://security.ubuntu.com/ubuntu/ jammy-security multiverse -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiverse diff --git a/docker-bake.hcl b/docker-bake.hcl index ffd4c93..e8d0bdc 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -1,20 +1,18 @@ # ---- groups ---- -group "clang-tools" { +group "default" { targets = [ - "clang-tools-6", - "clang-tools-7", - "clang-tools-8", - "clang-tools-9", - "clang-tools-10", - "clang-tools-11", - "clang-tools-11-alpine", - "clang-tools-12", - "clang-tools-12-alpine", - "clang-tools-13", - "clang-tools-14", - "clang-tools-15", - "clang-tools-16", - "clang-tools-all", + "all", + "17", + "16", + "15", + "14", + "13", + "12", + "11", + "10", + "9", + "8", + "7", ] } @@ -34,11 +32,68 @@ variable "ALPINE_VERSION" { # ---- targets ---- target "clang-tools" { matrix = { - tgt = ["all", "16", "15", "14", "13", "12", "12-alpine", "11", "11-alpine", "10", "9", "8", "7", "6"] + tgt = ["all"] } - name = "clang-tools-${tgt}" - dockerfile = "${tgt}/Dockerfile" + name = "${tgt}" + dockerfile = "Dockerfile.${tgt}" context = "." + args = { + BASE_IMAGE="ubuntu:20.04" + } + tags = [ + "${DOCKER_REPO}:${tgt}", + "${GITHUB_REPO}:${tgt}" + ] + platforms = ["linux/amd64"] +} + +target "clang-tools" { + matrix = { + tgt = ["17", "16", "15", "14", "13"] + } + name = "${tgt}" + dockerfile = "Dockerfile" + context = "." + args = { + BASE_IMAGE="ubuntu:23.10" + CLANG_VERSION="${tgt}", + } + tags = [ + "${DOCKER_REPO}:${tgt}", + "${GITHUB_REPO}:${tgt}" + ] + platforms = ["linux/amd64"] +} + +target "clang-tools" { + matrix = { + tgt = ["12", "11"] + } + name = "${tgt}" + dockerfile = "Dockerfile" + context = "." + args = { + BASE_IMAGE="ubuntu:22.04" + CLANG_VERSION="${tgt}", + } + tags = [ + "${DOCKER_REPO}:${tgt}", + "${GITHUB_REPO}:${tgt}" + ] + platforms = ["linux/amd64"] +} + +target "clang-tools" { + matrix = { + tgt = ["10", "9", "8", "7"] + } + name = "${tgt}" + dockerfile = "Dockerfile" + context = "." + args = { + BASE_IMAGE="ubuntu:20.04" + CLANG_VERSION="${tgt}", + } tags = [ "${DOCKER_REPO}:${tgt}", "${GITHUB_REPO}:${tgt}" diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..5d72d3c --- /dev/null +++ b/install.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e +set -x + +CLANG_VERSION=$1 +# clang-tools:17, clang-tools:16, etc. +TAG_VERSIONS="17 16 15 14 13 12 11 10 9 8 7" +# clang-tools:all, all includes following versions. +TAG_ALL_VERSIONS="17 16 15 14 13 12 11 10 9" + +apt_get_install(){ + local version=$1 + apt-get --no-install-recommends -y install \ + clang-format-"$version" \ + clang-tidy-"$version" +} + +print_version(){ + local version=$1 + clang-format-"$version" --version + clang-tidy-"$version" --version +} + +if [[ $TAG_VERSIONS =~ $CLANG_VERSION ]]; then + apt_get_install "$CLANG_VERSION" +elif [[ "all" == "$CLANG_VERSION" ]]; then + for version in $TAG_ALL_VERSIONS; do + apt_get_install "$version" + print_version "$version" + done + exit 0 +else + echo "$CLANG_VERSION not support." + exit 1 +fi + +print_version "$CLANG_VERSION" +exit 0 diff --git a/13/sources.list.jammy b/sources.list.jammy similarity index 100% rename from 13/sources.list.jammy rename to sources.list.jammy From 9654648c55fdcf0e2937f82b9846aa6e068de427 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 23 Sep 2023 11:20:48 -0400 Subject: [PATCH 2/5] fix: update readme and fix snky --- .github/workflows/snyk-container.yml | 6 +++--- README.md | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/snyk-container.yml b/.github/workflows/snyk-container.yml index 1a4fcb3..933e915 100644 --- a/.github/workflows/snyk-container.yml +++ b/.github/workflows/snyk-container.yml @@ -12,11 +12,11 @@ on: push: branches: [ master ] paths: - - '**Dockerfile' + - 'Dockerfile*' pull_request: branches: [ master ] paths: - - '**Dockerfile' + - 'Dockerfile*' jobs: snyk: @@ -33,7 +33,7 @@ jobs: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: image: xianpengshen/clang-tools:all - args: --severity-threshold=high --file=all/Dockerfile + args: --severity-threshold=high --file=Dockerfile.all - name: Upload result to GitHub Code Scanning uses: github/codeql-action/upload-sarif@v2 diff --git a/README.md b/README.md index 4205548..9d63f42 100644 --- a/README.md +++ b/README.md @@ -12,20 +12,20 @@ You can find clang-tools docker images on Docker Hub [registry](https://hub.docker.com/r/xianpengshen/clang-tools) or GitHub Packages [registry](https://github.com/cpp-linter/clang-tools-docker/pkgs/container/clang-tools) -* [`all`](https://github.com/cpp-linter/clang-tools-docker/blob/master/all/Dockerfile) (include tags `16`, `15`, `14`, `13`, `12`, `11`, `10`, `9`, `8`) -* [`16`](https://github.com/cpp-linter/clang-tools-docker/blob/master/16/Dockerfile) -* [`15`](https://github.com/cpp-linter/clang-tools-docker/blob/master/15/Dockerfile) -* [`14`](https://github.com/cpp-linter/clang-tools-docker/blob/master/14/Dockerfile) -* [`13`](https://github.com/cpp-linter/clang-tools-docker/blob/master/13/Dockerfile) -* [`12-alpine-3.18`](https://github.com/cpp-linter/clang-tools-docker/blob/master/12-alpine/Dockerfile) -* [`12`](https://github.com/cpp-linter/clang-tools-docker/blob/master/12/Dockerfile) -* [`11-alpine-3.18`](https://github.com/cpp-linter/clang-tools-docker/blob/master/11-alpine/Dockerfile) -* [`11`](https://github.com/cpp-linter/clang-tools-docker/blob/master/11/Dockerfile) -* [`10`](https://github.com/cpp-linter/clang-tools-docker/blob/master/10/Dockerfile) -* [`9`](https://github.com/cpp-linter/clang-tools-docker/blob/master/9/Dockerfile) -* [`8`](https://github.com/cpp-linter/clang-tools-docker/blob/master/8/Dockerfile) -* [`7`](https://github.com/cpp-linter/clang-tools-docker/blob/master/7/Dockerfile) -* [`6`](https://github.com/cpp-linter/clang-tools-docker/blob/master/6/Dockerfile) +* [`all`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile.all) (include tags `17`, `16`, `15`, `14`, `13`, `12`, `11`, `10`, `9`) +* [`17`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`16`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`15`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`14`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`13`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) + +* [`12`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) + +* [`11`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`10`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`9`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`8`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`7`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) ## How to use this image From 94d84d8c04d653bfc043014c737871318830a69a Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sat, 23 Sep 2023 11:24:16 -0400 Subject: [PATCH 3/5] chore: remoev set -x --- install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install.sh b/install.sh index 5d72d3c..6af910f 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,5 @@ #!/bin/bash set -e -set -x CLANG_VERSION=$1 # clang-tools:17, clang-tools:16, etc. From 0c15dc8fd210402c3dfd7d78e2e8728d793c0225 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sun, 24 Sep 2023 10:10:11 -0400 Subject: [PATCH 4/5] chore: Dockerfiles cleanup and updates --- .github/CODEOWNERS | 1 + Dockerfile | 19 +++++---- Dockerfile.12-alpine | 23 ---------- Dockerfile.11-alpine => Dockerfile.alpine | 5 ++- README.md | 52 ++++++----------------- demo/Dockerfile | 2 +- docker-bake.hcl | 35 +++++++++------ install.sh | 37 ---------------- sources.list.jammy | 42 ------------------ 9 files changed, 51 insertions(+), 165 deletions(-) create mode 100644 .github/CODEOWNERS delete mode 100644 Dockerfile.12-alpine rename Dockerfile.11-alpine => Dockerfile.alpine (93%) delete mode 100755 install.sh delete mode 100644 sources.list.jammy diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..4f08a45 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @shenxianpeng diff --git a/Dockerfile b/Dockerfile index 14e4914..2d25457 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,14 +12,17 @@ LABEL \ org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ org.opencontainers.image.licenses="MIT" -WORKDIR /src - -COPY install.sh install.sh +RUN set -ex \ + && apt-get update \ + && apt-get --no-install-recommends -y install \ + clang-format-"$CLANG_VERSION" \ + clang-tidy-"$CLANG_VERSION" \ + && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ + && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ + && clang-format --version \ + && clang-tidy --version \ + && rm -rf /var/lib/apt/lists/* -RUN apt-get update \ - && chmod +x install.sh \ - && ./install.sh "$CLANG_VERSION" \ - && rm -rf /var/lib/apt/lists/* \ - && rm install.sh +WORKDIR /src CMD [""] diff --git a/Dockerfile.12-alpine b/Dockerfile.12-alpine deleted file mode 100644 index d367e94..0000000 --- a/Dockerfile.12-alpine +++ /dev/null @@ -1,23 +0,0 @@ -FROM alpine:3.18 - -ENV CLANG_VERSION 12 - -LABEL \ - org.opencontainers.image.vendor="cpp-linter team" \ - org.opencontainers.image.title="Unofficial Clang Tools Docker image" \ - org.opencontainers.image.description="The Clang Tools Docker image includes the clang-format and clang-tidy." \ - org.opencontainers.image.version="clang-tools:${CLANG_VERSION}" \ - org.opencontainers.image.url="https://hub.docker.com/r/xianpengshen/clang-tools" \ - org.opencontainers.image.source="https://github.com/cpp-linter/clang-tools-docker" \ - org.opencontainers.image.licenses="MIT" - -RUN apk update \ - && apk add --no-cache clang-extra-tools \ - && echo "--- Clang-format version ---" \ - && clang-format --version \ - && echo "--- Clang-tidy version ---" \ - && clang-tidy --version - -WORKDIR /src - -CMD [""] diff --git a/Dockerfile.11-alpine b/Dockerfile.alpine similarity index 93% rename from Dockerfile.11-alpine rename to Dockerfile.alpine index a21743d..bbca6b7 100644 --- a/Dockerfile.11-alpine +++ b/Dockerfile.alpine @@ -1,6 +1,7 @@ -FROM alpine:3.18 +ARG BASE_IMAGE +FROM $BASE_IMAGE -ENV CLANG_VERSION 11 +ARG CLANG_VERSION LABEL \ org.opencontainers.image.vendor="cpp-linter team" \ diff --git a/README.md b/README.md index 9d63f42..18b2d7c 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,11 @@ You can find clang-tools docker images on Docker Hub [registry](https://hub.dock * [`all`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile.all) (include tags `17`, `16`, `15`, `14`, `13`, `12`, `11`, `10`, `9`) * [`17`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) * [`16`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) +* [`16-alpine`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile.alpine) * [`15`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) * [`14`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) * [`13`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) - * [`12`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) - * [`11`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) * [`10`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) * [`9`](https://github.com/cpp-linter/clang-tools-docker/blob/master/Dockerfile) @@ -33,28 +32,25 @@ You can find clang-tools docker images on Docker Hub [registry](https://hub.dock ```bash # Check clang-format version -$ docker run xianpengshen/clang-tools:12 clang-format --version -Ubuntu clang-format version 12.0.0-3ubuntu1~20.04.4 +$ docker run xianpengshen/clang-tools:17 clang-format --version +Ubuntu clang-format version 17.0.0 (+rc4-1~exp5ubuntu1) # Format code (helloworld.c in the demo directory) -$ docker run -v $PWD:/src xianpengshen/clang-tools:12 clang-format --dry-run -i helloworld.c +$ docker run -v $PWD:/src xianpengshen/clang-tools:17 clang-format --dry-run -i helloworld.c # Check clang-tidy version -$ docker run xianpengshen/clang-tools:12 clang-tidy --version -LLVM (http://llvm.org/): - LLVM version 12.0.0 - +$ docker run xianpengshen/clang-tools:17 clang-tidy --version +Ubuntu LLVM version 17.0.0 Optimized build. - Default target: x86_64-pc-linux-gnu - Host CPU: cascadelake + # Diagnostic code (helloworld.c in the demo directory) -$ docker run -v $PWD:/src xianpengshen/clang-tools:12 clang-tidy helloworld.c \ +$ docker run -v $PWD:/src xianpengshen/clang-tools:17 clang-tidy helloworld.c \ -checks=boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-cplusplus-*,clang-analyzer-*,cppcoreguidelines-* ``` ### As base image in [`Dockerfile`](https://github.com/cpp-linter/clang-tools-docker/blob/master/demo/Dockerfile) ```Dockerfile -FROM xianpengshen/clang-tools:12 +FROM xianpengshen/clang-tools:17 WORKDIR /src @@ -70,43 +66,19 @@ $ docker build -t clang-tools . # Check clang-format version $ docker run clang-tools clang-format --version -Ubuntu clang-format version 12.0.0-3ubuntu1~20.04.3 +Ubuntu clang-format version 17.0.0 (+rc4-1~exp5ubuntu1) # Format code $ docker run clang-tools clang-format --dry-run -i helloworld.c # Check clang-tidy version $ docker run clang-tools clang-tidy --version -LLVM (http://llvm.org/): - LLVM version 12.0.0 +Ubuntu LLVM version 17.0.0 + Optimized build. # Diagnostic code $ docker run clang-tools clang-tidy helloworld.c \ -checks=boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-cplusplus-*,clang-analyzer-*,cppcoreguidelines-* ``` -### Use specific tag in `Dockerfile` - -If you want to use a specific tag of clang-tools, you can build image by passing `--build-arg` - -```Dockerfile -ARG TAG=12 -FROM xianpengshen/clang-tools:$TAG - -WORKDIR /src - -COPY . . - -CMD [ "" ] -``` - -```bash -$ docker build -t mylinter --build-arg TAG=11 . -Sending build context to Docker daemon 148kB -Step 1/13 : ARG TAG=latest -Step 2/13 : FROM xianpengshen/clang-tools:$TAG -11: Pulling from xianpengshen/clang-tools -Status: Downloaded newer image for xianpengshen/clang-tools:11 -``` - ## Have question or feedback? To provide feedback (requesting a feature or reporting a bug) please post to [issues](https://github.com/cpp-linter/clang-tools-docker/issues). diff --git a/demo/Dockerfile b/demo/Dockerfile index da95a3d..3b3d427 100644 --- a/demo/Dockerfile +++ b/demo/Dockerfile @@ -1,4 +1,4 @@ -FROM xianpengshen/clang-tools:12 +FROM xianpengshen/clang-tools:17 WORKDIR /usr/src/app diff --git a/docker-bake.hcl b/docker-bake.hcl index e8d0bdc..880a40f 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -4,6 +4,7 @@ group "default" { "all", "17", "16", + "16-alpine", "15", "14", "13", @@ -25,24 +26,16 @@ variable "GITHUB_REPO" { default = "ghcr.io/cpp-linter/clang-tools" } -variable "ALPINE_VERSION" { - default = "3.18" -} - # ---- targets ---- -target "clang-tools" { - matrix = { - tgt = ["all"] - } - name = "${tgt}" - dockerfile = "Dockerfile.${tgt}" +target "all" { + dockerfile = "Dockerfile.all" context = "." args = { BASE_IMAGE="ubuntu:20.04" } tags = [ - "${DOCKER_REPO}:${tgt}", - "${GITHUB_REPO}:${tgt}" + "${DOCKER_REPO}:all", + "${GITHUB_REPO}:all" ] platforms = ["linux/amd64"] } @@ -100,3 +93,21 @@ target "clang-tools" { ] platforms = ["linux/amd64"] } + +target "clang-tools" { + matrix = { + tgt = ["16-alpine"] + } + name = "${tgt}" + dockerfile = "Dockerfile.alpine" + context = "." + args = { + BASE_IMAGE="alpine:3.18", + CLANG_VERSION="${tgt}", + } + tags = [ + "${DOCKER_REPO}:${tgt}", + "${GITHUB_REPO}:${tgt}" + ] + platforms = ["linux/amd64"] +} diff --git a/install.sh b/install.sh deleted file mode 100755 index 6af910f..0000000 --- a/install.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -set -e - -CLANG_VERSION=$1 -# clang-tools:17, clang-tools:16, etc. -TAG_VERSIONS="17 16 15 14 13 12 11 10 9 8 7" -# clang-tools:all, all includes following versions. -TAG_ALL_VERSIONS="17 16 15 14 13 12 11 10 9" - -apt_get_install(){ - local version=$1 - apt-get --no-install-recommends -y install \ - clang-format-"$version" \ - clang-tidy-"$version" -} - -print_version(){ - local version=$1 - clang-format-"$version" --version - clang-tidy-"$version" --version -} - -if [[ $TAG_VERSIONS =~ $CLANG_VERSION ]]; then - apt_get_install "$CLANG_VERSION" -elif [[ "all" == "$CLANG_VERSION" ]]; then - for version in $TAG_ALL_VERSIONS; do - apt_get_install "$version" - print_version "$version" - done - exit 0 -else - echo "$CLANG_VERSION not support." - exit 1 -fi - -print_version "$CLANG_VERSION" -exit 0 diff --git a/sources.list.jammy b/sources.list.jammy deleted file mode 100644 index f9510d3..0000000 --- a/sources.list.jammy +++ /dev/null @@ -1,42 +0,0 @@ -# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to -# newer versions of the distribution. -deb http://archive.ubuntu.com/ubuntu/ jammy main restricted -# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted - -## Major bug fix updates produced after the final release of the -## distribution. -deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team. Also, please note that software in universe WILL NOT receive any -## review or updates from the Ubuntu security team. -deb http://archive.ubuntu.com/ubuntu/ jammy universe -# deb-src http://archive.ubuntu.com/ubuntu/ jammy universe -deb http://archive.ubuntu.com/ubuntu/ jammy-updates universe -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates universe - -## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu -## team, and may not be under a free licence. Please satisfy yourself as to -## your rights to use the software. Also, please note that software in -## multiverse WILL NOT receive any review or updates from the Ubuntu -## security team. -deb http://archive.ubuntu.com/ubuntu/ jammy multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy multiverse -deb http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse - -## N.B. software from this repository may not have been tested as -## extensively as that contained in the main release, although it includes -## newer versions of some applications which may provide useful features. -## Also, please note that software in backports WILL NOT receive any review -## or updates from the Ubuntu security team. -deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse -# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse - -deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted -deb http://security.ubuntu.com/ubuntu/ jammy-security universe -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security universe -deb http://security.ubuntu.com/ubuntu/ jammy-security multiverse -# deb-src http://security.ubuntu.com/ubuntu/ jammy-security multiverse From 101eec831a21f60e77a6ba1c669d3ef52b164a32 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Sun, 24 Sep 2023 10:18:43 -0400 Subject: [PATCH 5/5] chore: update Dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2d25457..399fba1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,8 @@ LABEL \ RUN set -ex \ && apt-get update \ && apt-get --no-install-recommends -y install \ - clang-format-"$CLANG_VERSION" \ - clang-tidy-"$CLANG_VERSION" \ + clang-format-$CLANG_VERSION \ + clang-format-$CLANG_VERSION \ && ln -s /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format \ && ln -s /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy \ && clang-format --version \