Containerize a Langflow application
Podman can be used instead of Docker for all commands shown here. For more information, see the Podman documentation.
Designing flows in the visual editor is only the first step in building an application that uses Langflow.
Once you have a functional flow, you can use that flow in a larger application, such as a website or mobile app. Because Langflow is both an IDE and a runtime, you can use Langflow to build and test your flows locally, and then package and serve your flows in a production environment.
This guide introduces application development with Langflow from initial setup through packaging and deployment. This documentation doesn't explain how to write a complete application; it only describes how to include Langflow in the context of a larger application.
Directory structure
The following example describes the directory structure for a minimal Langflow application:
_10LANGFLOW-APPLICATION/_10├── docker.env_10├── Dockerfile_10├── flows/_10│ ├── flow1.json_10│ └── flow2.json_10├── langflow-config-dir/_10├── README.md
This directory contains the following:
docker.env: This file is copied to the Docker image as a.envfile in the container root.Dockerfile: This file controls how your Langflow image is built./flows: This folder holds the flows you want to host, which are the flows that your application uses./langflow-config-dir: This folder is referenced in the Dockerfile as the location for your Langflow deployment's configuration files, database, and logs.README.md: This is a typical README file for your application's documentation.
This is a minimal example of a Langflow application directory.
Your application might have additional files and folders, such as a /components folder for custom components, or a pyproject.toml file for additional dependencies.
Package management
The base Langflow Docker image includes the Langflow core dependencies because it uses langflowai/langflow:latest as the parent image.
If your application requires additional dependencies, create a pyproject.toml file for the additional dependencies.
For more information, see Install custom dependencies.
To deploy an application with additional dependencies to Docker, you must copy the pyproject.toml and uv.lock files to the Docker image.
To do this, add the following to your Langflow application's Dockerfile:
_10COPY pyproject.toml uv.lock /app/
Environment variables
The docker.env file is a .env file loaded into your Docker image.
It contains Langflow environment variables that are used in flows or control Langflow's behavior, such as authentication, database storage, API keys, and server configurations.
For example:
_10LANGFLOW_AUTO_LOGIN=True_10LANGFLOW_SAVE_DB_IN_CONFIG_DIR=True_10LANGFLOW_BASE_URL=http://0.0.0.0:7860_10OPENAI_API_KEY=sk-...
You can set environment variables in the Dockerfile as well.
However, if you set an environment variable in both docker.env and the Dockerfile, Langflow uses the value set in docker.env.
Langflow can also create global variables from your environment variables, or use environment variables as a backup for missing global variables.