-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
82 lines (65 loc) · 2.3 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
SHELL = /bin/bash
# Set project environment here. This file is git ignored and SHOULD NOT be committed to git
include .env
include .common.env
# Include additional invironment overrides if present
-include .$(HOSTING_ENVIRONMENT).env
# Make it possible to pass arguments to Makefile from command line
# https://stackoverflow.com/a/6273809/1826109
ARGS = $(filter-out $@,$(MAKECMDGOALS))
.EXPORT_ALL_VARIABLES:
# Prints help based on annotations for Makefile commands
.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: build
build: ## Build stack images
@echo "Building stack images for $(PROJECT_NAME)..."
@$(DOCKER_COMPOSE) build
.PHONY: start
start: ## Start project stack
@echo "Starting up containers for $(PROJECT_NAME)..."
#@$(DOCKER_COMPOSE) pull
@$(DOCKER_COMPOSE) up -d --remove-orphans --build
.PHONY: up
up: start ## Alias for "start"
.PHONY: stop
stop: ## Stop project stack
@echo "Stopping containers for $(PROJECT_NAME)..."
@$(DOCKER_COMPOSE) stop
.PHONY: restart
restart: ## Restart project start (stop + start)
@make stop
@make start
.PHONY: remove
remove: ## Remove project stack
@echo "Removing resources for $(PROJECT_NAME)..."
@make network-disconnect
@$(DOCKER_COMPOSE) down -v
.PHONY: reset
reset: ## Reset project start (remove + start)
@make remove
@make start
.PHONY: ps
ps: ## List stack services
@$(DOCKER) ps --filter "label=com.docker.compose.project=$(PROJECT_NAME)"
.PHONY: logs
logs: ## Show stack logs. Examples: make logs; make logs web
@$(DOCKER_COMPOSE) logs -f $(ARGS)
.PHONY: network-disconnect
network-disconnect:
@for network in $(shell $(DOCKER) network inspect -f '{{range .Containers}}{{.Name}} {{end}}' $(PROJECT_NETWORK_NAME)); do \
$(DOCKER) network disconnect -f $(PROJECT_NETWORK_NAME) $$network; \
done
.PHONY: show-config
show-config: ## Print effective stack docker-compose config
@$(DOCKER_COMPOSE) config
.PHONY: ctop
ctop: ## Run ctop to view realtime container CPU/RAM/Disk/Network stats and logs
@docker rm -vf ctop &>/dev/null || true
@docker run --rm -it --name=ctop \
-v /var/run/docker.sock:/var/run/docker.sock \
quay.io/vektorlab/ctop:latest
# https://stackoverflow.com/a/6273809/1826109
%:
@: