-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (51 loc) · 2.33 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (51 loc) · 2.33 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
59
60
61
62
63
64
65
66
67
68
69
70
# Use Python 3.12 slim image for smaller size
FROM python:3.12-slim AS builder
# Set working directory
WORKDIR /opt/courtlistener
# Install system dependencies needed for building
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install uv
RUN pip install --no-cache-dir uv
# Copy dependency files first (for better caching)
COPY pyproject.toml uv.lock ./
# Install dependencies (not the local package yet)
RUN uv sync --frozen --no-dev --no-install-project
# Multi-stage build for smaller final image
FROM python:3.12-slim
# Set working directory
WORKDIR /opt/courtlistener
# curl is required by the container/orchestrator health check
# (`curl -f http://localhost:8000/health`). The slim base image has none.
RUN apt-get update && apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r courtlistener && useradd -r -g courtlistener -m courtlistener
# Copy virtual environment and project files from builder
COPY --from=builder /opt/courtlistener/.venv .venv
COPY --from=builder /opt/courtlistener/pyproject.toml /opt/courtlistener/uv.lock ./
# Copy application code
COPY app ./app
# Pre-compile Python bytecode for faster startup
RUN python -m compileall -q ./app .venv/lib
# Set ownership for non-root user
RUN chown -R courtlistener:courtlistener /opt/courtlistener
# Switch to non-root user
USER courtlistener
# Set Python-related environment variables
ENV PYTHONUNBUFFERED=1 \
PATH="/opt/courtlistener/.venv/bin:$PATH"
# Expose default MCP port
EXPOSE 8000
# Labels for container metadata
LABEL org.opencontainers.image.title="CourtListener MCP Server" \
org.opencontainers.image.description="MCP server providing LLM access to the CourtListener legal database and eCFR federal regulations" \
org.opencontainers.image.version="0.2.0" \
org.opencontainers.image.source="https://github.com/Vaquill-AI/courtlistener-mcp"
# Container-level health check (mirrors the orchestrator's /health probe)
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Default to HTTP transport for container use, bound to all interfaces
# Override with MCP_TRANSPORT=stdio for CLI integration
CMD ["python", "-m", "app", "--transport", "http", "--host", "0.0.0.0"]