-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (96 loc) · 4.11 KB
/
Makefile
File metadata and controls
112 lines (96 loc) · 4.11 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
# Divemap Deployment Makefile
#
# Usage:
# make deploy - Deploy backend, frontend, and nginx
# make deploy-backend - Deploy only the backend
# make deploy-frontend - Deploy only the frontend
# make deploy-nginx - Deploy only the nginx proxy
# make test - Run all tests (backend and frontend)
# make test-backend - Run backend tests
# make test-frontend - Run frontend tests
# make purge-cache - Purge Cloudflare cache for divemap.gr
# make help - Show this help message
# Load environment variables from .env
-include .env
export
SHELL := /bin/bash
.PHONY: help deploy deploy-backend deploy-frontend deploy-nginx test test-backend test-frontend purge-cache check-api-contracts
# Default target
help:
@echo "Divemap Deployment Makefile"
@echo ""
@echo "Available targets:"
@echo " deploy - Deploy backend, frontend, and nginx"
@echo " deploy-backend - Deploy only the backend"
@echo " deploy-frontend - Deploy only the frontend"
@echo " deploy-nginx - Deploy only the nginx proxy"
@echo " test - Run all tests (backend and frontend)"
@echo " test-backend - Run backend tests"
@echo " test-frontend - Run frontend tests"
@echo " purge-cache - Purge Cloudflare cache for divemap.gr"
@echo " check-api-contracts - Verify frontend API calls match backend routes"
@echo " help - Show this help message"
@echo ""
# Deploy backend, frontend, and nginx
deploy: deploy-backend deploy-frontend deploy-nginx
@echo "✅ Backend, frontend, and nginx deployed successfully!"
@echo "🌐 Frontend: https://divemap-frontend.fly.dev/"
@echo "🔧 Backend: https://divemap-backend.fly.dev/"
@echo "🔄 Nginx Proxy: https://divemap.fly.dev/"
# Deploy only the backend
deploy-backend:
@echo "🚀 Deploying backend..."
@cd backend && fly deploy
@echo "✅ Backend deployed successfully!"
# Deploy only the frontend
deploy-frontend:
@echo "🚀 Deploying frontend..."
@cd frontend && ./deploy.sh .env.production
@echo "✅ Frontend deployed successfully!"
# Deploy only the nginx proxy
deploy-nginx:
@echo "🚀 Deploying nginx proxy..."
@cd nginx && fly deploy
@echo "✅ Nginx proxy deployed successfully!"
# Run all tests
test: test-backend test-frontend
@echo "✅ All tests completed successfully!"
# Run backend tests
test-backend:
@echo "🧪 Running backend tests..."
@cd backend && source divemap_venv/bin/activate && export PYTHONPATH="$$(pwd)/divemap_venv/lib/python3.11/site-packages:$$PYTHONPATH" && python -m pytest tests/ -v
@echo "✅ Backend tests completed!"
# Run frontend tests
test-frontend:
@echo "🧪 Running frontend tests..."
@cd frontend && npm test
@echo "✅ Frontend tests completed!"
# Generate content for AI crawlers (llms.txt)
generate-llm-content:
@echo "🤖 Generating LLM content in backend..."
@docker-compose exec -T backend python generate_static_content.py --force
@echo "✅ LLM content generated in backend/llm_content/"
# Run frontend linting and formatting, saving errors to a log file
lint-frontend:
@echo "🧹 Running frontend format and lint:fix..."
@docker exec divemap_frontend npm run format > /dev/null 2>&1 || true
@docker exec divemap_frontend npm run lint:fix -- --quiet > frontend-lint-errors.log 2>&1 || if [ $$(wc -l < frontend-lint-errors.log) -gt 2 ]; then echo "❌ Linting failed:"; cat frontend-lint-errors.log; exit 1; fi
@echo "✅ Linting complete. No errors found."
# Purge Cloudflare cache
purge-cache:
@echo "🧹 Purging Cloudflare cache for divemap.gr..."
@RESPONSE=$$(curl -s -X POST "https://api.cloudflare.com/client/v4/zones/$(CLOUDFLARE_ZONE_ID)/purge_cache" \
-H "Authorization: Bearer $(CLOUDFLARE_API_KEY)" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'); \
if echo "$$RESPONSE" | tr -d '[:space:]' | grep -q '"success":true'; then \
echo "✅ Cache purged!"; \
else \
echo "❌ Failed to purge cache:"; \
echo "$$RESPONSE"; \
exit 1; \
fi
# Verify frontend API calls match backend routes
check-api-contracts:
@echo "🔍 Verifying frontend API calls against backend OpenAPI schema..."
@python3 scripts/check_api_contracts.py