Skip to content
This repository was archived by the owner on Aug 16, 2023. It is now read-only.

Commit 6b4be8a

Browse files
authored
Merge pull request #17 from crazy-max/vendor-targets
Vendor targets
2 parents 842a37d + f1f088c commit 6b4be8a

File tree

8 files changed

+187
-15
lines changed

8 files changed

+187
-15
lines changed

.github/workflows/validate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
matrix:
2222
target:
2323
- lint
24+
- validate-vendor
2425
steps:
2526
-
2627
name: Checkout

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
ifneq (, $(BUILDX_BIN))
2+
export BUILDX_CMD = $(BUILDX_BIN)
3+
else ifneq (, $(shell docker buildx version))
4+
export BUILDX_CMD = docker buildx
5+
else ifneq (, $(shell which buildx))
6+
export BUILDX_CMD = $(which buildx)
7+
else
8+
$(error "Buildx is required: https://github.com/docker/buildx#installing")
9+
endif
10+
11+
CHANNEL ?= mainline
12+
13+
image:
14+
CHANNEL=$(CHANNEL) $(BUILDX_CMD) bake
15+
16+
vendor:
17+
$(eval $@_TMP_OUT := $(shell mktemp -d -t dockerfile-output.XXXXXXXXXX))
18+
$(BUILDX_CMD) bake --set "*.output=$($@_TMP_OUT)" vendor
19+
rm -rf ./vendor
20+
cp -R "$($@_TMP_OUT)"/out/* .
21+
rm -rf $($@_TMP_OUT)/*
22+
23+
mod-outdated:
24+
$(BUILDX_CMD) bake mod-outdated
25+
26+
validate: lint test validate-vendor
27+
28+
lint:
29+
$(BUILDX_CMD) bake lint
30+
31+
test:
32+
./hack/test integration
33+
34+
validate-vendor:
35+
$(BUILDX_CMD) bake validate-vendor
36+
37+
.PHONY: image vendor mod-outdated validate lint test validate-vendor

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,26 @@ change in between releases on labs channel, the old versions are guaranteed to b
6161

6262
## Build
6363

64+
`docker/dockerfile` is developed using Docker.
65+
6466
```shell
65-
# build image and output to docker with dockerfile:local tag (default)
66-
docker buildx bake
67+
# build mainline channel image (output to docker)
68+
make image
69+
70+
# build mainline channel image (output to docker)
71+
CHANNEL=labs make image
72+
73+
# vendor
74+
make vendor
6775

68-
# build multi-platform image
69-
docker buildx bake image-cross
76+
# validate
77+
make validate
7078

71-
# build labs channel
72-
CHANNEL=labs docker buildx bake
79+
# check dependencies updates
80+
make mod-outdated
7381

74-
# build and push to username/dockerfile:test
75-
docker buildx bake image --push --set *.tags=username/dockerfile:test
82+
# build and push multi-platform mainline channel image to username/dockerfile:test
83+
docker buildx bake image-cross --push --set *.tags=username/dockerfile:test
7684
```
7785

7886
## Examples

docker-bake.hcl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ target "image-cross" {
4444
]
4545
}
4646

47+
target "vendor" {
48+
inherits = ["_common"]
49+
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"
50+
target = "update"
51+
output = ["."]
52+
}
53+
54+
target "mod-outdated" {
55+
inherits = ["_common"]
56+
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"
57+
target = "outdated"
58+
args = {
59+
// used to invalidate cache for outdated run stage
60+
// can be dropped when https://github.com/moby/buildkit/issues/1213 fixed
61+
_RANDOM = uuidv4()
62+
}
63+
output = ["type=cacheonly"]
64+
}
65+
4766
group "validate" {
4867
targets = ["lint"]
4968
}
@@ -53,3 +72,10 @@ target "lint" {
5372
dockerfile = "./hack/dockerfiles/lint.Dockerfile"
5473
output = ["type=cacheonly"]
5574
}
75+
76+
target "validate-vendor" {
77+
inherits = ["_common"]
78+
dockerfile = "./hack/dockerfiles/vendor.Dockerfile"
79+
target = "validate"
80+
output = ["type=cacheonly"]
81+
}

go.mod

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ require (
66
github.com/containerd/containerd v1.6.0-beta.3
77
github.com/containerd/continuity v0.2.1
88
github.com/docker/distribution v2.7.1+incompatible
9-
github.com/docker/docker v20.10.7+incompatible // master (v21.xx-dev)
9+
github.com/docker/docker v20.10.12+incompatible // master
1010
github.com/docker/go-connections v0.4.0
1111
github.com/docker/go-units v0.4.0
1212
github.com/google/go-cmp v0.5.6
13-
github.com/moby/buildkit v0.9.1-0.20220107201744-ffe2301031c8
14-
github.com/moby/sys/mount v0.3.0 // indirect
13+
github.com/moby/buildkit v0.9.3
1514
github.com/moby/sys/signal v0.6.0
16-
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
1715
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283
1816
github.com/pkg/errors v0.9.1
1917
github.com/sirupsen/logrus v1.8.1
@@ -41,11 +39,14 @@ require (
4139
github.com/golang/protobuf v1.5.2 // indirect
4240
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
4341
github.com/google/uuid v1.3.0 // indirect
42+
github.com/gorilla/mux v1.8.0 // indirect
4443
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
4544
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
4645
github.com/klauspost/compress v1.13.6 // indirect
4746
github.com/moby/locker v1.0.1 // indirect
47+
github.com/moby/sys/mount v0.3.0 // indirect
4848
github.com/moby/sys/mountinfo v0.5.0 // indirect
49+
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
4950
github.com/morikuni/aec v1.0.0 // indirect
5051
github.com/opencontainers/go-digest v1.0.0 // indirect
5152
github.com/opencontainers/runc v1.0.2 // indirect
@@ -74,6 +75,7 @@ require (
7475

7576
replace (
7677
github.com/docker/docker => github.com/docker/docker v20.10.3-0.20211208011758-87521affb077+incompatible
78+
github.com/moby/buildkit => github.com/moby/buildkit v0.9.1-0.20220107201744-ffe2301031c8
7779
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace => github.com/tonistiigi/opentelemetry-go-contrib/instrumentation/net/http/httptrace/otelhttptrace v0.0.0-20211026174723-2f82a1e0c997
7880
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp => github.com/tonistiigi/opentelemetry-go-contrib/instrumentation/net/http/otelhttp v0.0.0-20211026174723-2f82a1e0c997
7981
)

0 commit comments

Comments
 (0)