# Makefile for MCP Sentiment Analysis Server # Variables IMAGE_NAME = mcp-sentiment CONTAINER_NAME = mcp-sentiment-container PORT = 7860 DOCKER_REGISTRY = VERSION = latest # Default target .PHONY: help help: @echo "MCP Sentiment Analysis Server - Development Commands" @echo "==================================================" @echo "" @echo "Development:" @echo " install Install Python dependencies locally" @echo " run Run the server locally (without Docker)" @echo " test Run tests locally" @echo "" @echo "Docker:" @echo " build Build Docker image" @echo " run-docker Run Docker container" @echo " stop Stop Docker container" @echo " logs Show Docker container logs" @echo " shell Open shell in running container" @echo "" @echo "Testing:" @echo " test-docker Test Docker container" @echo " test-all Run all tests (local + Docker)" @echo "" @echo "Deployment:" @echo " deploy-hf Deploy to Hugging Face Spaces (interactive)" @echo "" @echo "Cleanup:" @echo " clean Remove Docker containers and images" @echo " clean-all Remove everything including volumes" # Development targets .PHONY: install install: pip install -r requirements.txt .PHONY: run run: python app.py .PHONY: test test: python test_mcp_server.py # Docker targets .PHONY: build build: docker build -t $(IMAGE_NAME):$(VERSION) . .PHONY: run-docker run-docker: build docker run -d \ --name $(CONTAINER_NAME) \ -p $(PORT):7860 \ $(IMAGE_NAME):$(VERSION) @echo "Container started. Access at http://localhost:$(PORT)" @echo "MCP endpoint: http://localhost:$(PORT)/gradio_api/mcp/sse" .PHONY: stop stop: -docker stop $(CONTAINER_NAME) -docker rm $(CONTAINER_NAME) .PHONY: logs logs: docker logs -f $(CONTAINER_NAME) .PHONY: shell shell: docker exec -it $(CONTAINER_NAME) /bin/bash # Testing targets .PHONY: test-docker test-docker: python test_mcp_server.py --server --wait .PHONY: test-all test-all: test test-docker # Deployment targets .PHONY: deploy-hf deploy-hf: @echo "Deploying to Hugging Face Spaces..." @read -p "Enter your HF username: " username; \ read -p "Enter space name: " space_name; \ python deploy_to_hf.py $$space_name $$username # Docker Compose targets .PHONY: up up: docker-compose up -d .PHONY: down down: docker-compose down .PHONY: restart restart: down up # Cleanup targets .PHONY: clean clean: stop -docker rmi $(IMAGE_NAME):$(VERSION) -docker system prune -f .PHONY: clean-all clean-all: clean -docker volume prune -f -docker network prune -f # Development workflow .PHONY: dev dev: install test build test-docker @echo "Development setup complete!" # Production workflow .PHONY: prod prod: clean build test-docker @echo "Production build complete!" # Quick start .PHONY: quick-start quick-start: build run-docker @echo "Quick start complete!" @echo "Waiting for server to be ready..." @sleep 5 @python test_mcp_server.py --server --url=http://localhost:$(PORT) # Health check .PHONY: health health: @curl -f http://localhost:$(PORT)/ || echo "Server not responding" # Show running containers .PHONY: ps ps: docker ps --filter "name=$(CONTAINER_NAME)" # Show image info .PHONY: info info: @echo "Image: $(IMAGE_NAME):$(VERSION)" @echo "Container: $(CONTAINER_NAME)" @echo "Port: $(PORT)" @docker images $(IMAGE_NAME) || echo "Image not built yet"