diff --git a/10/Dockerfile b/10/Dockerfile index e33d119..c5f0071 100644 --- a/10/Dockerfile +++ b/10/Dockerfile @@ -7,13 +7,13 @@ RUN tools="clang-format-$VERSION clang-tidy-$VERSION" \ && apt-get -y install $tools \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version -RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format -RUN echo "--- Clang-format version ---" -RUN clang-format --version -RUN ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy -RUN echo "--- Clang-tidy version ---" -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/11/Dockerfile b/11/Dockerfile index 1f39f35..e3d2a0f 100644 --- a/11/Dockerfile +++ b/11/Dockerfile @@ -7,13 +7,13 @@ RUN tools="clang-format-$VERSION clang-tidy-$VERSION" \ && apt-get -y install $tools \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version -RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format -RUN echo "--- Clang-format version ---" -RUN clang-format --version -RUN ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy -RUN echo "--- Clang-tidy version ---" -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/12/Dockerfile b/12/Dockerfile index 27c8f51..d663601 100644 --- a/12/Dockerfile +++ b/12/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:latest +FROM ubuntu:20.04 ENV VERSION 12 @@ -7,13 +7,13 @@ RUN tools="clang-format-$VERSION clang-tidy-$VERSION" \ && apt-get -y install $tools \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version -RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format -RUN echo "--- Clang-format version ---" -RUN clang-format --version -RUN ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy -RUN echo "--- Clang-tidy version ---" -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/6/Dockerfile b/6/Dockerfile index a355e5b..3e514cd 100644 --- a/6/Dockerfile +++ b/6/Dockerfile @@ -7,13 +7,13 @@ RUN tools="clang-format-$VERSION clang-tidy-$VERSION" \ && apt-get -y install $tools \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version -RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format -RUN echo "--- Clang-format version ---" -RUN clang-format --version -RUN ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy -RUN echo "--- Clang-tidy version ---" -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/7/Dockerfile b/7/Dockerfile index 32b8dcc..079c490 100644 --- a/7/Dockerfile +++ b/7/Dockerfile @@ -7,13 +7,13 @@ RUN tools="clang-format-$VERSION clang-tidy-$VERSION" \ && apt-get -y install $tools \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version -RUN echo "--- Clang-format version ---" -RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format -RUN clang-format --version -RUN echo "--- Clang-tidy version ---" -RUN ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/8/Dockerfile b/8/Dockerfile index 901bc84..2d532b0 100644 --- a/8/Dockerfile +++ b/8/Dockerfile @@ -7,13 +7,13 @@ RUN tools="clang-format-$VERSION clang-tidy-$VERSION" \ && apt-get -y install $tools \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version -RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format -RUN echo "--- Clang-format version ---" -RUN clang-format --version -RUN ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy -RUN echo "--- Clang-tidy version ---" -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/9/Dockerfile b/9/Dockerfile index 0ecfb03..dc816c3 100644 --- a/9/Dockerfile +++ b/9/Dockerfile @@ -7,13 +7,13 @@ RUN tools="clang-format-$VERSION clang-tidy-$VERSION" \ && apt-get -y install $tools \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version -RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format -RUN echo "--- Clang-format version ---" -RUN clang-format --version -RUN ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy -RUN echo "--- Clang-tidy version ---" -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/Dockerfile-ubuntu.template b/Dockerfile-ubuntu.template index 7627258..52ce04a 100644 --- a/Dockerfile-ubuntu.template +++ b/Dockerfile-ubuntu.template @@ -7,13 +7,13 @@ RUN tools="clang-format-$VERSION clang-tidy-$VERSION" \ && apt-get -y install $tools \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version -RUN ln -s /usr/bin/clang-format-"$VERSION" /usr/bin/clang-format -RUN echo "--- Clang-format version ---" -RUN clang-format --version -RUN ln -s /usr/bin/clang-tidy-"$VERSION" /usr/bin/clang-tidy -RUN echo "--- Clang-tidy version ---" -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7fa5880 --- /dev/null +++ b/Makefile @@ -0,0 +1,65 @@ +# import deploy config +# You can change the default deploy config with `make cnf="deploy_special.env" release` +dpl ?= deploy.env +include $(dpl) +export $(shell sed 's/=.*//' $(dpl)) + +# HELP +# This will output the help for each task +# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +.PHONY: help + +help: ## This help. + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +.DEFAULT_GOAL := help + + +# DOCKER TASKS +build: ## Build a docker image + docker build -t $(APP_NAME) -f $(FILE) . + +build-nc: ## Build a docker image without caching + docker build --no-cache -t $(APP_NAME) -f $(FILE) . + +build-all-nc: ## Build all docker images without caching + for TAG in $(APP_TAGS) ; do \ + docker build --no-cache -t $(APP_NAME):$$TAG -f $$TAG/Dockerfile . ; \ + done + +release: build-nc publish ## Release and publish a docker image to registry + +release-all: build-all-nc docker-login docker-tag-all docker-push-all ## Release and publish all images to registry + +publish: docker-login docker-tag docker-push ## Publish a docker image to registry + +publish-all: docker-login docker-tag-all docker-push-all ## Publish all docker images to registry + +docker-push: ## Docker push a docker image to registry + docker push $(DOCKER_HUB)/$(APP_NAME):$(TAG) + +docker-push-all: ## Docker push all docker images to registry + for TAG in $(APP_TAGS) ; do \ + echo "docker push $(DOCKER_HUB)/$(APP_NAME):$$TAG ... " ; \ + docker push $(DOCKER_HUB)/$(APP_NAME):$$TAG ; \ + done + +docker-tag: ## Docker image create a tag + docker tag $(APP_NAME):$(TAG) $(DOCKER_HUB)/$(APP_NAME):$(TAG) + +docker-tag-all: ## Docker image create all tags + for TAG in $(APP_TAGS) ; do \ + docker tag $(APP_NAME):$$TAG $(DOCKER_HUB)/$(APP_NAME):$$TAG ; \ + done + +docker-login: ## Login to docker hub + docker login + +version: ## Output the all support versions + @echo $(APP_TAGS) + +# Test Makefile syntax. +test: + for TAG in $(APP_TAGS) ; do \ + echo "testing $$TAG" ; \ + done \ No newline at end of file diff --git a/README.md b/README.md index 7245a4d..96bd885 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## Supported tags ![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/xianpengshen/clang-tools/all) -![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/xianpengshen/clang-tools/latest) +![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/xianpengshen/clang-tools/12) ![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/xianpengshen/clang-tools/11) ![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/xianpengshen/clang-tools/10) ![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/xianpengshen/clang-tools/9) @@ -17,7 +17,7 @@ * [clang-tools:all](https://github.com/shenxianpeng/clang-tools/blob/master/all/Dockerfile) (supports all versions of the below tags) -* [clang-tools:latest](https://github.com/shenxianpeng/clang-tools/blob/master/12/Dockerfile) (v12) +* [clang-tools:12](https://github.com/shenxianpeng/clang-tools/blob/master/12/Dockerfile) * [clang-tools:11](https://github.com/shenxianpeng/clang-tools/blob/master/11/Dockerfile) * [clang-tools:10](https://github.com/shenxianpeng/clang-tools/blob/master/10/Dockerfile) * [clang-tools:9](https://github.com/shenxianpeng/clang-tools/blob/master/9/Dockerfile) @@ -27,10 +27,10 @@ ## How to use this image -### Create a `Dockerfile` in your project +### Create a [`Dockerfile`](demo/Dockerfile) in your project ```Dockerfile -FROM xianpengshen/clang-tools +FROM xianpengshen/clang-tools:12 WORKDIR /usr/src/app @@ -64,17 +64,17 @@ $ docker run clang-tools clang-tidy helloworld.c \ If a simple source code, you may find it inconvenient to write a complete `Dockerfile`. In such cases, you can run by using the Docker image directly. ```bash -docker run -v $PWD:/src xianpengshen/clang-tools clang-format -i helloworld.c -docker run -v $PWD:/src xianpengshen/clang-tools clang-tidy helloworld.c \ +docker run -v $PWD:/src xianpengshen/clang-tools:12 clang-format -i helloworld.c +docker run -v $PWD:/src xianpengshen/clang-tools:12 clang-tidy helloworld.c \ -checks=boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-cplusplus-*,clang-analyzer-*,cppcoreguidelines-* ``` -### Run `Dockerfile` with specific verion +### Build `Dockerfile` with specific verion If you want to provide dynamic versions of clang-tools ```Dockerfile -ARG TAG=latest +ARG TAG=12 FROM xianpengshen/clang-tools:$TAG WORKDIR /usr/src/app @@ -84,17 +84,6 @@ COPY . . CMD [ "" ] ``` -Use the latest verion of clang-tools. - -```bash -$ docker build -t mylinter . -Sending build context to Docker daemon 157.7kB -Step 1/13 : ARG TAG=latest -Step 2/13 : FROM xianpengshen/clang-tools:$TAG -latest: Pulling from xianpengshen/clang-tools -Status: Downloaded newer image for xianpengshen/clang-tools:latest -``` - Use specific version of clang-tools by passing `--build-arg` ```bash diff --git a/all/Dockerfile b/all/Dockerfile index ba394eb..9fa4f03 100644 --- a/all/Dockerfile +++ b/all/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:latest +FROM ubuntu:20.04 ARG DEFAULT_VERSION=12 ENV VERSION="12 11 10 9 8 7 6.0" @@ -9,13 +9,13 @@ RUN apt-get update \ apt-get -y install $tools; done \ && rm -rf /var/lib/apt/lists/* -WORKDIR /src +RUN ln -s /usr/bin/clang-format-$DEFAULT_VERSION /usr/bin/clang-format \ + && echo "--- Clang-format version ---" \ + && clang-format --version \ + && ln -s /usr/bin/clang-tidy-$DEFAULT_VERSION /usr/bin/clang-tidy \ + && echo "--- Clang-tidy version ---" \ + && clang-tidy --version \ -RUN ln -s /usr/bin/clang-format-$DEFAULT_VERSION /usr/bin/clang-format -RUN echo "--- Clang-format version ---" -RUN clang-format --version -RUN ln -s /usr/bin/clang-tidy-$DEFAULT_VERSION /usr/bin/clang-tidy -RUN echo "--- Clang-tidy version ---" -RUN clang-tidy --version +WORKDIR /src CMD [""] diff --git a/demo/Dockerfile b/demo/Dockerfile new file mode 100644 index 0000000..1217785 --- /dev/null +++ b/demo/Dockerfile @@ -0,0 +1,7 @@ +FROM xianpengshen/clang-tools:12 + +WORKDIR /usr/src/app + +COPY . . + +CMD [ "" ] \ No newline at end of file diff --git a/compile_commands.json b/demo/compile_commands.json similarity index 100% rename from compile_commands.json rename to demo/compile_commands.json diff --git a/helloworld.c b/demo/helloworld.c similarity index 100% rename from helloworld.c rename to demo/helloworld.c diff --git a/deploy.env b/deploy.env new file mode 100644 index 0000000..f41899f --- /dev/null +++ b/deploy.env @@ -0,0 +1,5 @@ +# You have to define the values in {} +APP_NAME=clang-tools +APP_TAGS=all 12 11 10 9 8 7 6 +DOCKER_HUB=xianpengshen +DOCKER_PKG=ghcr.io/shenxianpeng