-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (60 loc) · 1.46 KB
/
Makefile
File metadata and controls
77 lines (60 loc) · 1.46 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
# Project constants
PROJECT_NAME=joinmun2025
COMPOSE_DEV_FILE=compose.dev.yaml
COMPOSE_PROD_FILE=compose.prod.yaml
DB_USERNAME=joinmun
DB_DATABASE=joinmun_backend_db
# Mode selection (default: dev)
MODE ?= dev
ifeq ($(MODE),dev)
COMPOSE_FILE=$(COMPOSE_DEV_FILE)
BACKEND_SERVICE=$(PROJECT_NAME)-backend-api-1
BACKEND_DB=$(PROJECT_NAME)-backend-db-1
else ifeq ($(MODE),prod)
COMPOSE_FILE=$(COMPOSE_PROD_FILE)
BACKEND_SERVICE=$(PROJECT_NAME)-backend-api-1
BACKEND_DB=$(PROJECT_NAME)-backend-db-1
else
$(error MODE must be either 'dev' or 'prod')
endif
DOCKER_COMPOSE=docker compose -f $(COMPOSE_FILE)
# Commands
.PHONY: up down downv restart restartv logs build start stop ps shell db
# Start containers
up:
$(DOCKER_COMPOSE) up
upb:
$(DOCKER_COMPOSE) up --build
updb:
$(DOCKER_COMPOSE) up -d --build
# Stop and remove containers
down:
$(DOCKER_COMPOSE) down
# Stop and remove containers and volumes
downv:
$(DOCKER_COMPOSE) down -v
# Restart containers
restart: down upb
# Restart containers with volume removal
restartv: downv upb
# Build containers
build:
$(DOCKER_COMPOSE) build
# View logs
logs:
$(DOCKER_COMPOSE) logs -f
# Stop containers
start:
$(DOCKER_COMPOSE) start
# Stop containers
stop:
$(DOCKER_COMPOSE) stop
# List all containers
ps:
$(DOCKER_COMPOSE) ps
# Open a shell in the backend container
shell:
$(DOCKER_COMPOSE) exec -it $(BACKEND_SERVICE) sh
# Connect to the database
db:
docker exec -it $(BACKEND_DB) psql -U $(DB_USERNAME) -d $(DB_DATABASE)