forked from scaleway/scaleway-cloud-controller-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (49 loc) · 1.96 KB
/
Copy pathMakefile
File metadata and controls
64 lines (49 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
ARCHS ?= amd64 arm64
BUILD_DATE ?= $(shell date -Is)
GOPATH ?= $(GOPATH)
REGISTRY ?= scaleway
IMAGE ?= scaleway-cloud-controller-manager
FULL_IMAGE ?= $(REGISTRY)/$(IMAGE)
TAG ?= $(shell git rev-parse HEAD)
IMAGE_TAG ?= $(shell git rev-parse HEAD)
COMMIT_SHA ?= $(shell git rev-parse HEAD)
DOCKER_CLI_EXPERIMENTAL ?= enabled
.PHONY: default
default: test compile
.PHONY: clean
clean:
go clean -i -x ./...
.PHONY: test
test:
go test -timeout=1m -v -race -short ./...
.PHONY: fmt
fmt:
find . -type f -name "*.go" | grep -v "./vendor/*" | xargs gofmt -s -w -l
.PHONY: compile
compile:
go build -v -o scaleway-cloud-controller-manager ./cmd/scaleway-cloud-controller-manager
.PHONY: docker-build
docker-build:
@echo "Building scaleway-cloud-controller-manager for ${ARCH}"
docker build . --platform=linux/$(ARCH) --build-arg ARCH=$(ARCH) --build-arg TAG=$(TAG) --build-arg COMMIT_SHA=$(COMMIT_SHA) --build-arg BUILD_DATE=$(BUILD_DATE) -f Dockerfile -t ${FULL_IMAGE}:${IMAGE_TAG}-$(ARCH)
.PHONY: docker-push-arch
docker-push-arch:
@echo "Building and pushing scaleway-cloud-controller-manager for $(ARCH)"
mkdir -p digests
docker buildx build . --platform=linux/$(ARCH) --build-arg TAG=$(TAG) --build-arg COMMIT_SHA=$(COMMIT_SHA) --build-arg BUILD_DATE=$(BUILD_DATE) \
--output type=image,name=$(FULL_IMAGE),push=true,push-by-digest=true,name-canonical=true \
--metadata-file digests/$(ARCH).json
jq -r '."containerimage.digest"' digests/$(ARCH).json > digests/$(ARCH)
.PHONY: docker-manifest
docker-manifest:
@echo "Creating manifest $(FULL_IMAGE):$(IMAGE_TAG) from $(foreach arch,$(ARCHS),digests/$(arch))"
docker buildx imagetools create -t $(FULL_IMAGE):$(IMAGE_TAG) $(foreach arch,$(ARCHS),$(FULL_IMAGE)@$(shell cat digests/$(arch)))
.PHONY: docker-push-all
docker-push-all:
@for arch in $(ARCHS); do $(MAKE) docker-push-arch ARCH=$$arch; done
$(MAKE) docker-manifest
## Release
.PHONY: release
release: docker-push-all