-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
100 lines (76 loc) · 2.75 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
-include env_make
MARIADB_VER ?= 11.4.4
MARIADB_VER_MINOR = $(shell echo "${MARIADB_VER}" | grep -oE '^[0-9]+\.[0-9]+')
GALERA_VER ?=
WSREP_VER ?= $(shell echo "${GALERA_VER}" | grep -oE '^[0-9]+')
ALPINE_VER ?= 3.20
NPROC =
PLATFORM ?= linux/amd64
ifeq ($(BASE_IMAGE_STABILITY_TAG),)
BASE_IMAGE_TAG := $(ALPINE_VER)
else
BASE_IMAGE_TAG := $(ALPINE_VER)-$(BASE_IMAGE_STABILITY_TAG)
endif
TAG ?= $(MARIADB_VER_MINOR)
ifneq ($(STABILITY_TAG),)
ifneq ($(TAG),latest)
override TAG := $(TAG)-$(STABILITY_TAG)
endif
endif
REPO = wodby/mariadb
NAME = mariadb-$(MARIADB_VER_MINOR)
.PHONY: build buildx-build buildx-push buildx-build-amd64 test push shell run start stop logs clean release
default: build
build:
docker build -t $(REPO):$(TAG) \
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
--build-arg MARIADB_VER=$(MARIADB_VER) \
--build-arg MARIADB_VER_MINOR=$(MARIADB_VER_MINOR) \
--build-arg GALERA_VER=$(GALERA_VER) \
--build-arg WSREP_VER=$(WSREP_VER) \
--build-arg NPROC=$(NPROC) ./
# --load doesn't work with multiple platforms https://github.com/docker/buildx/issues/59
# we need to save cache to run tests first.
buildx-build-amd64:
docker buildx build --platform linux/amd64 -t $(REPO):$(TAG) \
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
--build-arg MARIADB_VER=$(MARIADB_VER) \
--build-arg MARIADB_VER_MINOR=$(MARIADB_VER_MINOR) \
--build-arg GALERA_VER=$(GALERA_VER) \
--build-arg WSREP_VER=$(WSREP_VER) \
--build-arg NPROC=$(NPROC) \
--load \
./
buildx-build:
docker buildx build --platform $(PLATFORM) -t $(REPO):$(TAG) \
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
--build-arg MARIADB_VER=$(MARIADB_VER) \
--build-arg MARIADB_VER_MINOR=$(MARIADB_VER_MINOR) \
--build-arg GALERA_VER=$(GALERA_VER) \
--build-arg WSREP_VER=$(WSREP_VER) \
--build-arg NPROC=$(NPROC) ./
buildx-push:
docker buildx build --push --platform $(PLATFORM) -t $(REPO):$(TAG) \
--build-arg BASE_IMAGE_TAG=$(BASE_IMAGE_TAG) \
--build-arg MARIADB_VER=$(MARIADB_VER) \
--build-arg MARIADB_VER_MINOR=$(MARIADB_VER_MINOR) \
--build-arg GALERA_VER=$(GALERA_VER) \
--build-arg WSREP_VER=$(WSREP_VER) \
--build-arg NPROC=$(NPROC) ./
test:
cd ./tests && IMAGE=$(REPO):$(TAG) ./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 -e MYSQL_RANDOM_ROOT_PASSWORD=1 $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) $(CMD)
start:
docker run -d --name $(NAME) -e MYSQL_RANDOM_ROOT_PASSWORD=1 $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG)
stop:
docker stop $(NAME)
logs:
docker logs $(NAME)
clean:
-docker rm -f $(NAME)
release: build push