-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (85 loc) · 2.77 KB
/
Copy pathMakefile
File metadata and controls
100 lines (85 loc) · 2.77 KB
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
export
DOCKER_COMPOSE_CMD = docker compose
.PHONY: help build up exec stop down logs list-profiles list-services
help: ## Show the help message
@echo "Syntax: make [target]"
@echo ""
@awk 'BEGIN {FS = ":.*##"; printf "Available targets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " %-15s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
list-profiles: ## List the profiles defined in the Docker Compose file
@echo "Available profiles:"
@$(DOCKER_COMPOSE_CMD) config --profiles
list-services: ## List the services defined in the Docker Compose file
@echo "Available services:"
@$(DOCKER_COMPOSE_CMD) config --services
init: ## Create the networks
docker network create shared-internal
docker network create shared-web
generate-migrations:
$(DOCKER_COMPOSE_CMD) exec api-dev sh -c "npm run migration:generate src/database/migrations/InitialSchema"
run-migrations:
$(DOCKER_COMPOSE_CMD) exec api-dev sh -c "npm run migration:run"
build: ## Build the Docker images
ifndef PROFILE
@$(MAKE) list-profiles
@echo "Please specify the profile: make build PROFILE=<profile_name> [SERVICE=<service_name>]"
else
ifdef SERVICE
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) up $(SERVICE) --build
else
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) up --build
endif
endif
up: ## Start the Docker containers
ifndef PROFILE
@$(MAKE) list-profiles
@echo "Please specify the profile: make up PROFILE=<profile_name> [SERVICE=<service_name>]"
else
ifdef SERVICE
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) up -d $(SERVICE)
else
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) up -d
endif
endif
exec: ## Execute a command in the Docker container
ifndef SERVICE
@$(MAKE) list-services
@echo "Please specify the service: make exec SERVICE=<service_name>"
else
$(DOCKER_COMPOSE_CMD) exec $(SERVICE) bash
endif
stop: ## Stop the Docker containers
ifndef PROFILE
@$(MAKE) list-profiles
@echo "Please specify the profile: make stop PROFILE=<profile_name> [SERVICE=<service_name>]"
else
ifdef SERVICE
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) stop $(SERVICE)
else
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) stop
endif
endif
down: ## Bring down the Docker containers
ifndef PROFILE
@$(MAKE) list-profiles
@echo "Please specify the profile: make down PROFILE=<profile_name> [SERVICE=<service_name>]"
else
ifdef SERVICE
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) down $(SERVICE)
else
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) down
endif
endif
logs: ## Show the logs of the Docker containers
ifndef PROFILE
@$(MAKE) list-profiles
@echo "Please specify the profile: make logs PROFILE=<profile_name> [SERVICE=<service_name>]"
else
ifdef SERVICE
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) logs -f $(SERVICE)
else
$(DOCKER_COMPOSE_CMD) --profile $(PROFILE) logs -f
endif
endif
db:
docker compose exec postgres psql -U $(DB_USERNAME) -d $(DB_NAME)