mirror of
https://github.com/hanzoai/mcp.git
synced 2026-10-15 12:30:12 +00:00
- Add docker-publish.yml workflow for ghcr.io - Add production-ready Dockerfile (if missing) - Enable automated builds on push to main - Support for semantic versioning tags
73 lines
1.9 KiB
Docker
73 lines
1.9 KiB
Docker
# Multi-stage Dockerfile for Hanzo MCP
|
|
# This Dockerfile creates a production-ready image for the Hanzo Model Context Protocol server
|
|
|
|
# Build stage
|
|
FROM python:3.12-slim AS builder
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
build-essential \
|
|
git \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install uv for fast Python package management
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
ENV PATH="/root/.cargo/bin:${PATH}"
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy dependency files
|
|
COPY pyproject.toml uv.lock ./
|
|
|
|
# Install dependencies - using pip since this project uses setuptools
|
|
RUN python -m venv .venv && \
|
|
.venv/bin/pip install --upgrade pip && \
|
|
.venv/bin/pip install -e .
|
|
|
|
# Production stage
|
|
FROM python:3.12-slim
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates \
|
|
git \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user
|
|
RUN groupadd -r hanzo && useradd -r -g hanzo hanzo
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy virtual environment from builder
|
|
COPY --from=builder /app/.venv /app/.venv
|
|
|
|
# Copy application code
|
|
COPY --chown=hanzo:hanzo . .
|
|
|
|
# Install the package in the final stage
|
|
RUN .venv/bin/pip install -e .
|
|
|
|
# Set environment variables
|
|
ENV PATH="/app/.venv/bin:${PATH}"
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV MCP_SERVER_PORT=8080
|
|
|
|
# Create necessary directories
|
|
RUN mkdir -p /app/logs /app/data && chown -R hanzo:hanzo /app/logs /app/data
|
|
|
|
# Switch to non-root user
|
|
USER hanzo
|
|
|
|
# Expose port
|
|
EXPOSE 8080
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|
CMD python -c "import httpx; httpx.get('http://localhost:8080/health').raise_for_status()" || exit 1
|
|
|
|
# Start the MCP server
|
|
CMD ["hanzo-mcp", "server", "--host", "0.0.0.0", "--port", "8080"] |