Skip to content

docs: clarify env var passing in Docker#9742

Merged
mendonk merged 4 commits into
mainfrom
docs-lfoss-2071
Sep 17, 2025
Merged

docs: clarify env var passing in Docker#9742
mendonk merged 4 commits into
mainfrom
docs-lfoss-2071

Conversation

@mendonk
Copy link
Copy Markdown
Collaborator

@mendonk mendonk commented Sep 8, 2025

Clarify how Langflow handles environment variables and global variables.
Clarify exposing custom environment variables as global variables.

This introduces some duplicate content between the Global variables page, but at least 1 user reported having an issue with this, so I think it's OK to clarify it in-line here.

Summary by CodeRabbit

  • Documentation
    • Expanded guidance on environment-variable handling and global-variable mapping.
    • Clarified precedence: docker.env values override Dockerfile values.
    • Documented auto-conversion of predefined environment variables into globals.
    • Added mechanism for custom variables via LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT (comma-separated list).
    • Introduced fallback option LANGFLOW_FALLBACK_TO_ENV_VAR=True when globals aren’t available.
    • Included practical examples (e.g., WATSONX_PROJECT_ID, WATSONX_API_KEY) and reorganized configuration blocks for clarity.
    • Retained and repositioned the “Secrets” section following the new guidance.

@mendonk mendonk requested a review from aimurphy September 8, 2025 13:58
@mendonk mendonk self-assigned this Sep 8, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 8, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Documentation updates in develop-application.mdx clarify Langflow’s environment-variable handling: precedence of docker.env over Dockerfile, automatic mapping of predefined env vars to globals, configuration via LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT, and fallback behavior controlled by LANGFLOW_FALLBACK_TO_ENV_VAR. Examples and reorganized code blocks demonstrate these configurations.

Changes

Cohort / File(s) Change Summary
Docs — Env vars to Globals mapping and fallback
docs/docs/Develop/develop-application.mdx
Rewrote environment/global variables section: added precedence rule (docker.env overrides Dockerfile), described automatic and custom env-to-global mapping via LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT, introduced fallback via LANGFLOW_FALLBACK_TO_ENV_VAR, and added explicit examples/config blocks.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as Developer
    participant DF as Dockerfile
    participant ENV as docker.env
    participant RT as Langflow Runtime

    Dev->>DF: Define VAR=... (build-time/default)
    Dev->>ENV: Define VAR=... (runtime override)
    Note over DF,ENV: Both define the same variable
    DF->>RT: Provide VAR (default)
    ENV->>RT: Provide VAR (override)
    Note over RT: Precedence: docker.env value is used
Loading
sequenceDiagram
    autonumber
    participant Node as Component
    participant G as Langflow Globals DB
    participant Map as Env Var Mapper
    participant PEnv as Process Env

    Node->>G: Get value for X
    alt X exists in Globals
        G-->>Node: Return value
    else X missing in Globals
        Node->>Map: Resolve X
        alt X is predefined OR listed in LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT
            Map->>PEnv: Read X
            PEnv-->>Map: Value
            Map->>G: Store X as global
            G-->>Node: Return value
        else Not mapped
            alt LANGFLOW_FALLBACK_TO_ENV_VAR = True
                Node->>PEnv: Read X
                PEnv-->>Node: Value (not stored)
            else Fallback disabled
                Node-->>Node: Value not available
            end
        end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • docs: reference exported key #9245 — Also updates documentation on environment-variable usage (fixes curl example to reference $LANGFLOW_API_KEY), overlapping with env-var handling guidance.

Suggested reviewers

  • jordanrfrazier
  • aimurphy
  • Empreiteiro

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly indicates that this is a documentation change and succinctly describes the principal update—clarifying how environment variables are passed through Docker—using concise, focused language.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly indicates that this is a documentation change and succinctly describes the principal update—clarifying how environment variables are passed through Docker—using concise, focused language.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Sep 8, 2025
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Sep 8, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/docs/Develop/develop-application.mdx (1)

1-4: Add required frontmatter description.

Docs must include at least title and description. Add a concise description.

 ---
 title: Containerize a Langflow application
 slug: /develop-application
+description: Learn how to containerize a Langflow application with Docker, configure environment variables and globals, and package flows for deployment.
 ---
🧹 Nitpick comments (4)
docs/docs/Develop/develop-application.mdx (4)

67-68: Deduplicate and surface precedence with an admonition.

State this once with an admonition; it’s repeated below (Lines 172–174).

-You can set environment variables in the Dockerfile, but if you set an environment variable in both `docker.env` and the Dockerfile, Langflow uses the value set in `docker.env`.
+:::warning
+If an environment variable is set in both `docker.env` and the Dockerfile, Langflow uses the value from `docker.env`.
+:::

Optionally remove Lines 172–174 or replace with “See note above.”

-The environment variables set directly in this Dockerfile specify resource paths for Langflow.
-If these variables are also set in `docker.env`, the values in `docker.env` override the values set in the Dockerfile.
+The environment variables set directly in this Dockerfile specify resource paths for Langflow. See the note above about `docker.env` precedence.

