From 93e66e5d460e509fc17104abe3a99d84ac3d54c9 Mon Sep 17 00:00:00 2001 From: Adrien Leravat Date: Fri, 29 May 2020 15:49:38 -0700 Subject: [PATCH] Add a build/push/run Makefile --- Dockerfile | 5 +++++ Makefile | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile index eeace87..2a2c3e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* ADD run-clang-format/run-clang-format.py /usr/bin +RUN ln -s /usr/bin/python3 /usr/local/bin/python RUN mkdir /src WORKDIR /src + +RUN echo "--- Clang-format version ---" +RUN clang-format --version + ENTRYPOINT ["run-clang-format.py"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d915cdc --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +TAG ?= latest +CMD ?= "-r ." + +DOCKER_REGISTRY = index.docker.io +IMAGE_ORG = witekio +IMAGE_NAME = clang-format-checker +IMAGE_TAG = $(DOCKER_REGISTRY)/$(IMAGE_ORG)/$(IMAGE_NAME):$(TAG) + +WORKING_DIR := $(shell pwd) +DOCKERFILE_DIR := $(WORKING_DIR) + +.DEFAULT_GOAL := build + +.PHONY: build push run + +build:: ## Build the docker image + @echo Building $(IMAGE_TAG) + @docker build --pull \ + -t $(IMAGE_TAG) $(DOCKERFILE_DIR) + +push:: ## Push the docker image to the registry + @echo Pushing $(IMAGE_TAG) + @docker push $(IMAGE_TAG) + +run:: ## Run the docker image + @docker run -v $(pwd):/src -it --rm $(IMAGE_TAG) $(CMD) + +# A help target including self-documenting targets (see the awk statement) +define HELP_TEXT +Usage: make [TARGET]... [MAKEVAR1=SOMETHING]... + +Available targets: +endef +export HELP_TEXT +help: ## This help target + @echo + @echo "$$HELP_TEXT" + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / \ + {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)