Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (35 loc) · 1.37 KB
/
Copy pathDockerfile
File metadata and controls
48 lines (35 loc) · 1.37 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
FROM python:3.11-slim-bookworm AS base
WORKDIR /app
FROM base AS builder
# Copy uv binaries from astral-sh image
COPY --from=ghcr.io/astral-sh/uv:0.6.3 /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
# Copy lock and project files first for caching
COPY uv.lock pyproject.toml /app/
# Install dependencies (frozen, no dev) using uv
# RUN --mount=type=cache,target=/root/.cache/uv \
# uv sync --frozen --no-install-project --no-dev
RUN uv sync --frozen --no-install-project --no-dev
# Copy application code and install project dependencies
COPY . /app
#RUN --mount=type=cache,target=/root/.cache/uv uv sync --frozen --no-dev
RUN uv sync --frozen --no-dev
# Final stage
FROM base
# Install curl for healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app /app
COPY --from=builder /bin/uv /bin/uv
# Set PATH to use venv created by uv
ENV PATH="/app/.venv/bin:$PATH"
# Create non-root user
RUN useradd --create-home --shell /bin/bash app && chown -R app:app /app
USER app
# Expose port
EXPOSE 9000
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:9000/health || exit 1
# Run your main script
CMD ["uv", "run", "python", "mcp_server.py", "--transport", "streamable-http", "--host", "0.0.0.0", "--port", "9000"]