-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
67 lines (63 loc) · 3.49 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
# ------------------------------------------------------------------------------------------------------
# Variables and arguments required
SHELL := '/bin/bash'
.DEFAULT_GOAL := help
GIT_LAST_COMMIT_HASH := $(shell git rev-parse --short HEAD)
CURRENT_DATE_GMT := $(shell date +"%Y-%m-%dT%H:%M:%S_GMT%Z")
VERSION := $(shell git describe --tags --always)
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
develop: ## Build '*-dev' tag, including Xdebug.
@echo "Building tag '8.3-dev'"
docker build \
--build-arg VCS_REF=$(GIT_LAST_COMMIT_HASH) \
--build-arg BUILD_DATE=$(CURRENT_DATE_GMT) \
--build-arg BUILD_VERSION=8.3-dev \
--build-arg VERSION="$(VERSION)" \
--build-arg INSTALL_XDEBUG=true \
-t devdrops/php-toolbox:8.3-dev .
# ------------------------------------------------------------------------------------------------------
build: ## Build the official tag.
@echo "Building tags 'latest' and '8.3'"
docker build \
--build-arg VCS_REF=$(GIT_LAST_COMMIT_HASH) \
--build-arg BUILD_DATE=$(CURRENT_DATE_GMT) \
--build-arg BUILD_VERSION=8.3 \
--build-arg VERSION="$(VERSION)" \
--build-arg INSTALL_XDEBUG=false \
--no-cache --squash \
-t devdrops/php-toolbox:latest \
-t devdrops/php-toolbox:8.3 .
# ------------------------------------------------------------------------------------------------------
debug: ## Build only the image with Xdebug.
@echo "Build tag '8.3-xdebug'"
docker build \
--build-arg VCS_REF=$(GIT_LAST_COMMIT_HASH) \
--build-arg BUILD_DATE=$(CURRENT_DATE_GMT) \
--build-arg BUILD_VERSION=8.3-xdebug \
--build-arg VERSION="$(VERSION)" \
--build-arg INSTALL_XDEBUG=true \
--no-cache \
-t devdrops/php-toolbox:8.3-xdebug .
# ------------------------------------------------------------------------------------------------------
latest: build debug ## Build two images: 1. official tag, 2. official tag + Xdebug.
# ------------------------------------------------------------------------------------------------------
push: ## Pushes to Docker Hub two images: 1. official tag, 2. official tag + Xdebug.
@echo "Pushing tags 'latest', '8.3' and '8.3-xdebug'"
docker push devdrops/php-toolbox:latest
docker push devdrops/php-toolbox:8.3
docker push devdrops/php-toolbox:8.3-xdebug
# ------------------------------------------------------------------------------------------------------
release: latest push ## Build and deploy official tags.
# ------------------------------------------------------------------------------------------------------
shellcheck: ## Run shellcheck to scan sh files at ./helpers.
find . -type f -name "*.sh" -exec shellcheck {} \;
# ------------------------------------------------------------------------------------------------------
hadolint: ## Lint ./Dockerfile with Hadolint
docker run --rm -i hadolint/hadolint < Dockerfile
# ------------------------------------------------------------------------------------------------------
help: ## Print information of each Make task.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
.PHONY: develop build debug latest push release shellcheck hadolint help