diff --git a/Dockerfile b/Dockerfile index ed7ba88..c299bec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,43 +1,52 @@ -FROM python:3.10-slim +FROM python:3.12-slim-bookworm AS builder + +COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv -# Set working directory WORKDIR /app -# Set environment variables -ENV PYTHONDONTWRITEBYTECODE=1 \ - PYTHONUNBUFFERED=1 \ - PIP_NO_CACHE_DIR=1 \ - PIP_DISABLE_PIP_VERSION_CHECK=1 - -# Install system dependencies -RUN apt-get update && apt-get install -y --no-install-recommends \ - gcc \ - python3-dev \ - bash \ - && rm -rf /var/lib/apt/lists/* - -# Copy the project files -COPY . /app/ - -# Install uv -RUN pip install --upgrade pip && \ - pip install uv - -# Create a virtual environment, install dependencies -RUN uv venv /app/.venv && \ - . /app/.venv/bin/activate && \ +ENV UV_COMPILE_BYTECODE=1 + +COPY pyproject.toml ./ +COPY uv.lock ./ +COPY src ./src/ + +RUN uv venv && \ uv pip install -e . -# Make the entrypoint script executable -RUN chmod +x /app/docker-entrypoint.sh +FROM python:3.12-slim-bookworm + +WORKDIR /app + +COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv + +RUN groupadd -r app && useradd -r -g app app + +COPY --from=builder /app/.venv /app/.venv +COPY --from=builder /app/src /app/src +COPY pyproject.toml /app/ + +ENV PATH="/app/.venv/bin:$PATH" \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PYTHONPATH="/app" \ + PYTHONFAULTHANDLER=1 + +USER app + +EXPOSE 8000 -# Set the entrypoint -ENTRYPOINT ["/app/docker-entrypoint.sh"] +HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:8000/health || exit 1 -# Label the image -LABEL maintainer="pab1it0" \ - description="Prometheus MCP Server" \ - version="1.0.0" +CMD ["/app/.venv/bin/prometheus-mcp-server"] -# Expose port if needed (but this is optional as the MCP server typically runs on stdio) -# EXPOSE 8000 \ No newline at end of file +# GitHub Container Registry Metadata +LABEL org.opencontainers.image.title="Prometheus MCP Server" \ + org.opencontainers.image.description="Model Context Protocol server for Prometheus integration" \ + org.opencontainers.image.version="1.0.0" \ + org.opencontainers.image.authors="Pavel Shklovsky" \ + org.opencontainers.image.source="https://github.com/pab1it0/prometheus-mcp-server" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.url="https://github.com/pab1it0/prometheus-mcp-server" \ + org.opencontainers.image.documentation="https://github.com/pab1it0/prometheus-mcp-server#readme" \ + org.opencontainers.image.vendor="Pavel Shklovsky" \ No newline at end of file diff --git a/README.md b/README.md index a90adcb..630f8f7 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,8 @@ To use the containerized server with Claude Desktop, update the configuration to This configuration passes the environment variables from Claude Desktop to the Docker container by using the `-e` flag with just the variable name, and providing the actual values in the `env` object. +> **Note about Docker implementation**: The Docker setup has been updated to match the structure of the chess-mcp project, which has been proven to work correctly with Claude. The new implementation uses a multi-stage build process and runs the entry point script directly without an intermediary shell script. This approach ensures proper handling of stdin/stdout for MCP communication. + ## Development Contributions are welcome! Please open an issue or submit a pull request if you have any suggestions or improvements. @@ -212,4 +214,4 @@ MIT --- -[mcp]: https://modelcontextprotocol.io +[mcp]: https://modelcontextprotocol.io \ No newline at end of file