Spaces:
Sleeping
Sleeping
File size: 3,402 Bytes
d884bf1 |
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# 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"
|