-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
188 lines (139 loc) · 8.88 KB
/
Copy pathMakefile
File metadata and controls
188 lines (139 loc) · 8.88 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Use bash for better scripting
SHELL := /bin/bash
# Define compose files to avoid repetition
DEV_COMPOSE_FILE := -f docker-compose.dev.yml
PROD_COMPOSE_FILE := -f docker-compose.prod.yml
# Default command to run when 'make' is called without arguments
.DEFAULT_GOAL := help
# Phony targets prevent conflicts with files of the same name
.PHONY: prune dev dev-up dev-build dev-down dev-stop dev-restart dev-logs dev-logs-backend dev-logs-frontend dev-logs-leads dev-logs-builder dev-logs-deployer dev-logs-outreach dev-shell-backend dev-shell-frontend dev-shell-db dev-shell-leads dev-shell-builder dev-shell-deployer dev-shell-outreach prod prod-up prod-build prod-down prod-stop prod-restart prod-logs prod-logs-backend prod-logs-frontend prod-logs-leads prod-logs-builder prod-logs-deployer prod-logs-outreach prod-shell-backend prod-shell-frontend prod-shell-db prod-shell-leads prod-shell-builder prod-shell-deployer prod-shell-outreach
# --- General Utility Commands ---
help:
@echo "================================================================"
@echo " Makefile for HackOHIO Project "
@echo "================================================================"
@echo "Usage: make [command]"
@echo ""
@echo "Available Commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
prune: dev-down prod-down ## Clean up the system by removing all stopped containers, unused networks, and dangling images.
@echo "Pruning Docker system..."
@docker system prune -af
# --- Development Environment Commands ---
dev: dev-up ## Start the development environment with hot-reloading (alias for 'dev-up').
dev-up: ## Start the development environment with hot-reloading.
@echo "Starting development containers in detached mode (with hot-reloading)..."
@docker-compose $(DEV_COMPOSE_FILE) up --build -d
dev-build: ## Force a rebuild of all development images without starting containers.
@echo "Building development images..."
@docker-compose $(DEV_COMPOSE_FILE) build
dev-down: ## Stop and remove all development containers, networks, and volumes.
@echo "Stopping all containers..."
@docker-compose $(DEV_COMPOSE_FILE) down -v --remove-orphans
dev-stop: ## Stop running development containers without removing them.
@echo "Stopping development containers..."
@docker-compose $(DEV_COMPOSE_FILE) stop
dev-restart: ## Restart all development services.
@echo "Restarting development containers..."
@make dev-stop && make dev-up
dev-logs: ## View and follow logs for all running development services.
@echo "Following logs for all development services..."
@docker-compose $(DEV_COMPOSE_FILE) logs -f
dev-logs-backend: ## View and follow logs for the development backend service only.
@echo "Following backend logs..."
@docker-compose $(DEV_COMPOSE_FILE) logs -f backend
dev-logs-frontend: ## View and follow logs for the development frontend service only.
@echo "Following frontend logs..."
@docker-compose $(DEV_COMPOSE_FILE) logs -f frontend
dev-logs-leads: ## View and follow logs for the development leads service only.
@echo "Following leads logs..."
@docker-compose $(DEV_COMPOSE_FILE) logs -f leads
dev-logs-builder: ## View and follow logs for the development builder service only.
@echo "Following builder logs..."
@docker-compose $(DEV_COMPOSE_FILE) logs -f builder
dev-logs-deployer: ## View and follow logs for the development deployer service only.
@echo "Following deployer logs..."
@docker-compose $(DEV_COMPOSE_FILE) logs -f deployer
dev-logs-outreach: ## View and follow logs for the development outreach service only.
@echo "Following outreach logs..."
@docker-compose $(DEV_COMPOSE_FILE) logs -f outreach
dev-shell-backend: ## Open a bash shell inside the running development backend container.
@echo "Opening bash shell in backend container..."
@docker-compose $(DEV_COMPOSE_FILE) exec backend /bin/bash
dev-shell-frontend: ## Open a bash shell inside the running development frontend container.
@echo "Opening bash shell in frontend container..."
@docker-compose $(DEV_COMPOSE_FILE) exec frontend /bin/bash
dev-shell-leads: ## Open a bash shell inside the running development leads container.
@echo "Opening bash shell in leads container..."
@docker-compose $(DEV_COMPOSE_FILE) exec leads /bin/bash
dev-shell-builder: ## Open a bash shell inside the running development builder container.
@echo "Opening bash shell in builder container..."
@docker-compose $(DEV_COMPOSE_FILE) exec builder /bin/bash
dev-shell-deployer: ## Open a bash shell inside the running development deployer container.
@echo "Opening bash shell in deployer container..."
@docker-compose $(DEV_COMPOSE_FILE) exec deployer /bin/bash
dev-shell-outreach: ## Open a bash shell inside the running development outreach container.
@echo "Opening bash shell in outreach container..."
@docker-compose $(DEV_COMPOSE_FILE) exec outreach /bin/bash
dev-shell-db: ## Open a psql shell to interact with the development PostgreSQL database.
@echo "Opening psql shell in db container..."
@docker-compose $(DEV_COMPOSE_FILE) exec db psql -U $$(grep POSTGRES_USER .env.dev | cut -d '=' -f2) -d $$(grep POSTGRES_DB .env.dev | cut -d '=' -f2)
# --- Production Environment Commands ---
prod: prod-up ## Start the production environment (alias for 'prod-up').
prod-up: ## Build and start the production environment in detached mode.
@echo "Starting production containers in detached mode..."
@docker-compose $(PROD_COMPOSE_FILE) up --build -d
prod-build: ## Build production images without starting containers.
@echo "Building production images..."
@docker-compose $(PROD_COMPOSE_FILE) build
prod-down: ## Stop and remove production containers, networks, and volumes.
@echo "Stopping production containers..."
@docker-compose $(PROD_COMPOSE_FILE) down -v --remove-orphans
prod-stop: ## Stop running production containers without removing them.
@echo "Stopping production containers..."
@docker-compose $(PROD_COMPOSE_FILE) stop
prod-restart: ## Restart all production services.
@echo "Restarting production containers..."
@make prod-stop && make prod-up
prod-logs: ## View and follow logs for all running production services.
@echo "Following logs for all production services..."
@docker-compose $(PROD_COMPOSE_FILE) logs -f
prod-logs-backend: ## View and follow logs for the production backend service only.
@echo "Following production backend logs..."
@docker-compose $(PROD_COMPOSE_FILE) logs -f backend
prod-logs-frontend: ## View and follow logs for the production frontend service only.
@echo "Following production frontend logs..."
@docker-compose $(PROD_COMPOSE_FILE) logs -f frontend
prod-logs-leads: ## View and follow logs for the production leads service only.
@echo "Following production leads logs..."
@docker-compose $(PROD_COMPOSE_FILE) logs -f leads
prod-logs-builder: ## View and follow logs for the production builder service only.
@echo "Following production builder logs..."
@docker-compose $(PROD_COMPOSE_FILE) logs -f builder
prod-logs-deployer: ## View and follow logs for the production deployer service only.
@echo "Following production deployer logs..."
@docker-compose $(PROD_COMPOSE_FILE) logs -f deployer
prod-logs-outreach: ## View and follow logs for the production outreach service only.
@echo "Following production outreach logs..."
@docker-compose $(PROD_COMPOSE_FILE) logs -f outreach
prod-shell-backend: ## Open a bash shell inside the running production backend container.
@echo "Opening bash shell in production backend container..."
@docker-compose $(PROD_COMPOSE_FILE) exec backend /bin/bash
prod-shell-frontend: ## Open a bash shell inside the running production frontend container.
@echo "Opening bash shell in production frontend container..."
@docker-compose $(PROD_COMPOSE_FILE) exec frontend /bin/bash
prod-shell-leads: ## Open a bash shell inside the running production leads container.
@echo "Opening bash shell in production leads container..."
@docker-compose $(PROD_COMPOSE_FILE) exec leads /bin/bash
prod-shell-builder: ## Open a bash shell inside the running production builder container.
@echo "Opening bash shell in production builder container..."
@docker-compose $(PROD_COMPOSE_FILE) exec builder /bin/bash
prod-shell-deployer: ## Open a bash shell inside the running production deployer container.
@echo "Opening bash shell in production deployer container..."
@docker-compose $(PROD_COMPOSE_FILE) exec deployer /bin/bash
prod-shell-outreach: ## Open a bash shell inside the running production deployer container.
@echo "Opening bash shell in production outreach container..."
@docker-compose $(PROD_COMPOSE_FILE) exec outreach /bin/bash
prod-shell-db: ## Open a psql shell to interact with the production PostgreSQL database.
@echo "Opening psql shell in production db container..."
@docker-compose $(PROD_COMPOSE_FILE) exec db psql -U $$(grep POSTGRES_USER .env.prod | cut -d '=' -f2) -d $$(grep POSTGRES_DB .env.prod | cut -d '=' -f2)