Also applies to: 172-174


69-75: Use an admonition and tighten wording; clarify when mapping happens.

Small style pass and clarify it occurs at startup.

-Langflow automatically converts a [predefined list](/configuration-global-variables#default-environment-variables) of environment variables into global variables.
-
-If your custom environment variables aren't in this predefined list, you need to explicitly include them using the `LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT` environment variable.
-
-This environment variable accepts a comma-separated list of environment variables to get from the environment and store as global variables.
+:::tip
+Langflow automatically converts a [predefined list](/configuration-global-variables#default-environment-variables) of environment variables into Global Variables at startup.
+For custom variables, set `LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT` to a comma‑separated list of env var names to persist as Global Variables.
+:::

75-83: Capitalize domain terms per style guide.

Capitalize Global Variables and Components.

-For example, this configuration creates global variables named `WATSONX_PROJECT_ID` and `WATSONX_API_KEY` in Langflow's database and makes them available for use in components:
+For example, this configuration creates Global Variables named `WATSONX_PROJECT_ID` and `WATSONX_API_KEY` in Langflow's database and makes them available for use in Components:

85-96: Clarify fallback precedence and present it as a tip.

Make precedence explicit; keep terminology consistent.

-Alternatively, set `LANGFLOW_FALLBACK_TO_ENV_VAR=True` to allow global variables set in Langflow Settings to use an environment variable with the same name if Langflow can't retrieve the variable value from the global variables.
+:::tip
+Set `LANGFLOW_FALLBACK_TO_ENV_VAR=True` to allow Global Variables to fall back to an environment variable with the same name when the Global Variable is missing.
+Precedence: Global Variable (if present) > environment variable (fallback).
+:::
-For example, in this configuration, when a component references the global variables `WATSONX_PROJECT_ID` or `WATSONX_API_KEY` that don't exist in Langflow's database, Langflow will automatically use the corresponding environment variable value as a fallback.
+For example, when a Component references `WATSONX_PROJECT_ID` or `WATSONX_API_KEY` that do not exist in Langflow's database, Langflow uses the corresponding environment variable value as a fallback.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1d5a80 and 58c430f.

📒 Files selected for processing (1)
  • docs/docs/Develop/develop-application.mdx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs/docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (.cursor/rules/docs_development.mdc)

docs/docs/**/*.{md,mdx}: All documentation content must be written in Markdown or MDX files located under docs/docs/, following the prescribed directory structure for guides, reference, how-to, concepts, and API documentation.
All documentation Markdown and MDX files must begin with a frontmatter block including at least title and description fields.
Use admonitions (:::tip, :::warning, :::danger) in Markdown/MDX files to highlight important information, warnings, or critical issues.
All images referenced in documentation must include descriptive alt text for accessibility.
All code examples included in documentation must be tested and verified to work as shown.
Internal links in documentation must be functional and not broken.
Content must follow the style guide: professional but approachable tone, second person voice, present tense, short paragraphs, sentence case headers, inline code with backticks, bold for UI elements, italic for emphasis, and parallel structure in lists.
Use consistent terminology: always capitalize Langflow, Component, Flow, and uppercase API and JSON.

Files:

  • docs/docs/Develop/develop-application.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test Docs Build / Test Docs Build
  • GitHub Check: build-and-deploy
🔇 Additional comments (1)
docs/docs/Develop/develop-application.mdx (1)

97-98: Internal links and “Default environment variables” anchor verified—no changes needed.

Copy link
Copy Markdown
Collaborator

@aimurphy aimurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

About the duplication, depending how much is duplicated, you could possibly use a partial.

@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Sep 8, 2025
@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Sep 10, 2025
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/docs/Develop/develop-application.mdx (2)

149-153: Don’t bake secrets into the image; avoid copying .env into the container.

Copying docker.env into the image increases secret exposure risk and makes revocation/rotation harder. Pass env at runtime via --env-file or a bind mount instead, and drop --env-file from the CMD if using Docker’s envs.

Apply this diff to the Dockerfile example:

 # Copy flows, langflow-config-dir, and docker.env to the container
 COPY flows /app/flows
 COPY langflow-config-dir /app/langflow-config-dir
-COPY docker.env /app/.env
+# Do not copy .env into the image; pass env at runtime (see "Test your Langflow Docker image" below)

@@
-# Command to run the Langflow server on port 7860
 EXPOSE 7860
-CMD ["langflow", "run", "--backend-only", "--env-file","/app/.env","--host", "0.0.0.0", "--port", "7860"]
+CMD ["langflow", "run", "--backend-only", "--host", "0.0.0.0", "--port", "7860"]

Follow-ups:

  • Update the run command below to use --env-file ./docker.env (see next comment).
  • If you keep the current approach, add a prominent danger admonition in the Environment variables section warning against embedding secrets in images.

Also applies to: 167-170


201-203: Pass env at runtime in the run example.

Show best practice by supplying the env file at container start instead of baking it into the image.

-docker run -p 7860:7860 langflow-pokedex:1.2.0
+docker run --env-file ./docker.env -p 7860:7860 langflow-pokedex:1.2.0
+# or, bind-mount a .env file the app can read:
+# docker run -v "$PWD/docker.env:/app/.env:ro" -p 7860:7860 langflow-pokedex:1.2.0
🧹 Nitpick comments (4)
docs/docs/Develop/develop-application.mdx (4)

69-83: Confirm variable names and add a brief “what happens” note.

  • Please double-check the exact names/semantics of LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT and the “predefined list” behavior to avoid divergence from code.
  • Add a one‑line note that these globals are persisted to the Langflow database at startup.

Proposed tweak:

- Langflow automatically converts a [predefined list](/configuration-global-variables#default-environment-variables) of environment variables into global variables.
+ Langflow automatically converts a [predefined list](/configuration-global-variables#default-environment-variables) of environment variables into Global Variables (persisted in the Langflow database).

Also, per the style guide, capitalize core terms:

- ... available for use in components:
+ ... available for use in Components:

85-95: Add a security warning for fallback behavior.

Falling back to environment variables can mask misconfiguration and may unintentionally expose secrets when a Global Variable is missing.

Add this admonition under the paragraph:

:::warning
`LANGFLOW_FALLBACK_TO_ENV_VAR=True` can hide missing Global Variables and may lead to unintended secret usage. Prefer explicit Global Variables in production and monitor for missing keys.
:::

31-35: Align description with the updated Dockerfile guidance.

If you adopt the “don’t copy .env” change, this bullet should say the file is used to provide runtime env vars (not copied into the image).

-* [`docker.env`](#docker-env): This file is copied to the Docker image as a `.env` file in the container root.
+* [`docker.env`](#docker-env): This file provides runtime environment variables (passed with `--env-file` or mounted as `/app/.env`).

54-66: Add a “secrets in images” admonition.

Reinforce safe handling of secrets right where env usage is introduced.

:::danger
Avoid copying `.env` files into images. Pass secrets at runtime (`docker run --env-file ./docker.env`) or use a secrets manager (Docker/Kubernetes Secrets). Rotate credentials regularly.
:::
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4144d76 and 2c1c92a.

📒 Files selected for processing (1)
  • docs/docs/Develop/develop-application.mdx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
docs/docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (.cursor/rules/docs_development.mdc)

docs/docs/**/*.{md,mdx}: All documentation content must be written in Markdown or MDX files located under docs/docs/, following the prescribed directory structure for guides, reference, how-to, concepts, and API documentation.
All documentation Markdown and MDX files must begin with a frontmatter block including at least title and description fields.
Use admonitions (:::tip, :::warning, :::danger) in Markdown/MDX files to highlight important information, warnings, or critical issues.
All images referenced in documentation must include descriptive alt text for accessibility.
All code examples included in documentation must be tested and verified to work as shown.
Internal links in documentation must be functional and not broken.
Content must follow the style guide: professional but approachable tone, second person voice, present tense, short paragraphs, sentence case headers, inline code with backticks, bold for UI elements, italic for emphasis, and parallel structure in lists.
Use consistent terminology: always capitalize Langflow, Component, Flow, and uppercase API and JSON.

Files:

  • docs/docs/Develop/develop-application.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test Docs Build / Test Docs Build
  • GitHub Check: build-and-deploy
🔇 Additional comments (1)
docs/docs/Develop/develop-application.mdx (1)

67-67: Verify env precedence claim (docker.env vs Dockerfile).

This depends on how Langflow loads the env file (e.g., python-dotenv override behavior) vs Docker’s runtime env. Please confirm the CLI loads the env file with override semantics so values from docker.env truly win at runtime.

Add a short admonition making precedence explicit:

:::tip
If a variable is defined in both the Dockerfile and `docker.env`, the value from `docker.env` takes precedence at runtime.
:::

Comment thread docs/docs/Develop/develop-application.mdx
@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Sep 12, 2025
@github-actions

This comment has been minimized.

Comment thread docs/docs/Develop/develop-application.mdx
Comment thread docs/docs/Develop/develop-application.mdx
@sonarqubecloud
Copy link
Copy Markdown

@github-actions github-actions Bot added documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Sep 17, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 17, 2025

Build successful! ✅
Deploying docs draft.
Deploy successful! View draft

@mendonk mendonk added this pull request to the merge queue Sep 17, 2025
@mendonk mendonk removed this pull request from the merge queue due to a manual request Sep 17, 2025
@mendonk mendonk added this pull request to the merge queue Sep 17, 2025
Merged via the queue into main with commit 05c314e Sep 17, 2025
16 checks passed
@mendonk mendonk deleted the docs-lfoss-2071 branch September 17, 2025 14:12
lucaseduoli pushed a commit that referenced this pull request Sep 17, 2025
clarify-env-var-passing-in-docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants