# mcrentcast - Makefile for Docker Compose management .PHONY: help dev prod up down logs shell test clean build lint format check install setup # Default environment ENV_FILE := .env # Load environment variables ifneq (,$(wildcard $(ENV_FILE))) include $(ENV_FILE) export endif # Default target help: ## Show this help message @echo "mcrentcast - Docker Compose Management" @echo "" @echo "Usage: make [target]" @echo "" @echo "Targets:" @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST) setup: ## Initial setup - copy .env.example to .env and create external caddy network @if [ ! -f .env ]; then \ cp .env.example .env; \ echo "Created .env file from .env.example"; \ echo "Please edit .env and set your RENTCAST_API_KEY"; \ fi @docker network inspect caddy >/dev/null 2>&1 || docker network create caddy @echo "Setup complete!" install: setup ## Install dependencies and sync with uv uv sync dev: setup ## Start development environment @echo "Starting development environment..." MODE=development docker compose up -d @echo "Development environment started!" @echo "Frontend: https://$(DOMAIN)" @echo "API: https://api.$(DOMAIN)" @echo "Logs: make logs" prod: setup ## Start production environment @echo "Starting production environment..." MODE=production docker compose up -d @echo "Production environment started!" up: ## Start services (uses MODE from .env, defaults to development) docker compose up -d down: ## Stop all services docker compose down logs: ## Show logs from all services docker compose logs -f logs-server: ## Show logs from MCP server only docker compose logs -f mcrentcast-server logs-frontend: ## Show logs from frontend only docker compose logs -f frontend shell: ## Get a shell in the MCP server container docker compose exec mcrentcast-server /bin/bash shell-db: ## Get a shell in the database container docker compose exec mcrentcast-db psql -U mcrentcast -d mcrentcast test: ## Run tests in container docker compose exec mcrentcast-server uv run pytest test-local: ## Run tests locally with uv uv run pytest test-mock: setup ## Run with mock API for testing @echo "Starting services with mock API..." USE_MOCK_API=true docker compose --profile mock up -d @echo "Mock API started at: https://mock-api.$(DOMAIN)" @echo "Available test API keys:" @echo " - test_key_free_tier (50 daily limit)" @echo " - test_key_basic (100 daily limit)" @echo " - test_key_pro (1000 daily limit)" @echo " - test_key_rate_limited (1 daily limit for testing)" mock-api: ## Start only the mock API service docker compose --profile mock up -d mock-rentcast-api @echo "Mock API running at http://localhost:8001" @echo "View test keys at: http://localhost:8001/test-keys" coverage: ## Run tests with coverage report docker compose exec mcrentcast-server uv run pytest --cov=src --cov-report=html:reports/coverage_html @echo "Coverage report: reports/coverage_html/index.html" lint: ## Run linting with ruff uv run ruff check src/ tests/ format: ## Format code with black and ruff uv run black src/ tests/ uv run ruff format src/ tests/ check: ## Run type checking with mypy uv run mypy src/ clean: ## Clean up containers, volumes, and cache docker compose down -v docker system prune -f rm -rf .pytest_cache/ reports/ htmlcov/ build: ## Build all images docker compose build rebuild: ## Rebuild all images from scratch docker compose build --no-cache restart: ## Restart all services docker compose restart restart-server: ## Restart MCP server only docker compose restart mcrentcast-server status: ## Show status of all services docker compose ps # Database management db-migrate: ## Run database migrations docker compose exec mcrentcast-server uv run python -m mcrentcast.db.migrate db-reset: ## Reset database (WARNING: destroys all data) @echo "WARNING: This will destroy all data in the database!" @read -p "Are you sure? [y/N] " -n 1 -r; \ if [[ $$REPLY =~ ^[Yy]$$ ]]; then \ docker compose down -v; \ docker volume rm $(COMPOSE_PROJECT)_postgres_data 2>/dev/null || true; \ docker compose up -d mcrentcast-db; \ echo "Database reset complete"; \ fi # Development helpers watch: ## Watch for file changes and restart server docker compose exec mcrentcast-server watchfiles --clear uv run uvicorn mcrentcast.server:app --reload src/ pip-compile: ## Update dependencies lock file uv lock # Production helpers deploy: prod ## Alias for prod backup-db: ## Backup database @mkdir -p backups docker compose exec mcrentcast-db pg_dump -U mcrentcast mcrentcast | gzip > backups/mcrentcast_$(shell date +%Y%m%d_%H%M%S).sql.gz @echo "Database backup created in backups/"