File tree Expand file tree Collapse file tree 5 files changed +80
-65
lines changed Expand file tree Collapse file tree 5 files changed +80
-65
lines changed Original file line number Diff line number Diff line change 1
1
prefix =/usr/local
2
2
bindir =$(prefix ) /bin
3
3
4
- binaries : FORCE
4
+ export BUILDX_CMD ?= docker buildx
5
+
6
+ .PHONY : binaries
7
+ binaries :
5
8
hack/binaries
6
9
7
- images : FORCE
10
+ .PHONY : images
11
+ images :
8
12
# moby/buildkit:local and moby/buildkit:local-rootless are created on Docker
9
13
hack/images local moby/buildkit
10
14
TARGET=rootless hack/images local moby/buildkit
11
15
12
- install : FORCE
16
+ .PHONY : install
17
+ install :
13
18
mkdir -p $(DESTDIR )$(bindir )
14
19
install bin/* $(DESTDIR )$(bindir )
15
20
16
- clean : FORCE
21
+ .PHONY : clean
22
+ clean :
17
23
rm -rf ./bin
18
24
25
+ .PHONY : test
19
26
test :
20
27
./hack/test integration gateway dockerfile
21
28
29
+ .PHONY : lint
22
30
lint :
23
31
./hack/lint
24
32
33
+ .PHONY : validate-vendor
25
34
validate-vendor :
26
- ./hack/ validate-vendor
35
+ $( BUILDX_CMD ) bake validate-vendor
27
36
37
+ .PHONY : validate-shfmt
28
38
validate-shfmt :
29
39
./hack/validate-shfmt
30
40
41
+ .PHONY : shfmt
31
42
shfmt :
32
43
./hack/shfmt
33
44
45
+ .PHONY : validate-generated-files
34
46
validate-generated-files :
35
47
./hack/validate-generated-files
36
48
49
+ .PHONY : validate-all
37
50
validate-all : test lint validate-vendor validate-generated-files
38
51
52
+ .PHONY : vendor
39
53
vendor :
40
- ./hack/update-vendor
54
+ $(eval $@ _TMP_OUT := $(shell mktemp -d -t buildkit-output.XXXXXXXXXX) )
55
+ $(BUILDX_CMD ) bake --set " *.output=type=local,dest=$( $@ _TMP_OUT) " vendor
56
+ rm -rf ./vendor
57
+ cp -R " $( $@ _TMP_OUT) " /out/* .
58
+ rm -rf " $( $@ _TMP_OUT) " /
41
59
60
+ .PHONY : generated-files
42
61
generated-files :
43
62
./hack/update-generated-files
44
-
45
- .PHONY : vendor generated-files test binaries images install clean lint validate-all validate-vendor validate-generated-files
46
- FORCE :
Original file line number Diff line number Diff line change
1
+ variable "GO_VERSION" {
2
+ default = null
3
+ }
4
+
5
+ target "_common" {
6
+ args = {
7
+ GO_VERSION = GO_VERSION
8
+ BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
9
+ }
10
+ }
11
+
12
+ group "validate" {
13
+ targets = [" validate-vendor" ]
14
+ }
15
+
16
+ target "validate-vendor" {
17
+ inherits = [" _common" ]
18
+ dockerfile = " ./hack/dockerfiles/vendor.Dockerfile"
19
+ target = " validate"
20
+ output = [" type=cacheonly" ]
21
+ }
22
+
23
+ target "vendor" {
24
+ inherits = [" _common" ]
25
+ dockerfile = " ./hack/dockerfiles/vendor.Dockerfile"
26
+ target = " update"
27
+ output = [" ." ]
28
+ }
Original file line number Diff line number Diff line change 2
2
3
3
ARG GO_VERSION=1.20
4
4
5
- FROM golang:${GO_VERSION}-alpine AS vendored
6
- RUN apk add --no-cache git
5
+ FROM golang:${GO_VERSION}-alpine AS base
6
+ RUN apk add --no-cache git rsync
7
7
WORKDIR /src
8
- RUN --mount=target=/src,rw \
9
- --mount=target=/go/pkg/mod,type=cache \
10
- go mod tidy && go mod vendor && \
11
- mkdir /out && cp -r go.mod go.sum vendor /out
8
+
9
+ FROM base AS vendored
10
+ RUN --mount=target=/context \
11
+ --mount=target=.,type=tmpfs \
12
+ --mount=target=/go/pkg/mod,type=cache <<EOT
13
+ set -e
14
+ rsync -a /context/. .
15
+ go mod tidy
16
+ go mod vendor
17
+ mkdir /out
18
+ cp -r go.mod go.sum vendor /out
19
+ EOT
12
20
13
21
FROM scratch AS update
14
22
COPY --from=vendored /out /out
15
23
16
24
FROM vendored AS validate
17
- RUN --mount=target=.,rw \
18
- git add -A && \
19
- rm -rf vendor && \
20
- cp -rf /out/* . && \
21
- ./hack/validate-vendor check
25
+ RUN --mount=target=/context \
26
+ --mount=target=.,type=tmpfs <<EOT
27
+ set -e
28
+ rsync -a /context/. .
29
+ git add -A
30
+ rm -rf vendor
31
+ cp -rf /out/* .
32
+ if [ -n "$(git status --porcelain -- go.mod go.sum vendor)" ]; then
33
+ echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"'
34
+ git status --porcelain -- go.mod go.sum vendor
35
+ exit 1
36
+ fi
37
+ EOT
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments