以编程方式使用文档

默认情况下,LangSmith 会从我们的公共 Docker 仓库拉取镜像。但是,如果您在没有互联网访问的环境中运行 LangSmith,或者您想使用私有 Docker 仓库,您可以将镜像同步到您自己的仓库,然后配置您的 LangSmith 安装以使用这些镜像。

要求

  • * Authenticated access to a Docker registry that your Kubernetes cluster/machine has access to.
  • * 在本地计算机或可以访问 Docker 仓库的计算机上安装 Docker。
  • * 一个可以运行 LangSmith 的 Kubernetes 集群。

同步镜像

为方便起见,我们提供了一个脚本,可以帮助您同步镜像。您可以在 LangSmith Helm Chart 仓库

中找到该脚本。要使用该脚本,您需要使用以下命令运行脚本,指定您的仓库和平台:

bash mirror_images.sh <your-registry> [<platform>]

其中 <your-registry> 是您的 Docker 仓库的 URL(例如 myregistry.com), <platform> 是您使用的平台(例如 linux/amd64, linux/arm64 等)。如果未指定平台,默认使用 linux/amd64.

例如,如果您的仓库是 myregistry.com,您的平台是 linux/arm64,且您想使用最新版本的镜像,请运行:

bash mirror_langsmith_images.sh --registry myregistry --platform linux/arm64 --version 0.10.66

Note that this script will assume that you have Docker installed and that you are authenticated to your registry. It will also push the images to the specified registry with the same repository/tag as the original images.

或者,您可以手动拉取、同步和推送镜像。您需要在 values.yaml LangSmith Helm Chart 的文件中找到需要同步的镜像。这些可以在以下位置找到: LangSmith Helm Chart values.yaml

以下是使用 Docker 同步镜像的示例:

# Pull the images from the public registry
docker pull langchain/langsmith-backend:latest
docker tag langchain/langsmith-backend:latest <your-registry>/langsmith-backend:latest
docker push <your-registry>/langsmith-backend:latest

对于每个要同步的镜像,您都需要重复此操作。

配置

镜像同步完成后,您需要配置您的 LangSmith 安装以使用同步的镜像。您可以通过修改 values.yaml LangSmith Helm Chart 安装文件来执行此操作。将 tag 替换为您要使用的版本,例如 0.10.66 ,这是撰写本文时的最新版本。

images:
  imagePullSecrets: [] # Add your image pull secrets here if needed
  registry: "" # Set this to your registry URL if you mirrored all images to the same registry using our script. Then you can remove the repository prefix from the images below.
  aceBackendImage:
    repository: "(your-registry)/langchain/langsmith-ace-backend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  backendImage:
    repository: "(your-registry)/langchain/langsmith-backend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  frontendImage:
    repository: "(your-registry)/langchain/langsmith-frontend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  hostBackendImage:
    repository: "(your-registry)/langchain/hosted-langserve-backend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  operatorImage:
    repository: "(your-registry)/langchain/langgraph-operator"
    pullPolicy: IfNotPresent
    tag: "6cc83a8"
  platformBackendImage:
    repository: "(your-registry)/langchain/langsmith-go-backend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  playgroundImage:
    repository: "(your-registry)/langchain/langsmith-playground"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  postgresImage:
    repository: "(your-registry)/postgres"
    pullPolicy: IfNotPresent
    tag: "14.7"
  redisImage:
    repository: "(your-registry)/redis"
    pullPolicy: IfNotPresent
    tag: "7"
  clickhouseImage:
    repository: "(your-registry)/clickhouse/clickhouse-server"
    pullPolicy: Always
    tag: "24.8"

Fleet 和 Insights 的附加镜像

如果您使用 Fleet 或 Insights,LangGraph operator 会为每个部署动态创建 Redis 和 PostgreSQL(pgvector)Pod。这些 Pod 使用 operator 模板中定义的镜像,需要单独配置。

您必须同步这些附加镜像: - docker.io/redis:7 - docker.io/pgvector/pgvector:pg15

然后在您的 values.yaml 中覆盖 operator 模板以使用同步的镜像:

operator:
  templates:
    redis: |
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: ${service_name}
        namespace: ${namespace}
      spec:
        replicas: 1
        selector:
          matchLabels:
            app: ${service_name}
        template:
          metadata:
            labels:
              app: ${service_name}
          spec:
            enableServiceLinks: false
            containers:
            - name: redis
              image: (your-registry)/redis:7
              ports:
              - containerPort: 6379
                name: redis
              livenessProbe:
                exec:
                  command:
                  - redis-cli
                  - ping
                initialDelaySeconds: 30
                periodSeconds: 10
              readinessProbe:
                tcpSocket:
                  port: 6379
                initialDelaySeconds: 10
                periodSeconds: 5
    db: |
      apiVersion: apps/v1
      kind: StatefulSet
      metadata:
        name: ${service_name}
      spec:
        serviceName: ${service_name}
        selector:
          matchLabels:
            app: ${service_name}
        persistentVolumeClaimRetentionPolicy:
          whenDeleted: Delete
          whenScaled: Retain
        template:
          metadata:
            labels:
              app: ${service_name}
          spec:
            containers:
            - name: postgres
              image: (your-registry)/pgvector/pgvector:pg15
              ports:
              - containerPort: 5432
              command: ["docker-entrypoint.sh"]
              args:
                - postgres
                - -c
                - max_connections=${max_connections}
              env:
              - name: PGDATA
                value: /var/lib/postgresql/data/pgdata
              volumeMounts:
              - name: postgres-data
                mountPath: /var/lib/postgresql/data
            enableServiceLinks: false
        volumeClaimTemplates:
        - metadata:
            name: postgres-data
          spec:
            accessModes: ["ReadWriteOnce"]
            resources:
              requests:
                storage: "${storage_gi}Gi"

