Skip to content

Commit

Permalink
🧶
Browse files Browse the repository at this point in the history
  • Loading branch information
w13b3 committed Apr 5, 2024
1 parent 0b0b499 commit 11077a1
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/dockerfile-linter.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions .hadolint.yml
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)/$*

0 comments on commit 11077a1

Please sign in to comment.