# Pikud Haoref Real-Time Alert System - Docker Management
# Usage: make <command>
.PHONY: help build up down restart logs logs-app logs-mcp clean rebuild test status
# Default target
help:
@echo "๐ Pikud Haoref Alert System - Docker Commands"
@echo ""
@echo "๐ Available commands:"
@echo " make build - Build all Docker containers"
@echo " make up - Start all services"
@echo " make down - Stop all services"
@echo " make restart - Restart all services (down + build + up)"
@echo " make rebuild - Force rebuild all containers (no cache)"
@echo ""
@echo "๐ Monitoring:"
@echo " make logs - Show logs from all services"
@echo " make logs-app - Show logs from FastAPI app only"
@echo " make logs-mcp - Show logs from MCP server only"
@echo " make status - Show container status"
@echo ""
@echo "๐งช Testing:"
@echo " make test - Run test suite"
@echo " make test-alert - Create a test Hebrew missile alert"
@echo " make test-alert-en - Create a test English earthquake alert"
@echo ""
@echo "๐งน Cleanup:"
@echo " make clean - Stop and remove POHA containers, networks, and volumes only"
@echo " make clean-all - Stop and remove ALL Docker resources (use with caution)"
@echo ""
@echo "๐ Access URLs:"
@echo " FastAPI: http://localhost:8000"
@echo " Swagger UI: http://localhost:8000/docs"
@echo " MCP Server: http://localhost:8001"
# Build containers
build:
@echo "๐จ Building Docker containers..."
cd docker && docker-compose build
# Start services
up:
@echo "๐ Starting services..."
cd docker && docker-compose up -d
@echo "โ
Services started!"
@echo "๐ฑ FastAPI: http://localhost:8000"
@echo "๐ฑ Swagger: http://localhost:8000/docs"
@echo "๐ฑ MCP Server: http://localhost:8001"
# Stop services
down:
@echo "๐ Stopping services..."
cd docker && docker-compose down
# Quick restart (most common during development)
restart:
@echo "๐ Restarting services..."
@make down
@make build
@make up
# Force rebuild without cache
rebuild:
@echo "๐จ Force rebuilding all containers..."
cd docker && docker-compose build --no-cache
@make up
# Show all logs
logs:
@echo "๐ Showing logs from all services..."
cd docker && docker-compose logs -f
# Show app logs only
logs-app:
@echo "๐ Showing FastAPI app logs..."
cd docker && docker-compose logs -f app
# Show MCP server logs only
logs-mcp:
@echo "๐ Showing MCP server logs..."
cd docker && docker-compose logs -f mcp-server
# Show container status
status:
@echo "๐ Container Status:"
@docker ps --filter "name=poha" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
@echo ""
@echo "๐ Resource Usage:"
@docker stats --no-stream --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" $(shell docker ps --filter "name=poha" --format "{{.Names}}" | tr '\n' ' ')
# Run tests
test:
@echo "๐งช Running test suite..."
cd docker && docker-compose exec app pytest -v
# Create test alerts for quick testing
test-alert:
@echo "๐จ Creating test Hebrew missile alert..."
@curl -X POST "http://localhost:8000/api/test/fake-alert" \
-H "X-API-Key: poha-test-key-2024-secure" \
-H "Content-Type: application/json" \
-d '{"data": ["ืชื ืืืื - ืืจืื ืืขืืจ", "ืจืืช ืื"], "cat": "1", "language": "he"}' \
-s | jq '.'
test-alert-en:
@echo "๐ Creating test English earthquake alert..."
@curl -X POST "http://localhost:8000/api/test/fake-alert" \
-H "X-API-Key: poha-test-key-2024-secure" \
-H "Content-Type: application/json" \
-d '{"data": ["Jerusalem", "Haifa"], "cat": "3", "language": "en"}' \
-s | jq '.'
test-alert-drill:
@echo "๐ข Creating test drill alert..."
@curl -X POST "http://localhost:8000/api/test/fake-alert" \
-H "X-API-Key: poha-test-key-2024-secure" \
-H "Content-Type: application/json" \
-d '{"data": ["ืื ืืืจืฅ"], "cat": "101", "language": "he"}' \
-s | jq '.'
# Comprehensive cleanup - POHA containers only
clean:
@echo "๐งน Cleaning up POHA Docker resources..."
cd docker && docker-compose down -v --remove-orphans
@echo "๐๏ธ Removing POHA Docker images..."
@docker images --filter "reference=docker-*" -q | xargs -r docker rmi -f 2>/dev/null || echo "No POHA images to remove"
@echo "โ
POHA cleanup complete (only POHA containers and images removed)!"
# Full system cleanup (use with caution)
clean-all:
@echo "โ ๏ธ WARNING: This will remove ALL Docker resources!"
@echo "๐งน Cleaning up ALL Docker resources..."
cd docker && docker-compose down -v --remove-orphans
@echo "๐๏ธ Removing ALL unused Docker resources..."
docker system prune -f
@echo "โ
Full cleanup complete!"
# Development workflow shortcuts
dev: restart logs-app
@echo "๐ Development mode: containers restarted, showing app logs"
# Quick app-only restart (faster for code changes)
app-restart:
@echo "๐ Restarting FastAPI app only..."
cd docker && docker-compose stop app
cd docker && docker-compose build app
cd docker && docker-compose start app
@echo "โ
FastAPI app restarted!"
# Quick MCP-only restart
mcp-restart:
@echo "๐ Restarting MCP server only..."
cd docker && docker-compose stop mcp-server
cd docker && docker-compose build mcp-server
cd docker && docker-compose start mcp-server
@echo "โ
MCP server restarted!"
# Health check
health:
@echo "๐ฅ Checking service health..."
@echo "๐ฑ FastAPI Health:"
@curl -s http://localhost:8000/ | jq '.' || echo "โ FastAPI not responding"
@echo "๐ฑ MCP Server Health:"
@curl -s http://localhost:8001/ | head -1 || echo "โ MCP Server not responding"
# Show recent app errors
errors:
@echo "๐จ Recent errors from FastAPI app:"
@cd docker && docker-compose logs app | grep -i error | tail -10 || echo "No recent errors found"
# Interactive shell into app container
shell-app:
@echo "๐ Opening shell in FastAPI app container..."
cd docker && docker-compose exec app /bin/bash
# Interactive shell into MCP container
shell-mcp:
@echo "๐ Opening shell in MCP server container..."
cd docker && docker-compose exec mcp-server /bin/bash