-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (80 loc) · 2.93 KB
/
Copy pathMakefile
File metadata and controls
112 lines (80 loc) · 2.93 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
.PHONY: help install up down restart logs test clean migrate migrate-create dev build
# Default target
.DEFAULT_GOAL := help
help: ## Show this help message
@echo "📦 Logit Server - Available Commands"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
install: ## Install dependencies with uv
uv sync
# Docker Commands
up: ## Start all services (with auto-migration)
docker compose up -d
dev: ## Start all services in watch mode (auto-reload)
docker compose up --watch
build: ## Build Docker images
docker compose build
down: ## Stop all services
docker compose down
restart: ## Restart all services
docker compose restart
logs: ## View logs (follow mode)
docker compose logs -f
logs-app: ## View app logs only
docker compose logs -f app
# Database Commands
migrate: ## Run database migrations (auto via entrypoint.sh)
docker compose exec app alembic upgrade head
migrate-create: ## Create new migration (example: make migrate-create MSG="Add user table")
docker compose exec app alembic revision --autogenerate -m "$(MSG)"
migrate-down: ## Rollback last migration
docker compose exec app alembic downgrade -1
migrate-history: ## Show migration history
docker compose exec app alembic history
# Test Commands
test: ## Run tests
docker compose exec app pytest
test-cov: ## Run tests with coverage
docker compose exec app pytest --cov=app --cov-report=html
test-local: ## Run tests locally (requires uv sync)
uv run pytest
# Database Management
db-shell: ## Open PostgreSQL shell
docker compose exec postgres psql -U logit -d logit_db
db-reset: ## Reset database (WARNING: deletes all data)
docker compose down -v
docker compose up -d postgres
sleep 5
docker compose up -d app
# Cleanup Commands
clean: ## Stop containers and remove volumes
docker compose down -v
clean-all: ## Deep clean (containers, volumes, images)
docker compose down -v --rmi all
docker system prune -f
# Development Commands
shell: ## Open shell in app container
docker compose exec app /bin/bash
format: ## Format code with ruff
uv run ruff format .
lint: ## Lint code with ruff
uv run ruff check .
type-check: ## Type check with mypy
uv run mypy src/
# Production Commands (Blue-Green Deployment)
prod-init: ## First-time production setup (starts blue)
chmod +x scripts/deploy.sh
./scripts/deploy.sh init
prod-deploy: ## Blue-green deploy to production
./scripts/deploy.sh deploy
prod-rollback: ## Rollback production to previous version
./scripts/deploy.sh rollback
prod-status: ## Show production deployment status
./scripts/deploy.sh status
prod-logs: ## View production logs (follow mode)
docker compose -f docker-compose.prod.yml logs -f
prod-down: ## Stop all production services
docker compose -f docker-compose.prod.yml down
# Quick Start
quick-start: build up ## Build and start all services
@echo "✅ Services started! Visit http://localhost:8000/docs"