docs: clarify env var passing in Docker#9742
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughDocumentation 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
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
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
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. Comment |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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
📒 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.
aimurphy
left a comment
There was a problem hiding this comment.
LGTM.
About the duplication, depending how much is duplicated, you could possibly use a partial.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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.envinto the container.Copying
docker.envinto the image increases secret exposure risk and makes revocation/rotation harder. Pass env at runtime via--env-fileor a bind mount instead, and drop--env-filefrom 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_ENVIRONMENTand 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
📒 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.envtruly 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. :::
This comment has been minimized.
This comment has been minimized.
|
|
Build successful! ✅ |
clarify-env-var-passing-in-docker



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