-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (42 loc) · 1.34 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
DOCKER_COMPOSE = docker compose
COMPOSE_FILE = "docker-compose-dev.yaml"
DOCKER = docker
ifneq ($(filter prod, $(MAKECMDGOALS)),)
COMPOSE_FILE = "docker-compose-prod.yaml"
endif
ifneq ($(filter restart logs attach exec,$(MAKECMDGOALS)),)
SERVICE = $(word 2, $(MAKECMDGOALS))
EXEC_COMMAND = $(word 3, $(MAKECMDGOALS))
endif
.PHONY: help
help:
@echo "Usage: make [target]"
@echo "Targets:"
@echo " ps - show all containers"
@echo " build - build all containers"
@echo " up - start all containers"
@echo " down - stop all containers"
@echo " restart-all - restart all containers"
@echo
@echo " restart backend|frontend|nginx - restart service"
@echo " logs backend|frontend|nginx - show logs of service"
@echo " attach backend|frontend|nginx - attach to service"
@echo " exec backend|frontend|nginx <command> - execute command in service"
ps:
@$(DOCKER_COMPOSE) -f $(COMPOSE_FILE) ps -a
build:
@$(DOCKER_COMPOSE) -f $(COMPOSE_FILE) build
up:
@$(DOCKER_COMPOSE) -f $(COMPOSE_FILE) up -d
down:
@$(DOCKER_COMPOSE) -f $(COMPOSE_FILE) down
restart-all:
@$(DOCKER_COMPOSE) -f $(COMPOSE_FILE) restart
restart:
@$(DOCKER) restart $(SERVICE)
logs:
@$(DOCKER) logs -f $(SERVICE)
attach:
@$(DOCKER) exec -it $(SERVICE) bash
exec:
@$(DOCKER) exec $(SERVICE) $(EXEC_COMMAND)