-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (42 loc) · 1.21 KB
/
Makefile
File metadata and controls
55 lines (42 loc) · 1.21 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
# ==================================
# CONFIGURATION
# ==================================
SHELL := bash
DB_NAME = dev_wiki
DB_USER = devwiki_admin
CONTAINER_NAME = dev-wiki-postgres
DOCKER_IMAGE_NAME = dev-wiki-postgres
DUMP_DIR = apps/db
TIMESTAMP = $(shell date +%Y%m%d-%H%M)
DUMP_FILE = $(DUMP_DIR)/dump-$(DB_NAME)-$(TIMESTAMP).dump
# ==================================
# UTILITIES
# ==================================
.PHONY: all up down restart logs dump reset clean ensure-dirs
# ==================================
# RUNTIME TASKS
# ==================================
up:
@echo "Starting Postgres container..."
docker compose up -d
down:
@echo "Stopping and removing container and volumes..."
docker compose down -v
restart:
@echo "Full restart (clean volumes and rebuild)..."
docker compose down -v
docker compose up -d
build:
@echo "Building Docker image..."
docker compose up --build
# ==================================
# DATABASE TASKS
# ==================================
reset: down up dump
# ==================================
# CLEAN TASK
# ==================================
clean:
@echo "Cleaning dump files and Docker image..."
rm -rf $(DUMP_DIR)/*.dump
docker rmi -f $(DOCKER_IMAGE_NAME) || true