Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (58 loc) · 2.18 KB
/
Copy pathMakefile
File metadata and controls
81 lines (58 loc) · 2.18 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
-include env_make
REDIS_VER ?= 8.6.8
REDIS_VER_MINOR = $(shell echo "${REDIS_VER}" | grep -oE '^[0-9]+\.[0-9]+')
TAG ?= $(REDIS_VER_MINOR)
REPO = wodby/redis
NAME = redis-$(REDIS_VER)
PLATFORM ?= linux/arm64
ifneq ($(ARCH),)
override TAG := $(TAG)-$(ARCH)
endif
.PHONY: build buildx-build buildx-push test push shell run start stop logs clean release
# Resolve the same pinned base image for every local and CI build target.
include base-images.mk
BASE_IMAGE_TAG = $(REDIS_VER)-alpine
default: build
build:
docker build --build-arg BASE_IMAGE="$(BASE_IMAGE)" -t $(REPO):$(TAG) \
--build-arg REDIS_VER=$(REDIS_VER) \
./
buildx-build:
docker buildx build --build-arg BASE_IMAGE="$(BASE_IMAGE)" --platform $(PLATFORM) -t $(REPO):$(TAG) \
--build-arg REDIS_VER=$(REDIS_VER) \
--load \
./
buildx-push:
docker buildx build --build-arg BASE_IMAGE="$(BASE_IMAGE)" --platform $(PLATFORM) --push -t $(REPO):$(TAG) \
--build-arg REDIS_VER=$(REDIS_VER) \
./
# CI combines the exact architecture images this workflow run pushed; see
# wodby/images arch-image-pins. Per-architecture tags are shared by every run,
# so an overlapping run may already have replaced one of them.
arch-image = $(if $(ARCH_IMAGE_PINS),$(or $(shell cat '$(ARCH_IMAGE_PINS)/$(subst :,_,$(subst /,_,$(1)))' 2>/dev/null),$(error No digest of $(1) was pushed by this workflow run)),$(1))
buildx-imagetools-create:
docker buildx imagetools create -t $(REPO):$(TAG) \
$(call arch-image,$(REPO):$(REDIS_VER_MINOR)-amd64) \
$(call arch-image,$(REPO):$(REDIS_VER_MINOR)-arm64)
.PHONY: buildx-imagetools-create
test:
cd ./tests && IMAGE=$(REPO):$(TAG) NAME=$(NAME) ./run.sh
push:
docker push $(REPO):$(TAG)
shell:
docker run --rm --name $(NAME) -i -t $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash
run:
docker run --rm --name $(NAME) -e DEBUG=1 $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) $(CMD)
start:
docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG)
stop:
docker stop $(NAME)
logs:
docker logs $(NAME)
clean:
-docker rm -f $(NAME)
release: build push
# Keep CI scans aligned with the version, variant and architecture built by make.
.PHONY: image-ref
image-ref:
@printf '%s\n' '$(REPO):$(TAG)'