feat: Add Docker infrastructure with Caddy and startup scripts (#25, #26)

Issue #25 - Docker multi-service infrastructure:
- Create docker/Dockerfile with multi-stage build, git support, port 8080
- Create docker/docker-compose.yml with app + Caddy services
- Create docker/Caddyfile for HTTPS termination and reverse proxy
- Create docker/.env.example with configuration template

Issue #26 - Startup scripts and tests:
- Create scripts/start.sh for production startup with env validation
- Create scripts/healthcheck.sh for Docker health checks
- Add health endpoint tests to test_mcp_endpoints.py
- Fix middleware order (HealthCheckBypass must wrap BearerAuth)
- Fix pyproject.toml testpaths to use 'tests' directory
- Update test_config.py for new defaults (0.0.0.0:8080)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 21:11:29 -05:00
parent 9fea0683f7
commit 88c16c840b
10 changed files with 345 additions and 15 deletions

21
scripts/healthcheck.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Health check script for Gitea MCP Remote
#
# Used by Docker healthcheck and monitoring systems.
# Returns exit code 0 if healthy, 1 if unhealthy.
set -e
HOST="${HTTP_HOST:-localhost}"
PORT="${HTTP_PORT:-8080}"
ENDPOINT="http://${HOST}:${PORT}/health"
# Make request and check response
response=$(curl -sf "$ENDPOINT" 2>/dev/null) || exit 1
# Verify JSON response contains status: ok
if echo "$response" | grep -q '"status".*"ok"'; then
exit 0
else
exit 1
fi

60
scripts/start.sh Executable file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
# Production startup script for Gitea MCP Remote
#
# This script validates the environment and starts the server.
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}Starting Gitea MCP Remote...${NC}"
# Check required environment variables
check_required_env() {
local var_name=$1
if [ -z "${!var_name}" ]; then
echo -e "${RED}ERROR: Required environment variable $var_name is not set${NC}"
return 1
fi
echo -e "${GREEN} $var_name is set${NC}"
}
echo "Checking required environment variables..."
MISSING=0
check_required_env "GITEA_URL" || MISSING=1
check_required_env "GITEA_TOKEN" || MISSING=1
check_required_env "GITEA_OWNER" || MISSING=1
if [ $MISSING -eq 1 ]; then
echo -e "${RED}Missing required environment variables. Exiting.${NC}"
echo ""
echo "Required variables:"
echo " GITEA_URL - Gitea server URL (e.g., https://gitea.example.com)"
echo " GITEA_TOKEN - Gitea API token"
echo " GITEA_OWNER - Default repository owner"
echo ""
echo "Optional variables:"
echo " GITEA_REPO - Default repository name"
echo " AUTH_TOKEN - Bearer token for MCP endpoint authentication"
echo " HTTP_HOST - Server host (default: 0.0.0.0)"
echo " HTTP_PORT - Server port (default: 8080)"
exit 1
fi
# Show optional configuration
echo ""
echo "Optional configuration:"
[ -n "$GITEA_REPO" ] && echo -e " ${GREEN}GITEA_REPO: $GITEA_REPO${NC}" || echo -e " ${YELLOW}GITEA_REPO: not set (will use per-request)${NC}"
[ -n "$AUTH_TOKEN" ] && echo -e " ${GREEN}AUTH_TOKEN: (set)${NC}" || echo -e " ${YELLOW}AUTH_TOKEN: not set (no auth required)${NC}"
echo " HTTP_HOST: ${HTTP_HOST:-0.0.0.0}"
echo " HTTP_PORT: ${HTTP_PORT:-8080}"
# Start the server
echo ""
echo -e "${GREEN}Starting server...${NC}"
exec gitea-mcp-remote