-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.server
More file actions
101 lines (84 loc) · 4.12 KB
/
Dockerfile.server
File metadata and controls
101 lines (84 loc) · 4.12 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Dockerfile for LangGraph server
FROM python:3.11-slim
ARG UV_NO_CACHE=0
ENV UV_NO_CACHE=${UV_NO_CACHE}
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
curl \
unzip \
git \
&& rm -rf /var/lib/apt/lists/*
# Install Deno for langchain-sandbox
RUN curl -fsSL https://deno.land/install.sh | sh
ENV DENO_INSTALL="/root/.deno"
ENV PATH="$DENO_INSTALL/bin:$PATH"
# Copy project files
COPY pyproject.toml .
COPY README.md .
COPY src/ ./src/
COPY tests/ ./tests/
COPY langgraph.json .
COPY constraints.txt .
########################################
# Deepagents ref for cache-busting and pinning
########################################
# Install Python dependencies with constraints
RUN pip install --no-cache-dir uv && \
if [ "$UV_NO_CACHE" = "1" ]; then uv cache clean && rm -rf /root/.cache/uv; fi && \
uv pip install --system --constraint constraints.txt .[browser] && \
python -m playwright install --with-deps chromium
# Install upstream deepagents (latest published ref)
RUN set -eux; \
echo "🧩 Installing deepagents from upstream"; \
if [ "$UV_NO_CACHE" = "1" ]; then uv cache clean && rm -rf /root/.cache/uv; fi; \
uv pip install --system deepagents; \
python -c "import deepagents,inspect; import deepagents.sub_agent as sa; print('[deepagents] module:', deepagents.__file__); s=inspect.getsource(sa._create_task_tool); print('[deepagents] task tool contains graph handoff =', 'graph=' in s)"
# Install langgraph CLI and API to serve graphs in-process
RUN if [ "$UV_NO_CACHE" = "1" ]; then uv cache clean && rm -rf /root/.cache/uv; fi && \
uv pip install --system "langgraph-cli[inmem]" && \
uv pip install --system "langgraph-api"
# Install Postgres checkpointer for LangGraph persistence
RUN if [ "$UV_NO_CACHE" = "1" ]; then uv cache clean && rm -rf /root/.cache/uv; fi && \
uv pip install --system "langgraph-checkpoint-postgres" && \
uv pip install --system "langgraph-checkpoint" && \
uv pip install --system "psycopg[binary,pool]"
# Verify langchain-sandbox is from GitHub (version should be 0.0.7+, not 0.0.1 from PyPI)
RUN python -c "import langchain_sandbox; import sys; version = getattr(langchain_sandbox, '__version__', 'unknown'); print(f'langchain-sandbox version: {version}'); sys.exit(1 if version == '0.0.1' else 0)" && \
echo "✅ langchain-sandbox correctly installed from GitHub"
# Download and prepare TypeScript source from GitHub to avoid JSR dependencies
# Use /opt for permanent storage (not /tmp which might be cleared)
RUN mkdir -p /opt/langchain_sandbox && \
curl -s -o /opt/langchain_sandbox/pyodide_sandbox.ts \
https://raw.githubusercontent.com/johannhartmann/langchain-sandbox/main/libs/pyodide-sandbox-js/main.ts && \
# Replace JSR imports with Deno.land URLs
sed -i 's|import { join } from "@std/path";|import { join } from "https://deno.land/std@0.224.0/path/mod.ts";|' \
/opt/langchain_sandbox/pyodide_sandbox.ts && \
sed -i 's|import { parseArgs } from "@std/cli/parse-args";|import { parseArgs } from "https://deno.land/std@0.224.0/cli/parse_args.ts";|' \
/opt/langchain_sandbox/pyodide_sandbox.ts && \
# Fix pyodide import
sed -i 's|import { loadPyodide } from "pyodide";|import { loadPyodide } from "npm:pyodide@0.26.4";|' \
/opt/langchain_sandbox/pyodide_sandbox.ts && \
# Set proper permissions
chmod 644 /opt/langchain_sandbox/pyodide_sandbox.ts && \
echo "✅ TypeScript source prepared from GitHub"
# Set environment variable that pyodide.py expects (LANGCHAIN_SANDBOX_TS_PATH not TS_SOURCE)
ENV LANGCHAIN_SANDBOX_TS_PATH=/opt/langchain_sandbox/pyodide_sandbox.ts
# Verify the TypeScript file is accessible
RUN test -s /opt/langchain_sandbox/pyodide_sandbox.ts || exit 1
# Expose ports for both servers
EXPOSE 2024 8001
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV LANGSMITH_TRACING=true
ENV LANGSMITH_PROJECT=learning-agent
ENV DOCKER_ENV=1
# Copy scripts
COPY scripts/start_servers.sh /app/scripts/
# Make script executable
RUN chmod +x /app/scripts/start_servers.sh
# Run both servers
CMD ["/app/scripts/start_servers.sh"]