This repository was archived by the owner on Jul 4, 2025. It is now read-only.
forked from langchain-ai/langconnect
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (59 loc) · 1.96 KB
/
Dockerfile
File metadata and controls
77 lines (59 loc) · 1.96 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
71
72
73
74
75
76
77
# Multi-stage build for smaller final image
FROM python:3.11-slim as builder
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
python3-dev \
libpq-dev \
curl \
libxml2-dev \
libxslt1-dev \
&& rm -rf /var/lib/apt/lists/*
# Install uv
RUN pip install --no-cache-dir uv
WORKDIR /app
# Copy dependency files and README (required by pyproject.toml)
COPY pyproject.toml uv.lock README.md ./
# Create virtual environment and install dependencies
RUN uv venv && \
uv sync --frozen && \
uv pip install streamlit "unstructured[docx]"
# Final stage
FROM python:3.11-slim
# Install runtime dependencies only
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libpq-dev \
libxml2 \
libxslt1.1 \
libmagic1 \
poppler-utils \
tesseract-ocr \
pandoc \
&& rm -rf /var/lib/apt/lists/*
# Install uv in the final stage for runtime use
RUN pip install --no-cache-dir uv
# Create non-root user
RUN groupadd -r langconnect && useradd -r -g langconnect langconnect
WORKDIR /app
# Create cache directory with proper permissions
RUN mkdir -p /home/langconnect/.cache && \
chown -R langconnect:langconnect /home/langconnect/.cache
# Copy virtual environment from builder
COPY --from=builder --chown=langconnect:langconnect /app/.venv /app/.venv
# Copy application code
COPY --chown=langconnect:langconnect . .
# Set environment variables
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Switch to non-root user
USER langconnect
# Expose ports for API, Streamlit, and MCP server
EXPOSE 8080 8501 8765
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8080/health').read()" || exit 1
# Default command runs the API server
CMD ["uvicorn", "langconnect.server:APP", "--host", "0.0.0.0", "--port", "8080"]