diff --git a/Dockerfile b/Dockerfile index a9086d0..206baad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,6 +27,7 @@ ARG GOLANGCI_LINT_VERSION=v1.33.0-alpine FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS builder WORKDIR /go/src/github.com/docker/hub-tool RUN apk add --no-cache \ + bash \ git \ make @@ -51,6 +52,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/.cache/golangci-lint \ make -f builder.Makefile lint +#### +# VALIDATE HEADERS +#### +FROM builder AS validate-headers +RUN --mount=type=cache,target=/root/.cache/go-build \ + --mount=type=cache,target=/go/pkg \ + go get -u github.com/kunalkushwaha/ltag && ./scripts/validate/fileheader + #### # CHECK GO MOD #### diff --git a/Makefile b/Makefile index f1cb3ca..e8c2d7b 100644 --- a/Makefile +++ b/Makefile @@ -111,9 +111,7 @@ lint: ## Run the go linter .PHONY: validate-headers validate-headers: ## Validate files license header - docker run --rm -v $(CURDIR):/work -w /work \ - golang:${GO_VERSION} \ - bash -c 'go get -u github.com/kunalkushwaha/ltag && ./scripts/validate/fileheader' + @docker build $(BUILD_ARGS) . --target validate-headers .PHONY: validate-go-mod validate-go-mod: ## Validate go.mod and go.sum are up-to-date