Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langchain ai Langgraph Langgraph Up Command

From Leeroopedia
Revision as of 11:26, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Langchain_ai_Langgraph_Langgraph_Up_Command.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Property Value
API `langgraph up` CLI command and `compose` function
Type External Tool Doc + API Doc
Source `libs/cli/langgraph_cli/cli.py` and `libs/cli/langgraph_cli/docker.py`
Library langgraph-cli
Related Workflow CLI_Deployment

Overview

The `langgraph up` command launches a complete LangGraph API server deployment as a Docker Compose stack. It validates the project configuration, generates Docker Compose YAML (including inline Dockerfile when needed), starts all services (API server, PostgreSQL, Redis, and optional debugger), and monitors the stack until the application is ready. The `compose` function in `libs/cli/langgraph_cli/docker.py` generates the Docker Compose configuration as a YAML string.

Description

langgraph up Command

The `up` command is registered at `libs/cli/langgraph_cli/cli.py:L168-292`. Its execution flow:

  1. Capability check: Verifies Docker and Docker Compose are installed and determines the Compose type (plugin vs. standalone) via `check_capabilities`.
  2. Preparation: Calls the `prepare` function which:
    • Validates the configuration file via `validate_config_file`.
    • Optionally pulls the latest base image.
    • Generates Docker Compose YAML via the `compose` function and `config_to_compose`.
  3. Service launch: Invokes `docker compose up` with options:
    • `--remove-orphans` to clean up stale containers.
    • `--force-recreate` and `--renew-anon-volumes` if `--recreate` is specified.
    • `--watch` for file watching mode.
    • `--wait` for headless startup or `--abort-on-container-exit` for foreground mode.
  4. Status monitoring: Watches stdout for `"Application startup complete"` to print the ready message with API URL, docs URL, and Studio URL.

compose Function

The `compose` function at `libs/cli/langgraph_cli/docker.py:L247-271` generates the complete Docker Compose YAML by delegating to `compose_as_dict` and converting the result to YAML via `dict_to_yaml`.

The `compose_as_dict` function at `libs/cli/langgraph_cli/docker.py:L138-244` builds the service definitions:

  • langgraph-redis: Redis 6 with ping health check.
  • langgraph-postgres: pgvector/pgvector:pg16 with data volume, health checks, and vector extension. Omitted if `postgres_uri` is provided externally.
  • langgraph-debugger: Optional Studio debugger on the specified port.
  • langgraph-api: The main service with port mapping, environment variables, and dependency ordering.

Command Options

Option Type Default Description
`--config` / `-c` `Path` `langgraph.json` Path to configuration file
`--port` / `-p` `int` `8123` Port to expose
`--docker-compose` / `-d` `Path` `None` Additional Docker Compose file
`--pull` / `--no-pull` flag `True` Pull latest images
`--recreate` / `--no-recreate` flag `False` Force-recreate containers
`--watch` flag `False` Restart on file changes
`--wait` flag `False` Wait for services to start (implies detach)
`--verbose` flag `False` Show more server logs
`--debugger-port` `int` `None` Port for Studio debugger UI
`--debugger-base-url` `str` `None` Custom URL for debugger to reach API
`--postgres-uri` `str` `None` External PostgreSQL URI
`--api-version` `str` `None` Pin API server version
`--image` `str` `None` Pre-built Docker image (skips building)
`--base-image` `str` `None` Override base image for building

Code Reference

Source Location

Item File Line
`up` command `libs/cli/langgraph_cli/cli.py` L168-292
`prepare` function `libs/cli/langgraph_cli/cli.py` L833-878
`prepare_args_and_stdin` `libs/cli/langgraph_cli/cli.py` L784-830
`compose` function `libs/cli/langgraph_cli/docker.py` L247-271
`compose_as_dict` function `libs/cli/langgraph_cli/docker.py` L138-244
`check_capabilities` `libs/cli/langgraph_cli/docker.py` L48-90
`DockerCapabilities` `libs/cli/langgraph_cli/docker.py` L25-29

Signature

# CLI command
@cli.command(help="Launch LangGraph API server.")
def up(
    config: pathlib.Path,
    docker_compose: pathlib.Path | None,
    port: int,
    recreate: bool,
    pull: bool,
    watch: bool,
    wait: bool,
    verbose: bool,
    debugger_port: int | None,
    debugger_base_url: str | None,
    postgres_uri: str | None,
    api_version: str | None,
    image: str | None,
    base_image: str | None,
):
    ...
# Internal compose function
def compose(
    capabilities: DockerCapabilities,
    *,
    port: int,
    debugger_port: int | None = None,
    debugger_base_url: str | None = None,
    postgres_uri: str | None = None,
    image: str | None = None,
    base_image: str | None = None,
    api_version: str | None = None,
) -> str:
    """Create a docker compose file as a string."""
    ...

Import

CLI command:

langgraph up [OPTIONS]

Internal Python API:

from langgraph_cli.docker import compose, check_capabilities, DockerCapabilities

I/O Contract

langgraph up

Direction Name Type Description
Input CLI options various Command-line flags and arguments
Input config file JSON `langgraph.json` configuration
Output Docker stack containers Running Docker Compose services
Output stdout text Ready message with API URL, docs URL, and Studio URL
Raises `click.UsageError` If Docker/Docker Compose is not installed or configuration is invalid

compose

Direction Name Type Description
Input `capabilities` `DockerCapabilities` Docker/Compose version information
Input `port` `int` Port for the API server
Input `debugger_port` None` Port for the Studio debugger
Input `debugger_base_url` None` URL for debugger to access API
Input `postgres_uri` None` External PostgreSQL URI (omits local DB if set)
Input `image` None` Pre-built image name
Input `base_image` None` Base image override
Input `api_version` None` API server version
Output return `str` Docker Compose YAML string

Usage Examples

Launch with Default Settings

# Start the full LangGraph stack on port 8123
langgraph up

Output when ready:

Ready!
- API: http://localhost:8123
- Docs: http://localhost:8123/docs
- LangGraph Studio: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:8123

Launch with Local Debugger

# Start with Studio debugger on port 3968
langgraph up --debugger-port 3968

Launch with External Database

# Use an external PostgreSQL instance
langgraph up --postgres-uri "postgres://user:password@db-host:5432/mydb?sslmode=require"

Launch Pre-Built Image

# Skip building, use an already-built image
langgraph up --image my-app:v1.0 --no-pull

CI/CD Headless Startup

# Wait for all services to be healthy, then return
langgraph up --wait

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment