How to setup LangGraph build with private repositories and uv
Setup LangGraph Build with Private Repositories
When building Docker images for LangGraph agents that depend on private repositories (like JFrog Artifactory) and use uv as a package manager, there are several approaches you can take. Here's how to set it up properly:
Method 1: Using dockerfile_lines with uv sync (Recommended)
In your
langgraph.jsonfile, adddockerfile_linesto pre-install dependencies usinguv sync:{ "dependencies": ["."], "graphs": {"agent": "./agent.py:graph"}, "dockerfile_lines": [ "COPY . /tmp/project", "WORKDIR /tmp/project", "RUN uv sync" ] }This approach copies your project and runs
uv syncbefore the auto-generateduv pip installcommand, ensuring youruv.lockfile is respectedBuild your image using:
langgraph build -t my-image
Method 2: Using Build Arguments for Credentials
Add build-time environment variables in your
langgraph.json:{ "dependencies": ["."], "graphs": {"agent": "./agent.py:graph"}, "dockerfile_lines": [ "ARG UV_INDEX_URL", "ARG UV_EXTRA_INDEX_URL", "ENV UV_INDEX_URL=${UV_INDEX_URL}", "ENV UV_EXTRA_INDEX_URL=${UV_EXTRA_INDEX_URL}" ] }Build with credentials passed as build arguments:
langgraph build -t my-image -- --build-arg UV_INDEX_URL=https://your-jfrog.com/pypi/simple --build-arg UV_EXTRA_INDEX_URL=...
Method 3: Using Docker Secrets (For LangSmith Deployments)
Add environment variables to your deployment through the LangSmith UI
In your
langgraph.json, use Docker secrets to access credentials at build time:{ "dockerfile_lines": [ "RUN --mount=type=secret,id=LANGCHAIN_SECRET,dst=/run/secrets/LANGCHAIN_SECRET " ] }Deploy your application - the secret will be available during build without being stored in the final image
Manual Dockerfile Approach
Generate a base Dockerfile:
langgraph dockerfileManually modify the generated Dockerfile to use
uv syncinstead ofuv pip installAdd proper credential handling for your private repositories
Build using standard Docker commands
Usage
Current Limitations:
The
langgraph buildCLI usesuv pip install --systemwhich doesn't leverageuv.lockfilesThe
envparameter inlanggraph.jsononly applies to runtime, not build timeBuild arguments may leave credentials in the final Docker image layers
Best Practices:
Use Method 1 (dockerfile_lines with uv sync) for the most reliable builds that respect your lockfile
Be careful with credential management - avoid logging or exporting secrets during build
For LangSmith deployments with large environment variables (>4000 characters), contact support for build-time environment variable support
Note: Feature requests have been submitted to support native uv sync functionality and improved uv authentication handling in future releases.
