forked from bfjelds/test-packages-as-container-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (63 loc) · 2.62 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
BUILD_AMD64 ?= 1
BUILD_ARM32 ?= 1
BUILD_ARM64 ?= 1
PREFIX ?= ghcr.io/bfjelds/foo
LABEL_PREFIX ?= v0.1.1
CACHE_OPTION ?=
ENABLE_DOCKER_MANIFEST = DOCKER_CLI_EXPERIMENTAL=enabled
AMD64_SUFFIX = amd64
ARM32V7_SUFFIX = arm32v7
ARM64V8_SUFFIX = arm64v8
#
#
# TEST: make and push the images for test:
#
# To make all platforms: `make test`
# To make specific platforms: `BUILD_AMD64=1 BUILD_ARM32=0 BUILD_ARM64=1 make test`
#
#
.PHONY: test
test: test-docker-build test-docker-push-per-arch test-docker-push-multi-arch-create test-docker-push-multi-arch-push
test-docker-build: test-build-amd64 test-build-arm32 test-build-arm64
test-build-amd64:
ifeq (1, ${BUILD_AMD64})
docker build $(CACHE_OPTION) -f Dockerfile . -t $(PREFIX)/test:$(LABEL_PREFIX)-$(AMD64_SUFFIX) --build-arg PLATFORM=$(AMD64_SUFFIX)
endif
test-build-arm32:
ifeq (1, ${BUILD_ARM32})
docker build $(CACHE_OPTION) -f Dockerfile . -t $(PREFIX)/test:$(LABEL_PREFIX)-$(ARM32V7_SUFFIX) --build-arg PLATFORM=$(ARM32V7_SUFFIX)
endif
test-build-arm64:
ifeq (1, ${BUILD_ARM64})
docker build $(CACHE_OPTION) -f Dockerfile . -t $(PREFIX)/test:$(LABEL_PREFIX)-$(ARM64V8_SUFFIX) --build-arg PLATFORM=$(ARM64V8_SUFFIX)
endif
test-docker-push-per-arch: test-docker-per-arch-amd64 test-docker-per-arch-arm32 test-docker-per-arch-arm64
test-docker-per-arch-amd64:
ifeq (1, ${BUILD_AMD64})
docker push $(PREFIX)/test:$(LABEL_PREFIX)-$(AMD64_SUFFIX)
endif
test-docker-per-arch-arm32:
ifeq (1, ${BUILD_ARM32})
docker push $(PREFIX)/test:$(LABEL_PREFIX)-$(ARM32V7_SUFFIX)
endif
test-docker-per-arch-arm64:
ifeq (1, ${BUILD_ARM64})
docker push $(PREFIX)/test:$(LABEL_PREFIX)-$(ARM64V8_SUFFIX)
endif
test-docker-push-multi-arch-create: test-docker-multi-arch-create
test-docker-multi-arch-create:
ifeq (1, ${BUILD_AMD64})
$(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/test:$(LABEL_PREFIX) $(PREFIX)/test:$(LABEL_PREFIX)-$(AMD64_SUFFIX)
endif
ifeq (1, ${BUILD_ARM32})
$(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/test:$(LABEL_PREFIX) $(PREFIX)/test:$(LABEL_PREFIX)-$(ARM32V7_SUFFIX)
endif
ifeq (1, ${BUILD_ARM64})
$(ENABLE_DOCKER_MANIFEST) docker manifest create --amend $(PREFIX)/test:$(LABEL_PREFIX) $(PREFIX)/test:$(LABEL_PREFIX)-$(ARM64V8_SUFFIX)
endif
test-docker-push-multi-arch-inspect:
$(ENABLE_DOCKER_MANIFEST) docker manifest inspect $(PREFIX)/test:$(LABEL_PREFIX)
test-docker-push-multi-arch-push:
$(ENABLE_DOCKER_MANIFEST) docker manifest push $(PREFIX)/test:$(LABEL_PREFIX)
test-docker-push-multi-arch-pull:
$(ENABLE_DOCKER_MANIFEST) docker pull $(PREFIX)/test:$(LABEL_PREFIX)