Skip to content

Commit 416883f

Browse files
committed
hack: authors Dockerfile and bake target
Signed-off-by: CrazyMax <[email protected]>
1 parent 1b721f4 commit 416883f

File tree

4 files changed

+61
-16
lines changed

4 files changed

+61
-16
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ validate-shfmt:
4242
shfmt:
4343
./hack/shfmt
4444

45+
.PHONY: validate-authors
46+
validate-authors:
47+
$(BUILDX_CMD) bake validate-authors
48+
4549
.PHONY: validate-generated-files
4650
validate-generated-files:
4751
./hack/validate-generated-files
@@ -60,3 +64,7 @@ vendor:
6064
.PHONY: generated-files
6165
generated-files:
6266
./hack/update-generated-files
67+
68+
.PHONY: authors
69+
authors:
70+
$(BUILDX_CMD) bake authors

docker-bake.hcl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
variable "ALPINE_VERSION" {
2+
default = null
3+
}
4+
15
variable "GO_VERSION" {
26
default = null
37
}
48

59
target "_common" {
610
args = {
11+
ALPINE_VERSION = ALPINE_VERSION
712
GO_VERSION = GO_VERSION
813
BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
914
}
@@ -20,9 +25,23 @@ target "validate-vendor" {
2025
output = ["type=cacheonly"]
2126
}
2227

28+
target "validate-authors" {
29+
inherits = ["_common"]
30+
dockerfile = "./hack/dockerfiles/authors.Dockerfile"
31+
target = "validate"
32+
output = ["type=cacheonly"]
33+
}
34+
2335
target "vendor" {
2436
inherits = ["_common"]
2537
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"
2638
target = "update"
2739
output = ["."]
2840
}
41+
42+
target "authors" {
43+
inherits = ["_common"]
44+
dockerfile = "./hack/dockerfiles/authors.Dockerfile"
45+
target = "update"
46+
output = ["."]
47+
}

hack/dockerfiles/authors.Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# syntax=docker/dockerfile-upstream:master
2+
3+
ARG ALPINE_VERSION=3.17
4+
5+
FROM alpine:${ALPINE_VERSION} AS gen
6+
RUN apk add --no-cache git
7+
WORKDIR /src
8+
RUN --mount=type=bind,target=. <<EOT
9+
set -e
10+
mkdir /out
11+
# see also ".mailmap" for how email addresses and names are deduplicated
12+
{
13+
echo "# This file lists all individuals having contributed content to the repository."
14+
echo "# For how it is generated, see hack/dockerfiles/authors.Dockerfile."
15+
echo
16+
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf
17+
} > /out/AUTHORS
18+
cat /out/AUTHORS
19+
EOT
20+
21+
FROM scratch AS update
22+
COPY --from=gen /out /
23+
24+
FROM gen AS validate
25+
RUN --mount=type=bind,target=.,rw <<EOT
26+
set -e
27+
git add -A
28+
cp -rf /out/* .
29+
if [ -n "$(git status --porcelain -- AUTHORS)" ]; then
30+
echo >&2 'ERROR: Authors result differs. Please update with "make authors"'
31+
git status --porcelain -- AUTHORS
32+
exit 1
33+
fi
34+
EOT

hack/generate-authors

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)