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

65
docker/Dockerfile Normal file
View File

@@ -0,0 +1,65 @@
# Gitea MCP Remote — Dockerfile
# Multi-stage build for optimized image size
FROM python:3.11-slim as builder
# Set working directory
WORKDIR /build
# Install build dependencies including git for marketplace dependency
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
# Copy source code
COPY pyproject.toml .
COPY src/ src/
# Install package (includes marketplace dependency from git)
RUN pip install --user --no-cache-dir .
# Production stage
FROM python:3.11-slim
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /root/.local /root/.local
# Copy source code
COPY src/ src/
COPY pyproject.toml .
# Make sure scripts in .local are usable
ENV PATH=/root/.local/bin:$PATH
# Set Python environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Default to port 8080 (Caddy proxies to this)
ENV HTTP_PORT=8080
ENV HTTP_HOST=0.0.0.0
# Expose port
EXPOSE 8080
# Health check using curl
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Run the MCP server
CMD ["gitea-mcp-remote"]