Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
144 lines (114 loc) · 4.74 KB
/
Copy pathMakefile
File metadata and controls
144 lines (114 loc) · 4.74 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
# AccountSafe Makefile
# Standardized commands for development, testing, and deployment
.PHONY: help dev build up down test test-backend test-frontend clean init-ssl deploy logs shell \
oracle-bootstrap oracle-ssl-init oracle-up oracle-down oracle-deploy oracle-logs \
oracle-shell oracle-ps oracle-backup oracle-restore
# Default target
help:
@echo ""
@echo "AccountSafe - Available Commands"
@echo "================================"
@echo ""
@echo "Development:"
@echo " make dev Start local development environment"
@echo " make build Build all Docker images"
@echo " make up Start containers (detached)"
@echo " make down Stop and remove containers"
@echo " make logs Tail container logs"
@echo " make shell Open shell in backend container"
@echo ""
@echo "Testing:"
@echo " make test Run all tests (backend + frontend)"
@echo " make test-backend Run backend tests only (pytest)"
@echo " make test-frontend Run frontend tests only (jest)"
@echo ""
@echo "Production (legacy, single-host AWS):"
@echo " make init-ssl Initialize Let's Encrypt certificates"
@echo " make deploy Deploy to production"
@echo ""
@echo "Oracle Cloud (backend-only; frontend lives on Vercel):"
@echo " make oracle-bootstrap First-time VM setup (docker, firewall, swap)"
@echo " make oracle-ssl-init Issue Let's Encrypt cert for \$$DOMAIN"
@echo " make oracle-up Start the production stack"
@echo " make oracle-down Stop the production stack"
@echo " make oracle-deploy git pull + rebuild + migrate + restart"
@echo " make oracle-logs Tail all service logs"
@echo " make oracle-shell Open shell in backend container"
@echo " make oracle-ps Show service status"
@echo " make oracle-backup Trigger an immediate DB backup"
@echo ""
@echo "Maintenance:"
@echo " make clean Remove containers, volumes, and build artifacts"
@echo ""
# =============================================================================
# Development
# =============================================================================
dev:
docker-compose -f docker-compose.local.yml up --build
build:
docker-compose -f docker-compose.local.yml build
up:
docker-compose -f docker-compose.local.yml up -d
down:
docker-compose -f docker-compose.local.yml down
logs:
docker-compose -f docker-compose.local.yml logs -f
shell:
docker-compose -f docker-compose.local.yml exec backend /bin/bash
# =============================================================================
# Testing
# =============================================================================
test:
@echo "Running all tests..."
./scripts/run_tests.sh
test-backend:
@echo "Running backend tests..."
cd backend && python -m pytest -v
test-frontend:
@echo "Running frontend tests..."
cd frontend && npm test -- --watchAll=false
# =============================================================================
# Production
# =============================================================================
init-ssl:
chmod +x scripts/init-letsencrypt.sh
./scripts/init-letsencrypt.sh
deploy:
docker-compose -f docker-compose.prod.yml up -d --build
deploy-down:
docker-compose -f docker-compose.prod.yml down
# =============================================================================
# Maintenance
# =============================================================================
clean:
docker-compose -f docker-compose.local.yml down -v --rmi local
docker-compose -f docker-compose.prod.yml down -v --rmi local
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type d -name node_modules -prune -o -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true
# =============================================================================
# Oracle Cloud (backend) + Vercel (frontend)
# =============================================================================
ORACLE_COMPOSE := docker-compose.oracle.yml
oracle-bootstrap:
chmod +x scripts/oracle-bootstrap.sh
./scripts/oracle-bootstrap.sh
oracle-ssl-init:
chmod +x scripts/oracle-init-ssl.sh
./scripts/oracle-init-ssl.sh
oracle-up:
docker compose -f $(ORACLE_COMPOSE) up -d --build
oracle-down:
docker compose -f $(ORACLE_COMPOSE) down
oracle-deploy:
chmod +x scripts/oracle-deploy.sh
./scripts/oracle-deploy.sh
oracle-logs:
docker compose -f $(ORACLE_COMPOSE) logs -f --tail=200
oracle-shell:
docker compose -f $(ORACLE_COMPOSE) exec backend /bin/bash
oracle-ps:
docker compose -f $(ORACLE_COMPOSE) ps
oracle-backup:
docker compose -f $(ORACLE_COMPOSE) exec backup /backup.sh
oracle-restore:
@echo "Usage: docker compose -f $(ORACLE_COMPOSE) exec -T db psql -U \$$DB_USER \$$DB_NAME < backups/<file>.sql"