diff --git a/.github/workflows/dockerfile-linter.yml b/.github/workflows/dockerfile-linter.yml new file mode 100644 index 0000000..e57330a --- /dev/null +++ b/.github/workflows/dockerfile-linter.yml @@ -0,0 +1,22 @@ +--- +name: Lint Dockerfiles + +on: + push: + branches: + - master + pull_request: + branches: [ master ] + paths: + - 'Dockerfile*' + +jobs: + lint-dockerfiles: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Lint the Dockerfiles + run: | + make lint-all diff --git a/.hadolint.yml b/.hadolint.yml new file mode 100644 index 0000000..2e45b6d --- /dev/null +++ b/.hadolint.yml @@ -0,0 +1,10 @@ +# # Hadolint config file +# # https://hadolint.github.io/hadolint/ + +# Failure mode +failure-threshold: none +no-fail: false + +# Output format +format: tty +no-color: true diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..06d17a5 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +# # Makefile +.DEFAULT_GOAL := all +SHELL := /usr/bin/env sh + + +# # # Help + +.PHONY: help +help: + @echo "Usage: make [TARGET:-all]" + @echo "TARGET:" + @echo " all" + @echo " lint-dockerfile FILE" + @echo " lint-all" + + +# # # Default goal + +.PHONY: all +all: lint-all + $(info Done running 'make all') + + +# # # Lint the Dockerfile + +.PHONY: lint-dockerfile +lint-dockerfile: +ifeq ($(origin FILE), undefined) + @# Usage: make lint-dockerfile FILE=./Dockerfile + $(error variable FILE is not set) +else + docker run \ + --rm \ + --interactive \ + --network=none \ + --volume="$(CURDIR)/.hadolint.yml:/.hadolint.yml:ro" \ + hadolint/hadolint < $(FILE) +endif + + +.PHONY: lint-all lint-all-% +lint-all: $(foreach FILE, $(wildcard $(CURDIR)/Dockerfile*), lint-all-$(notdir $(FILE))) +lint-all-%: + $(MAKE) lint-dockerfile FILE=$(CURDIR)/$*