-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·136 lines (113 loc) · 4.76 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# HELP
# This will output the help for each task
# IMAGE=php VARIATION=cli PHP_VERSION=8.1 make build
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help: ## This help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
IMAGE_PREFIX=adeliom
IMAGE_NAME=$(IMAGE_PREFIX)/$(IMAGE)
REGISTRY=
# DOCKER TASKS
build: ## Build the container
$(eval DOCKERFILE := $(IMAGE)/Dockerfile-$(VERSION).$(VARIATION))
ifeq ("$(wildcard $(DOCKERFILE))","")
$(eval DOCKERFILE := $(IMAGE)/Dockerfile.$(VARIATION))
endif
docker buildx create --use
docker buildx build \
--push \
--platform linux/amd64 \
--tag $(IMAGE_NAME):$(VERSION)-$(VARIATION) \
--build-arg PHP_VERSION=$(VERSION) \
--file $(DOCKERFILE) $(IMAGE) \
--cache-from=type=registry,ref=$(REGISTRY)$(IMAGE_NAME):$(VERSION)-$(VARIATION)
build-nc: ## Build the container without caching
$(eval DOCKERFILE := $(IMAGE)/Dockerfile-$(VERSION).$(VARIATION))
ifeq ("$(wildcard $(DOCKERFILE))","")
$(eval DOCKERFILE := $(IMAGE)/Dockerfile.$(VARIATION))
endif
docker buildx create --use
docker buildx build \
--push \
--no-cache \
--platform linux/amd64 \
--tag $(REGISTRY)$(IMAGE_NAME):$(VERSION)-$(VARIATION) \
--build-arg PHP_VERSION=$(VERSION) \
--file $(DOCKERFILE) $(IMAGE) \
--cache-from=type=registry,ref=$(REGISTRY)$(IMAGE_NAME):$(VERSION)-$(VARIATION)
build-local: ## Build the container
$(eval DOCKERFILE := $(IMAGE)/Dockerfile-$(VERSION).$(VARIATION))
ifeq ("$(wildcard $(DOCKERFILE))","")
$(eval DOCKERFILE := $(IMAGE)/Dockerfile.$(VARIATION))
endif
docker buildx create --use
docker buildx build \
--load \
--platform linux/amd64 \
--tag $(IMAGE_NAME):$(VERSION)-$(VARIATION) \
--build-arg PHP_VERSION=$(VERSION) \
--file $(DOCKERFILE) $(IMAGE)
# Run containers
run: stop ## Run container
@docker run -i -t --rm --name="$(IMAGE_NAME)" $(IMAGE_NAME)
stop: ## Stop running containers
@docker stop $(IMAGE_NAME)
rm: stop ## Stop and remove running containers
@docker rm $(IMAGE_NAME)
# Docker release - build, tag and push the container
release: build-nc publish ## Make a release by building and publishing the tagged container
# Docker publish
publish: tag ## publish the taged container
@echo 'publish $(VERSION)-$(VARIATION)'
docker push $(REGISTRY)$(IMAGE_NAME):$(VERSION)-$(VARIATION)
# Docker tagging
tag: ## Generate container tag
@echo 'create tag $(VERSION)-$(VARIATION)'
docker tag $(IMAGE_NAME) $(REGISTRY)$(IMAGE_NAME):$(VERSION)-$(VARIATION)
IMAGE=php VERSION=8.4 VARIATION=fpm $(MAKE) build-local
IMAGE=php VERSION=8.2 VARIATION=caddy $(MAKE) build-local
IMAGE=php VERSION=8.2 VARIATION=apache $(MAKE) build-local
IMAGE=php VERSION=8.2 VARIATION=nginx $(MAKE) build-local
IMAGE=php VERSION=8.2 VARIATION=frankenphp $(MAKE) build-local
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := caddy)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := apache)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := nginx)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := frankenphp)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)
$(eval IMAGE := php)
$(eval VERSION := 8.2)
$(eval VARIATION := frankenphp)
$(eval IMAGE_NAME := $(IMAGE_PREFIX)/$(IMAGE):$(VERSION)-$(VARIATION))
@docker stop $(IMAGE)_$(VERSION)-$(VARIATION) || true
@docker run -i -t --rm -p 1234:80 -v ./test/:/var/www/html/ -e FRANKENPHP_CONFIG="worker /var/www/html/index.php" -e FRANKENPHP_WORKER=true --name="$(IMAGE)_$(VERSION)-$(VARIATION)" $(IMAGE_NAME)