I'm having issues setting up langflow through docker-compose
I'm trying to deploy langflow on ubuntu staging server through docker-compose
every other services starts successful except - backend, celeryworker and flower as shown in the below screenshot.
With error message - /usr/local/bin/python: No module named langflow
when i access the frontend through the browser, i only see the loading image and javascript error as shown on the below screenshot
To resolve the issues with the backend, celeryworker, and flower services not starting due to a missing langflow module, and the frontend showing a loading image with a JavaScript error, follow these steps:
-
Ensure
langflowModule is Installed: Make sure thelangflowmodule is installed in the Docker image used by thebackend,celeryworker, andflowerservices. Add the installation command in the Dockerfile or the startup script. -
Check Dockerfile and Startup Script: Verify that the Dockerfile or the startup script used in the
backend,celeryworker, andflowerservices includes the installation of thelangflowmodule. -
Update
docker-compose.yml: Ensure that thedocker-compose.ymlfile correctly references the Docker images and paths. Here is an example configuration:
version: "3.8"
services:
backend: &backend
image: "ogabrielluiz/langflow:latest"
build:
context: ../
dockerfile: base.Dockerfile
depends_on:
- db
- broker
- result_backend
env_file:
- .env
volumes:
- ../:/app
- ./startup-backend.sh:/startup-backend.sh
command: /startup-backend.sh
healthcheck:
test: "exit 0"
deploy:
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=PathPrefix(`/api/v1`) || PathPrefix(`/docs`) || PathPrefix(`/health`)
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=7860
celeryworker:
<<: *backend
env_file:
- .env
build:
context: ../
dockerfile: base.Dockerfile
command: celery -A langflow.worker.celery_app worker --loglevel=DEBUG --concurrency=1 -n lf-worker@%h
healthcheck:
test: "exit 0"
deploy:
replicas: 1
flower:
<<: *backend
env_file:
- .env
networks:
- default
build:
context: ../
dockerfile: base.Dockerfile
environment:
- FLOWER_PORT=5555
command: /bin/sh -c "celery -A langflow.worker.celery_app --broker=${BROKER_URL?Variable not set} flower --port=5555"
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.rule=Host(`flower.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.entrypoints=http
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.middlewares=${STACK_NAME?Variable not set}-https-redirect
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.rule=Host(`flower.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.entrypoints=https
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.tls=true
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.tls.certresolver=le
- traefik.http.services.${STACK_NAME?Variable not set}-flower.loadbalancer.server.port=5555
frontend:
image: "ogabrielluiz/langflow_frontend:latest"
env_file:
- .env
build:
context: ../src/frontend
dockerfile: Dockerfile
args:
- BACKEND_URL=http://backend:7860
restart: on-failure
deploy:
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=PathPrefix(`/`)
- traefik.http.services.${STACK_NAME?Variable not set}-frontend.loadbalancer.server.port=80
-
Frontend JavaScript Error: Ensure that the
BACKEND_URLis correctly set in the frontend service. The errorSyntaxError: Unexpected token '<'usually indicates that the frontend is trying to load an HTML page instead of a JavaScript file, often due to an incorrect backend URL. -
Common Installation Issues: If you encounter the error
No module named 'langflow.__main__', try the following steps:- Run
python -m langflow runinstead oflangflow run. - Reinstall Langflow with
python -m pip install langflow --pre -U. - Reinstall Langflow and its dependencies with
python -m pip install langflow --pre -U --force-reinstall.
If you encounter the error
Something went wrong running migrations. Please, run 'langflow migration --fix', clear the cache by deleting the contents of the cache folder located at:- Linux or WSL2 on Windows:
home/<username>/.cache/langflow/ - MacOS:
/Users/<username>/Library/Caches/langflow/
This error can occur during Langflow upgrades when the new version can't override
langflow-pre.dbin.cache/langflow/. Clearing the cache removes this file but will also erase your settings. Back up your files before clearing the folder if you wish to retain them [1][2][3][4][5]. - Run
To continue talking to Dosu, mention @dosu.
@dosu, the docker-compose you got your suggestion from was last updated 9months ago, meaning that it doesn't reflect the current way of deploy langflow with docker.
I've tried your suggestions they didn't work.
To deploy Langflow correctly using Docker Compose, you can use the following updated docker-compose.yml configuration:
version: "3.8"
services:
proxy:
image: traefik:v3.0
env_file:
- .env
networks:
- ${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- default
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command:
- --providers.docker
- --providers.docker.constraints=Label(`traefik.constraint-label-stack`, `${TRAEFIK_TAG?Variable not set}`)
- --providers.docker.exposedbydefault=false
- --accesslog
- --log
- --api
deploy:
placement:
constraints:
- node.role == manager
labels:
- traefik.enable=true
- traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
- traefik.http.middlewares.${STACK_NAME?Variable not set}-https-redirect.redirectscheme.scheme=https
- traefik.http.middlewares.${STACK_NAME?Variable not set}-https-redirect.redirectscheme.permanent=true
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.entrypoints=http
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.entrypoints=https
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.tls=true
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.tls.certresolver=le
- traefik.http.services.${STACK_NAME?Variable not set}-proxy.loadbalancer.server.port=80
- traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.regex=^https?://(www.)?(${DOMAIN?Variable not set})/(.*)
- traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.replacement=https://${DOMAIN?Variable not set}/$${3}
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.middlewares=${STACK_NAME?Variable not set}-www-redirect
- traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.middlewares=${STACK_NAME?Variable not set}-www-redirect,${STACK_NAME?Variable not set}-https-redirect
backend:
image: "langflowai/langflow:latest"
depends_on:
- db
- broker
- result_backend
env_file:
- .env
volumes:
- ../:/app
- ./startup-backend.sh:/startup-backend.sh
command: /startup-backend.sh
healthcheck:
test: "exit 0"
deploy:
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=PathPrefix(`/api/v1`) || PathPrefix(`/docs`) || PathPrefix(`/health`)
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=7860
db:
image: postgres:15.4
volumes:
- app-db-data:/var/lib/postgresql/data/pgdata
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
deploy:
placement:
constraints:
- node.labels.app-db-data == true
healthcheck:
test: "exit 0"
env_file:
- .env
pgadmin:
image: dpage/pgadmin4
networks:
- ${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- default
volumes:
- pgadmin-data:/var/lib/pgadmin
env_file:
- .env
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-pgadmin-http.rule=Host(`pgadmin.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-pgadmin-http.entrypoints=http
- traefik.http.routers.${STACK_NAME?Variable not set}-pgadmin-http.middlewares=${STACK_NAME?Variable not set}-https-redirect
- traefik.http.routers.${STACK_NAME?Variable not set}-pgadmin-https.rule=Host(`pgadmin.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-pgadmin-https.entrypoints=https
- traefik.http.routers.${STACK_NAME?Variable not set}-pgadmin-https.tls=true
- traefik.http.routers.${STACK_NAME?Variable not set}-pgadmin-https.tls.certresolver=le
- traefik.http.services.${STACK_NAME?Variable not set}-pgadmin.loadbalancer.server.port=5050
result_backend:
image: redis:6.2.5
env_file:
- .env
ports:
- 6379:6379
healthcheck:
test: "exit 0"
celeryworker:
image: "langflowai/langflow:latest"
env_file:
- .env
command: celery -A langflow.worker.celery_app worker --loglevel=INFO --concurrency=1 -n lf-worker@%h -P eventlet
healthcheck:
test: "exit 0"
deploy:
replicas: 1
flower:
image: "langflowai/langflow:latest"
env_file:
- .env
networks:
- default
environment:
- FLOWER_PORT=5555
command: /bin/sh -c "celery -A langflow.worker.celery_app --broker=${BROKER_URL?Variable not set} flower --port=5555"
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.rule=Host(`flower.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.entrypoints=http
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.middlewares=${STACK_NAME?Variable not set}-https-redirect
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.rule=Host(`flower.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.entrypoints=https
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.tls=true
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.tls.certresolver=le
- traefik.http.services.${STACK_NAME?Variable not set}-flower.loadbalancer.server.port=5555
frontend:
image: "ogabrielluiz/langflow_frontend:latest"
env_file:
- .env
build:
context: ../src/frontend
dockerfile: Dockerfile
args:
- BACKEND_URL=http://backend:7860
restart: on-failure
deploy:
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=PathPrefix(`/`)
- traefik.http.services.${STACK_NAME?Variable not set}-frontend.loadbalancer.server.port=80
broker:
image: rabbitmq:3-management
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER:-admin}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS:-admin}
volumes:
- rabbitmq_data:/etc/rabbitmq/
- rabbitmq_data:/var/lib/rabbitmq/
- rabbitmq_log:/var/log/rabbitmq/
ports:
- 5672:5672
- 15672:15672
prometheus:
image: prom/prometheus:v2.37.9
env_file:
- .env
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command:
- "--config.file=/etc/prometheus/prometheus.yml"
healthcheck:
test: "exit 0"
deploy:
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-prometheus-http.rule=PathPrefix(`/metrics`)
- traefik.http.services.${STACK_NAME?Variable not set}-prometheus.loadbalancer.server.port=9090
grafana:
image: grafana/grafana:8.2.6
env_file:
- .env
volumes:
- grafana_data:/var/lib/grafana
deploy:
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-grafana-http.rule=PathPrefix(`/grafana`)
- traefik.http.services.${STACK_NAME?Variable not set}-grafana.loadbalancer.server.port=3000
volumes:
grafana_data:
app-db-data:
rabbitmq_data:
rabbitmq_log:
pgadmin-data:
networks:
traefik-public:
external: false
To deploy Langflow:
-
Clone the LangFlow repository:
git clone https://github.com/langflow-ai/langflow.git -
Navigate to the
docker_exampledirectory:cd langflow/docker_example -
Run the Docker Compose file:
docker compose up
LangFlow will now be accessible at http://localhost:7860/ [1][2].
To continue talking to Dosu, mention @dosu.
@Dosu, for celeryworker and flower services am now getting the below errors:
/app/.venv/lib/python3.12/site-packages/langchain/agents/json_chat/base.py:22: SyntaxWarning: invalid escape sequence '\ ' """Create an agent that uses JSON to format its logic, build for Chat Models.
Usage: python -m langflow run [OPTIONS] Try 'python -m langflow run --help' for help.
No such option: --upgrade
The errors you're encountering suggest a couple of issues with the celeryworker and flower services. Let's address them step-by-step:
-
SyntaxWarning: invalid escape sequence: This warning is related to the
langchainlibrary and is not critical. However, it can be fixed by ensuring that the string literals in thebase.pyfile use raw strings (prefixing withr) or by escaping the backslashes properly. -
No such option: --upgrade: This error indicates that the
--upgradeoption is not recognized by thelangflowcommand. It seems like there might be a misconfiguration in the command being run.
Steps to Resolve:
-
Update Dockerfile and Startup Script: Ensure that the Dockerfile and startup script for the
backend,celeryworker, andflowerservices are correctly set up to install and runlangflowwithout the--upgradeoption. -
Correct Docker Compose Configuration: Verify that the
docker-compose.ymlfile does not include the--upgradeoption in the command for thebackend,celeryworker, andflowerservices.
Here is an updated example configuration for the docker-compose.yml:
version: "3.8"
services:
backend:
image: "langflowai/langflow:latest"
depends_on:
- db
- broker
- result_backend
env_file:
- .env
volumes:
- ../:/app
- ./startup-backend.sh:/startup-backend.sh
command: /startup-backend.sh
healthcheck:
test: "exit 0"
deploy:
labels:
- traefik.enable=true
- traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=PathPrefix(`/api/v1`) || PathPrefix(`/docs`) || PathPrefix(`/health`)
- traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=7860
celeryworker:
image: "langflowai/langflow:latest"
env_file:
- .env
command: celery -A langflow.worker.celery_app worker --loglevel=INFO --concurrency=1 -n lf-worker@%h -P eventlet
healthcheck:
test: "exit 0"
deploy:
replicas: 1
flower:
image: "langflowai/langflow:latest"
env_file:
- .env
networks:
- default
environment:
- FLOWER_PORT=5555
command: /bin/sh -c "celery -A langflow.worker.celery_app --broker=${BROKER_URL?Variable not set} flower --port=5555"
deploy:
labels:
- traefik.enable=true
- traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
- traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.rule=Host(`flower.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.entrypoints=http
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.middlewares=${STACK_NAME?Variable not set}-https-redirect
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.rule=Host(`flower.${DOMAIN?Variable not set}`)
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.entrypoints=https
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.tls=true
- traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.tls.certresolver=le
- traefik.http.services.${STACK_NAME?Variable not set}-flower.loadbalancer.server.port=5555
-
Ensure Correct Environment Variables: Make sure the
.envfile includes the necessary environment variables forceleryworkerandflowerservices:BROKER_URL=amqp://admin:admin@broker:5672// FLOWER_PORT=5555 -
Verify Installation of
langflow: Ensure that thelangflowmodule is correctly installed in the Docker image. You can add the installation command in the Dockerfile if it's not already included:RUN pip install langflow
By following these steps, you should be able to resolve the issues with the celeryworker and flower services. If the problem persists, please provide more details or logs for further assistance.
To continue talking to Dosu, mention @dosu.
Please can someone in the core team update the docker-compose.yml in deploy folder as it was last updated 2months? which definitely doesn't conform to current version 1 deployment requirements. @ogabrielluiz
@chibexme this is going to be fixed in 1.0.6. The current issue is "latest" image doesn't point to 1.x release. Plus, there's a problem with the endpoint that has been already fixed in the main branch but not released yet
cc @ogabrielluiz
@chibexme this is going to be fixed in 1.0.6. The current issue is "latest" image doesn't point to 1.x release. Plus, there's a problem with the endpoint that has been already fixed in the main branch but not released yet
cc @ogabrielluiz
Alright, will be waiting for the 1.0.6 release.
Thanks.
@ogabrielluiz I can see that version 1.0.6 has been release with many bug fixed, that's impressive.
Regard my concern about docker-compose.yml file in the deploy folder, it still has not been updated as can be seen in the screenshot below
I checked the docker image the frontend is point to, it was updated 9months ago
Kindly point me to the right working docker-compose file to deploy langflow from.
Expecting your speedy response.
Fixed by https://github.com/langflow-ai/langflow/pull/2654