-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (40 loc) · 1.63 KB
/
Dockerfile
File metadata and controls
58 lines (40 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# DataBeak MCP Server - HTTP Mode
# Multi-stage build for minimal production image
# Build stage - install dependencies with uv
FROM python:3.12-slim AS builder
# Install uv for fast dependency management (pinned for reproducibility)
COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /uvx /bin/
WORKDIR /app
# Copy dependency files first for better layer caching
# README.md is required by pyproject.toml for package metadata
COPY pyproject.toml uv.lock README.md ./
# Create virtual environment and install production dependencies only
RUN uv sync --frozen --no-dev --no-install-project
# Copy source code
COPY src/ ./src/
# Install the project itself
RUN uv sync --frozen --no-dev
# Production stage - minimal runtime image
FROM python:3.12-slim AS runtime
# Security: run as non-root user
RUN groupadd --gid 1000 databeak \
&& useradd --uid 1000 --gid 1000 --shell /bin/bash --create-home databeak
WORKDIR /app
# Copy virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Copy source code
COPY --from=builder /app/src /app/src
# Set environment variables
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Switch to non-root user
USER databeak
# Expose HTTP port
EXPOSE 8000
# Health check for container orchestration (uses stdlib to avoid dependency on httpx)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health', timeout=5)"
# Run the MCP server in HTTP mode
ENTRYPOINT ["python", "-m", "databeak.server"]
CMD ["--transport", "http", "--host", "0.0.0.0", "--port", "8000"]