Skip to content

[WIP] adding docker build #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Build stage
FROM debian:bookworm-slim AS builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
wget \
gcc \
g++ \
make \
zlib1g-dev \
libffi-dev \
libssl-dev \
libbz2-dev \
liblzma-dev \
clang \
&& rm -rf /var/lib/apt/lists/*

# Download and install Python from source
ENV PYTHON_VERSION=3.13.2
RUN wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \
&& tar -xf Python-${PYTHON_VERSION}.tgz \
&& cd Python-${PYTHON_VERSION} \
&& ./configure --enable-optimizations \
&& make -j$(nproc) \
&& make install \
&& cd .. \
&& rm -rf Python-${PYTHON_VERSION} \
&& rm Python-${PYTHON_VERSION}.tgz

# Create and activate virtual environment
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Install UV package manager
RUN pip install uv

# Set working directory
WORKDIR /app

# Copy application files
COPY . .

# Install dependencies
RUN uv sync

# Runtime stage
FROM debian:bookworm-slim

# Install runtime dependencies
RUN apt-get update && apt-get install -y \
zlib1g \
libffi8 \
libssl3 \
libbz2-1.0 \
liblzma5 \
&& rm -rf /var/lib/apt/lists/*

# Install Python from builder
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/lib /usr/local/lib
COPY --from=builder /usr/local/include /usr/local/include

# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Set working directory
WORKDIR /app

# Copy application files
COPY . .

# Expose port
EXPOSE 18123

# Run the application
CMD ["python3", "server.py"]
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mcp-clickhouse"
version = "0.1.7"
version = "0.1.8"
description = "An MCP server for ClickHouse."
readme = "README.md"
license = "Apache-2.0"
Expand All @@ -10,6 +10,7 @@ dependencies = [
"mcp[cli]>=1.3.0",
"python-dotenv>=1.0.1",
"uvicorn>=0.34.0",
"uvicorn[standard]>=0.34.0",
"clickhouse-connect>=0.8.16",
"pip-system-certs>=4.0",
]
Expand Down
5 changes: 5 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import uvicorn
from mcp_clickhouse.mcp_server import app

if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=18213)