-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (52 loc) · 1.97 KB
/
Makefile
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
SHELL=/bin/bash -o pipefail
REGISTRY ?= stashed
BIN := restic
IMAGE := $(REGISTRY)/$(BIN)
RELEASE ?= 0.13.1
VERSION ?= v$(RELEASE)
SRC_REG ?=
DOCKER_PLATFORMS := linux/amd64 linux/386 linux/arm64 linux/ppc64le linux/s390x
PLATFORM ?= $(firstword $(DOCKER_PLATFORMS))
TAG = $(VERSION)_$(subst /,_,$(PLATFORM))
container-%:
@$(MAKE) container \
--no-print-directory \
PLATFORM=$(subst _,/,$*)
push-%:
@$(MAKE) push \
--no-print-directory \
PLATFORM=$(subst _,/,$*)
all-container: $(addprefix container-, $(subst /,_,$(DOCKER_PLATFORMS)))
all-push: $(addprefix push-, $(subst /,_,$(DOCKER_PLATFORMS)))
ifeq (,$(SRC_REG))
container:
@echo "container: $(IMAGE):$(TAG)"
@docker buildx build --platform $(PLATFORM) --build-arg VERSION=$(RELEASE) --load --pull -t $(IMAGE):$(TAG) -f Dockerfile .
@echo
else
container:
@echo "container: $(IMAGE):$(TAG)"
@docker tag $(SRC_REG)/$(BIN):$(TAG) $(IMAGE):$(TAG)
@echo
endif
push: container
@docker push $(IMAGE):$(TAG)
@echo "pushed: $(IMAGE):$(TAG)"
@echo
.PHONY: manifest-version
manifest-version:
docker manifest create -a $(IMAGE):$(VERSION) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(VERSION)_$(subst /,_,$(PLATFORM)))
docker manifest push $(IMAGE):$(VERSION)
.PHONY: manifest-release
manifest-release:
docker manifest create -a $(IMAGE):v$(RELEASE) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(VERSION)_$(subst /,_,$(PLATFORM)))
docker manifest push $(IMAGE):v$(RELEASE)
docker manifest create -a $(IMAGE):$(RELEASE) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(VERSION)_$(subst /,_,$(PLATFORM)))
docker manifest push $(IMAGE):$(RELEASE)
# docker manifest create -a $(IMAGE):latest $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(VERSION)_$(subst /,_,$(PLATFORM)))
# docker manifest push $(IMAGE):latest
.PHONY: docker-manifest
docker-manifest: manifest-version manifest-release
.PHONY: release
release:
@$(MAKE) all-push docker-manifest --no-print-directory