(your-registry) 替换为您的仓库 URL。模板变量(${service_name}, ${namespace}, ${max_connections}, ${storage_gi})在运行时由 operator 替换,必须保持原样。

配置完成后,您需要更新您的 LangSmith 安装。您可以按照我们的升级指南操作: 升级 LangSmith。如果升级成功,您的 LangSmith 实例现在应该正在使用来自 Docker 仓库的同步镜像。

验证镜像签名

稳定版 LangSmith 镜像在 docker.io/langchain/* 在发布时使用无密钥方式签名 Sigstore/Cosign 。签名身份绑定到特定的 GitHub Actions 工作流、运行和提交,因此签名不仅证明镜像真实可靠,还证明它是由在以下环境中运行的稳定分支发布流水线生成的 langchain-ai/langchainplus。您可以在拉取或镜像镜像之前验证签名,也可以在镜像之后再次验证以确认您镜像的摘要与我们签名的内容一致。

安装 cosign (安装指南),然后验证任意标签:

cosign verify \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-identity-regexp 'https://github\.com/langchain-ai/langchainplus/\.github/workflows/release_self_hosted_on_version_bump\.yaml@refs/heads/v[0-9]+-stable' \
  docker.io/langchain/langsmith-backend:<tag>

成功的验证确认:

  • - 签名上的 cosign 声明有效。
  • - 证书链到 Sigstore 根并记录在 Rekor 透明度日志中。
  • - 签名证书通过 GitHub Actions OIDC 颁发给稳定分支发布工作流。

同一命令可对任何已发布镜像进行验证,只需替换仓库(langsmith-frontend, langsmith-go-backend, agent-builder-deep-agent, langsmith-clio, langsmith-polly, agent-builder-tool-server, agent-builder-trigger-server, hosted-langserve-backend, langsmith-playground, langsmith-ace-backend及其 *-fips 变体)。

固定到特定版本

要进行更严格的验证(例如固定到单个稳定分支或特定提交),请删除正则表达式并提供确切的证书身份。每个签名的证书还包含工作流运行 ID 和提交 SHA 作为主题备用名称扩展,因此您可以限制到特定版本:

cosign verify \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-identity 'https://github.com/langchain-ai/langchainplus/.github/workflows/release_self_hosted_on_version_bump.yaml@refs/heads/v15-stable' \
  docker.io/langchain/langsmith-backend:0.15.9

要检查证书的声明(工作流运行、提交、运行器),请下载证明并解码嵌入的证书:

cosign download attestation docker.io/langchain/langsmith-backend:<tag>

验证 SBOM 证明

发布的镜像还包含签名的 SPDX 软件物料清单(SBOM)证明,每个架构一份。证明附加在每架构子摘要而非多架构标签上,因此 cosign verify-attestation 对裸标签报告 no matching attestations。请先解析子摘要,然后验证每个摘要。

列出标签的每架构摘要:

docker buildx imagetools inspect --raw docker.io/langchain/langsmith-backend:<tag> \
  | jq -r '.manifests[] | select(.platform.os == "linux") | .digest + "  " + .platform.architecture'

验证其中一个摘要的 SBOM 证明:

cosign verify-attestation \
  --type spdxjson \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-identity-regexp 'https://github\.com/langchain-ai/langchainplus/\.github/workflows/release_self_hosted_on_version_bump\.yaml@refs/heads/v[0-9]+-stable' \
  docker.io/langchain/langsmith-backend@<digest>

成功的验证会给出与镜像签名相同的保证:证明由稳定分支发布工作流生成,其声明记录在 Rekor 透明度日志中。

要提取 SPDX 文档本身,请解码已验证的证明负载:

cosign verify-attestation \
  --type spdxjson \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-identity-regexp 'https://github\.com/langchain-ai/langchainplus/\.github/workflows/release_self_hosted_on_version_bump\.yaml@refs/heads/v[0-9]+-stable' \
  docker.io/langchain/langsmith-backend@<digest> \
  | jq -r '.payload' | base64 -d | jq '.predicate'

解码后的谓词是一个标准 SPDX 2.3 文档,列出了该镜像中的每个软件包。