OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
feat: added external ports for every service, tweaked development makefile (#1986)
Lucas Oliveira4f104ec2d235
diff --git a/.env.example b/.env.exampleindex 6917262d0..43ba712ca 100644--- a/.env.example+++ b/.env.example@@ -53,6 +53,14 @@ LANGFLOW_URL_INGEST_FLOW_ID=72c3d17c-2dac-4a73-b48a-6518473d7830# LANGFLOW_INGEST_FLOW_ID=1402618b-e6d1-4ff2-9a11-d6ce71186915NUDGES_FLOW_ID=ebc01d31-1976-46ce-a385-b0240327226c+# Backend bind port for local `make backend`.+OPENRAG_BACKEND_PORT=8000++# URL Docker-hosted services use to call the backend in host-backend mode.+# If unset, auto-derived from OPENRAG_BACKEND_PORT. Only set this explicitly+# if you need to override the auto-derived value (e.g., custom hostname).+# OPENRAG_BACKEND_INTERNAL_URL=http://openrag-backend:8000+# --- Backend ingestion-callback proxy router --------------------------------# When enabled, a tiny standalone uvicorn app is started in the same process as# the backend (its own port) that proxies ONLY the Langflow ingest callback@@ -107,11 +115,10 @@ LANGFLOW_DATA_PATH=./langflow-dataLANGFLOW_DATABASE_URL=sqlite:////app/langflow-data/langflow.db# OpenSearch Connection-OPENSEARCH_HOST=opensearch-OPENSEARCH_PORT=9200-# Optional: Use a different OpenSearch endpoint for Langflow-# LANGFLOW_OPENSEARCH_HOST=opensearch-# LANGFLOW_OPENSEARCH_PORT=9200+# OPENSEARCH_HOST=opensearch+# OPENSEARCH_PORT=9200+# OPENSEARCH_DASHBOARDS_PORT=5601+# OPENSEARCH_PERF_PORT=9600OPENSEARCH_USERNAME=admin# Disable the OpenSearch node-count readiness gate for single-node local setups.OPENSEARCH_NODE_COUNT_CHECK_ENABLED=false@@ -263,9 +270,6 @@ LANGFLOW_ENABLE_SUPERUSER_CLI=False# Langflow Container Variables# These variables are passed directly to the Langflow container by docker-compose.# They are NOT read by the OpenRAG Python backend.-#-# Note: OPENSEARCH_URL is automatically constructed by docker-compose from-# LANGFLOW_OPENSEARCH_HOST and LANGFLOW_OPENSEARCH_PORT — do not set it manually.# ─────────────────────────────────────────────────────────────────────────────# Langfuse tracing (optional)@@ -281,6 +285,7 @@ LANGFUSE_HOST=# - e.g. 9.46.110.49,10.21.103.227,openrag.example.comNEXT_ALLOWED_DEV_ORIGINS=+# OPTIONAL: Number of worker processes for concurrent request handling# - Increase for higher throughput; but, factor in CPU / memory constraints# MAX_WORKERS=4 # Backend ingestion workers (default: min(4, CPU_COUNT // 2))@@ -307,6 +312,9 @@ NEXT_ALLOWED_DEV_ORIGINS=# but can be pinned here to lock the deployment to a specific version when running OpenRAG with Make commands.OPENRAG_VERSION=latest+# Docker Compose project name. Change this to run multiple instances of OpenRAG alongside each other.+COMPOSE_PROJECT_NAME=openrag+# Path configuration (override defaults for custom directory layouts)# OPENRAG_DATA_PATH=./data# OPENRAG_KEYS_PATH=./keysdiff --git a/Dockerfile b/Dockerfileindex 6b8e18154..9ed3ff2b8 100644--- a/Dockerfile+++ b/Dockerfile@@ -109,6 +109,8 @@ RUN echo '#!/bin/bash' > /usr/share/opensearch/setup-security.sh && \echo 'if [ -z "$HASH" ]; then echo "[ERROR] Failed to generate admin hash"; exit 1; fi' >> /usr/share/opensearch/setup-security.sh && \echo 'sed -i "s|^ hash: \".*\"| hash: \"$HASH\"|" /usr/share/opensearch/securityconfig/internal_users.yml' >> /usr/share/opensearch/setup-security.sh && \echo 'echo "Updated internal_users.yml with runtime-generated admin hash"' >> /usr/share/opensearch/setup-security.sh && \+ echo 'BACKEND_URL=${OPENRAG_BACKEND_INTERNAL_URL:-http://${OPENRAG_BACKEND_HOST:-openrag-backend}:${OPENRAG_BACKEND_PORT:-8000}}' >> /usr/share/opensearch/setup-security.sh && \+ echo 'sed -i "s|http://openrag-backend:8000|$BACKEND_URL|g" /usr/share/opensearch/securityconfig/config.yml /usr/share/opensearch/cloud_securityconfig/config.yml' >> /usr/share/opensearch/setup-security.sh && \echo 'echo "Applying OIDC and DLS security configuration..."' >> /usr/share/opensearch/setup-security.sh && \echo '/usr/share/opensearch/plugins/opensearch-security/tools/securityadmin.sh \' >> /usr/share/opensearch/setup-security.sh && \echo ' -cd /usr/share/opensearch/securityconfig \' >> /usr/share/opensearch/setup-security.sh && \diff --git a/Makefile b/Makefileindex 2eca35150..6aaf8f94b 100644--- a/Makefile+++ b/Makefile@@ -25,11 +25,13 @@ CONTAINER_RUNTIME := $(shell command -v docker >/dev/null 2>&1 && echo "docker"HOST_UID := $(shell id -u)HOST_GID := $(shell id -g)OPENRAG_IMAGE_REPOS := langflowai/openrag-backend langflowai/openrag-frontend langflowai/openrag-langflow langflowai/openrag-opensearch langflowai/openrag-dashboards langflow/langflow opensearchproject/opensearch opensearchproject/opensearch-dashboards+COMPOSE_PROJECT_NAME ?= openrag+# Only pass --env-file if the file actually existsifneq (,$(wildcard $(ENV_FILE)))- COMPOSE_CMD := $(CONTAINER_RUNTIME) compose --env-file $(ENV_FILE)+ COMPOSE_CMD := $(CONTAINER_RUNTIME) compose --env-file $(ENV_FILE) -p $(COMPOSE_PROJECT_NAME)else- COMPOSE_CMD := $(CONTAINER_RUNTIME) compose+ COMPOSE_CMD := $(CONTAINER_RUNTIME) compose -p $(COMPOSE_PROJECT_NAME)endif######################@@ -165,6 +167,8 @@ help: ## Show main help with common commands@echo " $(PURPLE)make setup$(NC) - Initialize project (install dependencies, create .env)"@echo " $(PURPLE)make dev$(NC) - Start full stack with GPU support"@echo " $(PURPLE)make dev-cpu$(NC) - Start full stack with CPU only"+ @echo " $(PURPLE)make dev-build$(NC) - Build all images and start full stack with GPU support"+ @echo " $(PURPLE)make dev-build-cpu$(NC) - Build all images and start full stack with CPU only"@echo " $(PURPLE)make stop$(NC) - Stop and remove all OpenRAG containers"@echo ''@echo "$(PURPLE)Common Commands:$(NC)"@@ -249,14 +253,14 @@ help_dev: ## Show development environment commands@echo "$(PURPLE)Full Stack Development:$(NC)"@echo " $(PURPLE)make dev$(NC) - Start full stack with GPU support ($(COMPOSE_CMD))"@echo " $(PURPLE)make dev-cpu$(NC) - Start full stack with CPU only"+ @echo " $(PURPLE)make dev-build$(NC) - Build all images and start full stack with GPU support"+ @echo " $(PURPLE)make dev-build-cpu$(NC) - Build all images and start full stack with CPU only"@echo " $(PURPLE)make stop$(NC) - Stop and remove all OpenRAG containers"@echo " $(PURPLE)make restart$(NC) - Restart all containers"@echo ''@echo "$(PURPLE)Infrastructure Only:$(NC)"- @echo " $(PURPLE)make dev-local$(NC) - Start infrastructure only (for local backend/frontend)"- @echo " $(PURPLE)make dev-local-cpu$(NC) - Start infrastructure for local backend/frontend with CPU only"- @echo " $(PURPLE)make dev-local-build-lf$(NC) - Start infrastructure, building only Langflow image"- @echo " $(PURPLE)make dev-local-build-lf-cpu$(NC) - Same as above, with CPU only"+ @echo " $(PURPLE)make dev-local$(NC) - Start infrastructure only (for local backend/frontend) and build OpenSearch and Langflow images"+ @echo " $(PURPLE)make dev-local-cpu$(NC) - Start infrastructure for local backend/frontend with CPU only and build OpenSearch and Langflow images"@echo ''@echo "$(PURPLE)Branch Development (build Langflow from source):$(NC)"@echo " $(PURPLE)make dev-branch$(NC) - Build & run with custom Langflow branch"@@ -388,6 +392,7 @@ help_utils: ## Show utility commands@echo " $(PURPLE)make clean$(NC) - Stop containers and remove volumes"@echo " $(PURPLE)make clean-dev$(NC) - Clean dev environment"@echo " $(PURPLE)make factory-reset$(NC) - Complete reset (stop, remove volumes, clear data)"+ @echo " $(PURPLE)make factory-reset-clean-build$(NC) - Complete reset including removing images"@echo ''@echo "$(PURPLE)Flows:$(NC)"@echo " $(PURPLE)make flow-upload$(NC) - Upload flow to Langflow"@@ -414,66 +419,66 @@ dev: ensure-langflow-data ensure-backend-volumes ## Start full stack with GPU su$(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml up -d@echo "$(PURPLE)Services started!$(NC)"@echo " $(CYAN)Backend:$(NC) http://openrag-backend"- @echo " $(CYAN)Frontend:$(NC) http://localhost:3000"- @echo " $(CYAN)Langflow:$(NC) http://localhost:7860"- @echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"- @echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"+ @echo " $(CYAN)Frontend:$(NC) http://localhost:$${FRONTEND_PORT:-3000}"+ @echo " $(CYAN)Langflow:$(NC) http://localhost:$${LANGFLOW_PORT:-7860}"+ @echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"+ @echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"dev-cpu: ensure-langflow-data ensure-backend-volumes ## Start full stack with CPU only@echo "$(YELLOW)Starting OpenRAG with CPU only...$(NC)"$(COMPOSE_CMD) up -d@echo "$(PURPLE)Services started!$(NC)"@echo " $(CYAN)Backend:$(NC) http://openrag-backend"- @echo " $(CYAN)Frontend:$(NC) http://localhost:3000"- @echo " $(CYAN)Langflow:$(NC) http://localhost:7860"- @echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"- @echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"--dev-local: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development- @echo "$(YELLOW)Starting infrastructure only (for local development)...$(NC)"- $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml -f docker-compose.host-backend.yml up -d opensearch openrag-backend dashboards langflow- @echo "$(PURPLE)Infrastructure started!$(NC)"+ @echo " $(CYAN)Frontend:$(NC) http://localhost:$${FRONTEND_PORT:-3000}"+ @echo " $(CYAN)Langflow:$(NC) http://localhost:$${LANGFLOW_PORT:-7860}"+ @echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"+ @echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"++dev-build: ensure-langflow-data ensure-backend-volumes ## Start full stack with GPU support, building all images first+ @echo "$(YELLOW)Building all OpenRAG images...$(NC)"+ $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml build+ @echo "$(YELLOW)Starting OpenRAG with GPU support...$(NC)"+ $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml up -d+ @echo "$(PURPLE)Services started!$(NC)"@echo " $(CYAN)Backend:$(NC) http://openrag-backend"- @echo " $(CYAN)Langflow:$(NC) http://localhost:7860"- @echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"- @echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"- @echo ""- @echo "$(YELLOW)Now run 'make backend' and 'make frontend' in separate terminals$(NC)"--dev-local-cpu: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development, with CPU only- @echo "$(YELLOW)Starting infrastructure only (for local development)...$(NC)"- $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.host-backend.yml up -d opensearch openrag-backend dashboards langflow- @echo "$(PURPLE)Infrastructure started!$(NC)"+ @echo " $(CYAN)Frontend:$(NC) http://localhost:$${FRONTEND_PORT:-3000}"+ @echo " $(CYAN)Langflow:$(NC) http://localhost:$${LANGFLOW_PORT:-7860}"+ @echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"+ @echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"++dev-build-cpu: ensure-langflow-data ensure-backend-volumes ## Start full stack with CPU only, building all images first+ @echo "$(YELLOW)Building all OpenRAG images (CPU)...$(NC)"+ $(COMPOSE_CMD) build+ @echo "$(YELLOW)Starting OpenRAG with CPU only...$(NC)"+ $(COMPOSE_CMD) up -d+ @echo "$(PURPLE)Services started!$(NC)"@echo " $(CYAN)Backend:$(NC) http://openrag-backend"- @echo " $(CYAN)Langflow:$(NC) http://localhost:7860"- @echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"- @echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"- @echo ""- @echo "$(YELLOW)Now run 'make backend' and 'make frontend' in separate terminals$(NC)"+ @echo " $(CYAN)Frontend:$(NC) http://localhost:$${FRONTEND_PORT:-3000}"+ @echo " $(CYAN)Langflow:$(NC) http://localhost:$${LANGFLOW_PORT:-7860}"+ @echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"+ @echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"-dev-local-build-lf: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development, building only Langflow image- @echo "$(YELLOW)Building Langflow image...$(NC)"- $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml build langflow+dev-local: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development+ @echo "$(YELLOW)Building Langflow and OpenSearch images...$(NC)"+ $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml build langflow opensearch@echo "$(YELLOW)Starting infrastructure only (for local development)...$(NC)"- $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml -f docker-compose.host-backend.yml up -d opensearch openrag-backend dashboards langflow+ $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml -f docker-compose.host-backend.yml up -d opensearch dashboards langflow@echo "$(PURPLE)Infrastructure started!$(NC)"- @echo " $(CYAN)Backend:$(NC) http://openrag-backend"- @echo " $(CYAN)Langflow:$(NC) http://localhost:7860"- @echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"- @echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"+ @echo " $(CYAN)Langflow:$(NC) http://localhost:$${LANGFLOW_PORT:-7860}"+ @echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"+ @echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"@echo ""@echo "$(YELLOW)Now run 'make backend' and 'make frontend' in separate terminals$(NC)"-dev-local-build-lf-cpu: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development, building only Langflow image with CPU only- @echo "$(YELLOW)Building Langflow image (CPU)...$(NC)"- $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.host-backend.yml build langflow+dev-local-cpu: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development, with CPU only+ @echo "$(YELLOW)Building Langflow and OpenSearch images (CPU)...$(NC)"+ $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.host-backend.yml build langflow opensearch@echo "$(YELLOW)Starting infrastructure only (for local development)...$(NC)"- $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.host-backend.yml up -d opensearch openrag-backend dashboards langflow+ $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.host-backend.yml up -d opensearch dashboards langflow@echo "$(PURPLE)Infrastructure started!$(NC)"- @echo " $(CYAN)Backend:$(NC) http://openrag-backend"- @echo " $(CYAN)Langflow:$(NC) http://localhost:7860"- @echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"- @echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"+ @echo " $(CYAN)Langflow:$(NC) http://localhost:$${LANGFLOW_PORT:-7860}"+ @echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"+ @echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"@echo ""@echo "$(YELLOW)Now run 'make backend' and 'make frontend' in separate terminals$(NC)"@@ -494,10 +499,10 @@ dev-branch: ensure-langflow-data ensure-backend-volumes ## Build & run full stacGIT_BRANCH=$(BRANCH) GIT_REPO=$(REPO) $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.gpu.yml -f docker-compose.dev.yml up -d@echo ""@echo "$(PURPLE)Dev environment started!$(NC)"- @echo " $(CYAN)Langflow ($(BRANCH)):$(NC) http://localhost:7860"- @echo " $(CYAN)Frontend:$(NC) http://localhost:3000"- @echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"- @echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"+ @echo " $(CYAN)Langflow ($(BRANCH)):$(NC) http://localhost:$${LANGFLOW_PORT:-7860}"+ @echo " $(CYAN)Frontend:$(NC) http://localhost:$${FRONTEND_PORT:-3000}"+ @echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"+ @echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"dev-branch-cpu: ensure-langflow-data ensure-backend-volumes ## Build & run full stack with custom Langflow branch and CPU only mode@echo "$(YELLOW)Building Langflow from branch: $(BRANCH)$(NC)"@@ -510,10 +515,10 @@ dev-branch-cpu: ensure-langflow-data ensure-backend-volumes ## Build & run fullGIT_BRANCH=$(BRANCH) GIT_REPO=$(REPO) $(COMPOSE_CMD) -f docker-compose.yml -f docker-compose.dev.yml up -d@echo ""@echo "$(PURPLE)Dev environment started!$(NC)"- @echo " $(CYAN)Langflow ($(BRANCH)):$(NC) http://localhost:7860"- @echo " $(CYAN)Frontend:$(NC) http://localhost:3000"- @echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"- @echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"+ @echo " $(CYAN)Langflow ($(BRANCH)):$(NC) http://localhost:$${LANGFLOW_PORT:-7860}"+ @echo " $(CYAN)Frontend:$(NC) http://localhost:$${FRONTEND_PORT:-3000}"+ @echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"+ @echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"build-langflow-dev: ## Build only the Langflow dev image (no cache)@echo "$(YELLOW)Building Langflow dev image from branch: $(BRANCH)$(NC)"@@ -586,8 +591,65 @@ clean: stop ## Stop containers and remove volumes@$(MAKE) remove-openrag-images@echo "$(PURPLE)Cleanup complete!$(NC)"-factory-reset: ## Complete reset (stop, remove volumes, clear data, remove images)- @echo "$(RED)WARNING: This will completely reset OpenRAG!$(NC)"; \+define FACTORY_RESET_SCRIPT+set -e; \+if [ "$(FORCE)" != "true" ]; then \+ read -p "Are you sure? Type 'yes' to continue: " confirm; \+ if [ "$$confirm" != "yes" ]; then \+ echo "$(CYAN)Factory reset cancelled.$(NC)"; \+ exit 0; \+ fi; \+fi; \+echo ""; \+echo "$(YELLOW)Stopping all services and removing volumes...$(NC)"; \+$(COMPOSE_CMD) down -v --remove-orphans || true; \+echo "$(YELLOW)Removing local data directories...$(NC)"; \+if [ -d "langflow-data" ]; then \+ echo "Removing langflow-data..."; \+ rm -rf langflow-data; \+ echo "$(PURPLE)langflow-data removed$(NC)"; \+fi; \+if [ -d "config" ]; then \+ echo "Removing config..."; \+ rm -rf config; \+ echo "$(PURPLE)config removed$(NC)"; \+fi; \+if [ -d "data" ]; then \+ echo "Removing data..."; \+ rm -rf data; \+ echo "$(PURPLE)data removed$(NC)"; \+fi; \+if [ -n "$$OPENRAG_DATA_PATH" ] && [ -d "$$OPENRAG_DATA_PATH" ]; then \+ echo "Removing $$OPENRAG_DATA_PATH..."; \+ rm -rf "$$OPENRAG_DATA_PATH"; \+ echo "$(PURPLE)$$OPENRAG_DATA_PATH removed$(NC)"; \+fi; \+if [ -f "keys/private_key.pem" ] || [ -f "keys/public_key.pem" ]; then \+ echo "Removing JWT keys..."; \+ rm -f keys/private_key.pem keys/public_key.pem 2>/dev/null || \+ $(CONTAINER_RUNTIME) run --rm -v "$$(pwd)/keys:/keys" alpine rm -f /keys/private_key.pem /keys/public_key.pem 2>/dev/null || true; \+ echo "$(PURPLE)JWT keys removed$(NC)"; \+fi+endef++factory-reset: ## Complete reset (stop, remove volumes, clear data)+ @echo "$(RED)WARNING: This will completely reset OpenRAG data!$(NC)"; \+ echo "$(YELLOW)This will:$(NC)"; \+ echo " - Stop all containers"; \+ echo " - Remove all volumes"; \+ echo " - Delete langflow-data directory"; \+ echo " - Delete config directory"; \+ echo " - Delete data directory (database and session configs)"; \+ echo " - Delete JWT keys (private_key.pem, public_key.pem)"; \+ echo ""; \+ echo ""; \+ $(FACTORY_RESET_SCRIPT); \+ echo ""; \+ echo "$(PURPLE)Factory reset complete!$(NC)"; \+ echo "$(CYAN)Run 'make dev' or 'make dev-cpu' to start fresh.$(NC)";++factory-reset-clean-build: ## Complete reset (stop, remove volumes, clear data, remove images)+ @echo "$(RED)WARNING: This will completely reset OpenRAG and remove images!$(NC)"; \echo "$(YELLOW)This will:$(NC)"; \echo " - Stop all containers"; \echo " - Remove all volumes"; \@@ -663,8 +725,14 @@ backend: ## Run backend locallyfrontend: ## Run frontend locally@echo "$(YELLOW)Starting frontend locally...$(NC)"@if [ ! -d "frontend/node_modules" ]; then echo "$(YELLOW)Installing frontend dependencies first...$(NC)"; cd frontend && npm install; fi- cd frontend && npx next dev \- --hostname $(hostname)+ cd frontend && \+ export ENV_FILE="$(abspath $(ENV_FILE))"; \+ PORT=$${FRONTEND_PORT:-3000}; \+ export NEXT_DIST_DIR=$${NEXT_DIST_DIR:-$$( [ "$$PORT" = "3000" ] && echo .next || echo .next-$$PORT )}; \+ echo "$(YELLOW)Using distDir $$NEXT_DIST_DIR$(NC)"; \+ npx next dev \+ --port $$PORT \+ --hostname $(hostname)docling: ## Start docling-serve for document processing@echo "$(YELLOW)Starting docling-serve...$(NC)"@@ -871,13 +939,13 @@ test-ci: ensure-langflow-data ensure-backend-volumes ## Start infra, run integrauv run python scripts/docling_ctl.py status 2>&1 || true; \echo "$(YELLOW)Waiting for backend OIDC endpoint...$(NC)"; \for i in $$(seq 1 60); do \- $(CONTAINER_RUNTIME) exec openrag-backend curl -s http://localhost:8000/.well-known/openid-configuration >/dev/null 2>&1 && break || sleep 2; \+ $(COMPOSE_CMD) exec -T openrag-backend curl -s http://localhost:8000/.well-known/openid-configuration >/dev/null 2>&1 && break || sleep 2; \done; \echo "$(YELLOW)Fixing JWT key ownership for test runner (host UID $$(id -u))...$(NC)"; \$(CONTAINER_RUNTIME) run --rm -v $$(pwd)/keys:/keys alpine sh -c "chown $$(id -u):$$(id -g) /keys/private_key.pem /keys/public_key.pem 2>/dev/null; chmod 600 /keys/private_key.pem; chmod 644 /keys/public_key.pem 2>/dev/null" 2>/dev/null || true; \echo "$(YELLOW)Waiting for OpenSearch security config to be fully applied...$(NC)"; \for i in $$(seq 1 60); do \- if $(CONTAINER_RUNTIME) logs os 2>&1 | grep -q "Security configuration applied successfully"; then \+ if $(COMPOSE_CMD) logs opensearch 2>&1 | grep -q "Security configuration applied successfully"; then \echo "$(PURPLE)Security configuration applied$(NC)"; \break; \fi; \@@ -885,7 +953,7 @@ test-ci: ensure-langflow-data ensure-backend-volumes ## Start infra, run integradone; \echo "$(YELLOW)Verifying OIDC authenticator is active in OpenSearch...$(NC)"; \for i in $$(seq 1 30); do \- AUTHC_CONFIG=$$(curl -k -s -u admin:$${OPENSEARCH_PASSWORD} https://localhost:9200/_opendistro/_security/api/securityconfig 2>/dev/null || true); \+ AUTHC_CONFIG=$$(curl -k -s -u admin:$${OPENSEARCH_PASSWORD} https://localhost:$${OPENSEARCH_PORT:-9200}/_opendistro/_security/api/securityconfig 2>/dev/null || true); \if echo "$$AUTHC_CONFIG" | grep -q "openid_auth_domain"; then \echo "$(PURPLE)OIDC authenticator configured$(NC)"; \echo "$$AUTHC_CONFIG" | grep -A 5 "openid_auth_domain"; \@@ -900,7 +968,7 @@ test-ci: ensure-langflow-data ensure-backend-volumes ## Start infra, run integradone; \echo "$(YELLOW)Waiting for Langflow...$(NC)"; \for i in $$(seq 1 60); do \- curl -s http://localhost:7860/ >/dev/null 2>&1 && break || sleep 2; \+ curl -s http://localhost:$${LANGFLOW_PORT:-7860}/ >/dev/null 2>&1 && break || sleep 2; \done; \echo "$(YELLOW)Waiting for docling-serve at $$DOCLING_ENDPOINT...$(NC)"; \for i in $$(seq 1 60); do \@@ -924,8 +992,7 @@ test-ci: ensure-langflow-data ensure-backend-volumes ## Start infra, run integraLOG_LEVEL=$${LOG_LEVEL:-DEBUG} \GOOGLE_OAUTH_CLIENT_ID="" \GOOGLE_OAUTH_CLIENT_SECRET="" \- OPENSEARCH_HOST=localhost OPENSEARCH_PORT=9200 \- LANGFLOW_OPENSEARCH_HOST=opensearch LANGFLOW_OPENSEARCH_PORT=9200 \+ OPENSEARCH_HOST=localhost OPENSEARCH_PORT=$${OPENSEARCH_PORT:-9200} \OPENSEARCH_USERNAME=admin OPENSEARCH_PASSWORD=$${OPENSEARCH_PASSWORD} \DISABLE_STARTUP_INGEST=$${DISABLE_STARTUP_INGEST:-true} \uv run pytest tests/integration/core -vv -s --log-file=service-logs/pytest-core.log --log-file-level=DEBUG --junitxml=service-logs/junit-core.xml || TEST_RESULT=1; \@@ -1001,13 +1068,13 @@ test-ci-local: ensure-langflow-data ensure-backend-volumes ## Same as test-ci buuv run python scripts/docling_ctl.py status 2>&1 || true; \echo "$(YELLOW)Waiting for backend OIDC endpoint...$(NC)"; \for i in $$(seq 1 60); do \- $(CONTAINER_RUNTIME) exec openrag-backend curl -s http://localhost:8000/.well-known/openid-configuration >/dev/null 2>&1 && break || sleep 2; \+ $(COMPOSE_CMD) exec -T openrag-backend curl -s http://localhost:8000/.well-known/openid-configuration >/dev/null 2>&1 && break || sleep 2; \done; \echo "$(YELLOW)Fixing JWT key ownership for test runner (host UID $$(id -u))...$(NC)"; \$(CONTAINER_RUNTIME) run --rm -v $$(pwd)/keys:/keys alpine sh -c "chown $$(id -u):$$(id -g) /keys/private_key.pem /keys/public_key.pem 2>/dev/null; chmod 600 /keys/private_key.pem; chmod 644 /keys/public_key.pem 2>/dev/null" 2>/dev/null || true; \echo "$(YELLOW)Waiting for OpenSearch security config to be fully applied...$(NC)"; \for i in $$(seq 1 60); do \- if $(CONTAINER_RUNTIME) logs os 2>&1 | grep -q "Security configuration applied successfully"; then \+ if $(COMPOSE_CMD) logs opensearch 2>&1 | grep -q "Security configuration applied successfully"; then \echo "$(PURPLE)Security configuration applied$(NC)"; \break; \fi; \@@ -1015,7 +1082,7 @@ test-ci-local: ensure-langflow-data ensure-backend-volumes ## Same as test-ci budone; \echo "$(YELLOW)Verifying OIDC authenticator is active in OpenSearch...$(NC)"; \for i in $$(seq 1 30); do \- AUTHC_CONFIG=$$(curl -k -s -u admin:$${OPENSEARCH_PASSWORD} https://localhost:9200/_opendistro/_security/api/securityconfig 2>/dev/null || true); \+ AUTHC_CONFIG=$$(curl -k -s -u admin:$${OPENSEARCH_PASSWORD} https://localhost:$${OPENSEARCH_PORT:-9200}/_opendistro/_security/api/securityconfig 2>/dev/null || true); \if echo "$$AUTHC_CONFIG" | grep -q "openid_auth_domain"; then \echo "$(PURPLE)OIDC authenticator configured$(NC)"; \echo "$$AUTHC_CONFIG" | grep -A 5 "openid_auth_domain"; \@@ -1030,7 +1097,7 @@ test-ci-local: ensure-langflow-data ensure-backend-volumes ## Same as test-ci budone; \echo "$(YELLOW)Waiting for Langflow...$(NC)"; \for i in $$(seq 1 60); do \- curl -s http://localhost:7860/ >/dev/null 2>&1 && break || sleep 2; \+ curl -s http://localhost:$${LANGFLOW_PORT:-7860}/ >/dev/null 2>&1 && break || sleep 2; \done; \echo "$(YELLOW)Waiting for docling-serve at $$DOCLING_ENDPOINT...$(NC)"; \for i in $$(seq 1 60); do \@@ -1054,8 +1121,7 @@ test-ci-local: ensure-langflow-data ensure-backend-volumes ## Same as test-ci buLOG_LEVEL=$${LOG_LEVEL:-DEBUG} \GOOGLE_OAUTH_CLIENT_ID="" \GOOGLE_OAUTH_CLIENT_SECRET="" \- OPENSEARCH_HOST=localhost OPENSEARCH_PORT=9200 \- LANGFLOW_OPENSEARCH_HOST=opensearch LANGFLOW_OPENSEARCH_PORT=9200 \+ OPENSEARCH_HOST=localhost OPENSEARCH_PORT=$${OPENSEARCH_PORT:-9200} \OPENSEARCH_USERNAME=admin OPENSEARCH_PASSWORD=$${OPENSEARCH_PASSWORD} \DISABLE_STARTUP_INGEST=$${DISABLE_STARTUP_INGEST:-true} \uv run pytest tests/integration/core -vv -s --log-file=service-logs/pytest-core.log --log-file-level=DEBUG --junitxml=service-logs/junit-core.xml || TEST_RESULT=1; \@@ -1134,11 +1200,11 @@ health: ## Check health of all services@printf "$(CYAN)Frontend:$(NC) "@if curl -s -k --fail http://127.0.0.1:$${FRONTEND_PORT:-3000}/ >/dev/null 2>&1; then printf "$(GREEN)Healthy$(NC)\n"; else printf "$(RED)Not responding$(NC)\n"; fi@printf "$(CYAN)Backend:$(NC) "- @if curl -s -k --fail http://127.0.0.1:8000/health >/dev/null 2>&1; then printf "$(GREEN)Healthy$(NC)\n"; else printf "$(RED)Not responding$(NC)\n"; fi+ @if curl -s -k --fail http://127.0.0.1:$${OPENRAG_BACKEND_PORT:-8000}/health >/dev/null 2>&1; then printf "$(GREEN)Healthy$(NC)\n"; else printf "$(RED)Not responding$(NC)\n"; fi@printf "$(CYAN)Langflow:$(NC) "@if curl -s -k --fail http://127.0.0.1:$${LANGFLOW_PORT:-7860}/health >/dev/null 2>&1; then printf "$(GREEN)Healthy$(NC)\n"; else printf "$(RED)Not responding$(NC)\n"; fi@printf "$(CYAN)OpenSearch:$(NC) "- @RESULTS=$$(curl -s -k -u "admin:$$OPENSEARCH_PASSWORD" https://127.0.0.1:9200/_cluster/health 2>/dev/null); \+ @RESULTS=$$(curl -s -k -u "admin:$$OPENSEARCH_PASSWORD" https://127.0.0.1:$${OPENSEARCH_PORT:-9200}/_cluster/health 2>/dev/null); \if [ -z "$$RESULTS" ]; then \printf "$(RED)Not responding$(NC)\n"; \else \@@ -1158,8 +1224,8 @@ health: ## Check health of all servicesdb-reset: ## Reset OpenSearch indices@echo "$(YELLOW)Resetting OpenSearch indices...$(NC)"- curl -X DELETE "http://localhost:9200/documents" -u admin:$${OPENSEARCH_PASSWORD} || true- curl -X DELETE "http://localhost:9200/knowledge_filters" -u admin:$${OPENSEARCH_PASSWORD} || true+ curl -k -X DELETE "https://localhost:$${OPENSEARCH_PORT:-9200}/documents" -u admin:$${OPENSEARCH_PASSWORD} || true+ curl -k -X DELETE "https://localhost:$${OPENSEARCH_PORT:-9200}/knowledge_filters" -u admin:$${OPENSEARCH_PASSWORD} || true@echo "$(PURPLE)Indices reset. Restart backend to recreate.$(NC)"clear-os-data: ## Clear OpenSearch data volume@@ -1174,7 +1240,7 @@ clear-os-data: ## Clear OpenSearch data volumeflow-upload: ## Upload flow to Langflow@echo "$(YELLOW)Uploading flow to Langflow...$(NC)"@if [ -z "$(FLOW_FILE)" ]; then echo "$(RED)Usage: make flow-upload FLOW_FILE=path/to/flow.json$(NC)"; exit 1; fi- curl -X POST "http://localhost:7860/api/v1/flows" \+ curl -X POST "http://localhost:$${LANGFLOW_PORT:-7860}/api/v1/flows" \-H "Content-Type: application/json" \-d @$(FLOW_FILE)@echo "$(PURPLE)Flow uploaded.$(NC)"diff --git a/docker-compose.yml b/docker-compose.ymlindex 3a22a38dc..b88b8a5bd 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -1,16 +1,17 @@services:opensearch:image: langflowai/openrag-opensearch:${OPENRAG_VERSION:-latest}- # build:- # context: .- # dockerfile: Dockerfile- container_name: os- depends_on:- - openrag-backend+ build:+ context: .+ dockerfile: Dockerfile+ container_name: ${COMPOSE_PROJECT_NAME:-openrag}-opensearchenvironment:- discovery.type=single-node- OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD}- OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g+ - OPENRAG_BACKEND_PORT=${OPENRAG_BACKEND_PORT:-8000}+ - OPENRAG_BACKEND_HOST=${OPENRAG_BACKEND_HOST:-openrag-backend}+ - OPENRAG_BACKEND_INTERNAL_URL=${OPENRAG_BACKEND_INTERNAL_URL:-http://${OPENRAG_BACKEND_HOST:-openrag-backend}:${OPENRAG_BACKEND_PORT:-8000}}# NOTE: do NOT add `extra_hosts: openrag-backend:host-gateway` here.# `extra_hosts` writes to /etc/hosts, which libc resolves BEFORE# docker DNS — so the alias overrides docker-compose service-name@@ -20,8 +21,8 @@ services:# run `make backend` on the host need the alias and should add it via# an override file (see AGENTS.md → Operational constraints).ports:- - "9200:9200"- - "9600:9600"+ - "${OPENSEARCH_PORT:-9200}:9200"+ - "${OPENSEARCH_PERF_PORT:-9600}:9600"volumes:- opensearch-data:/usr/share/opensearch/datastop_grace_period: 2m@@ -35,28 +36,28 @@ services:dashboards:image: opensearchproject/opensearch-dashboards:3.6.0- container_name: osdash+ container_name: ${COMPOSE_PROJECT_NAME:-openrag}-dashboardsdepends_on:- opensearchenvironment:- OPENSEARCH_HOSTS: '["https://${OPENSEARCH_HOST:-opensearch}:${OPENSEARCH_PORT:-9200}"]'+ OPENSEARCH_HOSTS: '["https://${OPENSEARCH_HOST:-opensearch}:${OPENSEARCH_INTERNAL_PORT:-9200}"]'OPENSEARCH_USERNAME: "${OPENSEARCH_USERNAME:-admin}"OPENSEARCH_PASSWORD: ${OPENSEARCH_PASSWORD}ports:- - "5601:5601"+ - "${OPENSEARCH_DASHBOARDS_PORT:-5601}:5601"openrag-backend:image: langflowai/openrag-backend:${OPENRAG_VERSION:-latest}build:context: .dockerfile: Dockerfile.backend- container_name: openrag-backend+ container_name: ${COMPOSE_PROJECT_NAME:-openrag}-backenddepends_on:- langflowenvironment:- OPENSEARCH_HOST=${OPENSEARCH_HOST:-opensearch}- LANGFLOW_URL=http://langflow:7860- - OPENRAG_BACKEND_INTERNAL_URL=${OPENRAG_BACKEND_INTERNAL_URL:-http://openrag-backend:8000}+ - OPENRAG_BACKEND_INTERNAL_URL=${OPENRAG_BACKEND_INTERNAL_URL:-http://openrag-backend:${OPENRAG_BACKEND_PORT:-8000}}- OPENRAG_BACKEND_ROUTER_ENABLE=${OPENRAG_BACKEND_ROUTER_ENABLE:-false}- LANGFLOW_PUBLIC_URL=${LANGFLOW_PUBLIC_URL}- LANGFLOW_AUTO_LOGIN=${LANGFLOW_AUTO_LOGIN}@@ -68,9 +69,7 @@ services:- DISABLE_INGEST_WITH_LANGFLOW=${DISABLE_INGEST_WITH_LANGFLOW:-false}- INGEST_SAMPLE_DATA=${INGEST_SAMPLE_DATA:-true}- NUDGES_FLOW_ID=${NUDGES_FLOW_ID}- - OPENSEARCH_PORT=${OPENSEARCH_PORT:-9200}- - LANGFLOW_OPENSEARCH_HOST=${LANGFLOW_OPENSEARCH_HOST:-${OPENSEARCH_HOST:-opensearch}}- - LANGFLOW_OPENSEARCH_PORT=${LANGFLOW_OPENSEARCH_PORT:-${OPENSEARCH_PORT:-9200}}+ - OPENSEARCH_PORT=${OPENSEARCH_INTERNAL_PORT:-9200}- OPENSEARCH_USERNAME=${OPENSEARCH_USERNAME:-admin}- OPENSEARCH_PASSWORD=${OPENSEARCH_PASSWORD}# Single-node compose clusters don't meet the multi-node readiness counts,@@ -142,7 +141,7 @@ services:build:context: .dockerfile: Dockerfile.frontend- container_name: openrag-frontend+ container_name: ${COMPOSE_PROJECT_NAME:-openrag}-frontenddepends_on:- openrag-backendenvironment:@@ -155,7 +154,7 @@ services:build:context: .dockerfile: Dockerfile.langflow- container_name: langflow+ container_name: ${COMPOSE_PROJECT_NAME:-openrag}-langflowports:- "${LANGFLOW_PORT:-7860}:7860"volumes:@@ -197,9 +196,9 @@ services:- OPENRAG_INGEST_RUN_ID=OPENRAG_INGEST_RUN_ID- OPENRAG_INGEST_BATCH_SIZE=100- OPENSEARCH_PASSWORD=${OPENSEARCH_PASSWORD}- - OPENSEARCH_HOST=${LANGFLOW_OPENSEARCH_HOST:-${OPENSEARCH_HOST:-opensearch}}- - OPENSEARCH_PORT=${LANGFLOW_OPENSEARCH_PORT:-${OPENSEARCH_PORT:-9200}}- - OPENSEARCH_URL=https://${LANGFLOW_OPENSEARCH_HOST:-${OPENSEARCH_HOST:-opensearch}}:${LANGFLOW_OPENSEARCH_PORT:-${OPENSEARCH_PORT:-9200}}+ - OPENSEARCH_HOST=${OPENSEARCH_HOST:-opensearch}+ - OPENSEARCH_PORT=${OPENSEARCH_INTERNAL_PORT:-9200}+ - OPENSEARCH_URL=https://${OPENSEARCH_HOST:-opensearch}:${OPENSEARCH_INTERNAL_PORT:-9200}- OPENSEARCH_INDEX_NAME=${OPENSEARCH_INDEX_NAME:-documents}- DOCLING_SERVE_URL=${DOCLING_SERVE_URL:-http://host.docker.internal:5001}- DOCLING_SERVE_VERIFY_SSL=${DOCLING_SERVE_VERIFY_SSL:-true}diff --git a/frontend/.gitignore b/frontend/.gitignoreindex effa71abb..7d5e0ed52 100644--- a/frontend/.gitignore+++ b/frontend/.gitignore@@ -15,6 +15,7 @@# next.js/.next/+/.next-*//out/# productiondiff --git a/frontend/app/api/[...path]/route.ts b/frontend/app/api/[...path]/route.tsindex 361dcd3fe..0b0076295 100644--- a/frontend/app/api/[...path]/route.ts+++ b/frontend/app/api/[...path]/route.ts@@ -41,12 +41,13 @@ export async function PATCH(async function proxyRequest(request: NextRequest, params: { path: string[] }) {const backendHost = process.env.OPENRAG_BACKEND_HOST || "localhost";- const backendSSL = process.env.OPENRAG_BACKEND_SSL || false;+ const backendSSL = process.env.OPENRAG_BACKEND_SSL === "true";+ const backendPort = process.env.OPENRAG_BACKEND_PORT || "8000";const path = params.path.join("/");const searchParams = request.nextUrl.searchParams.toString();- let backendUrl = `http://${backendHost}:8000/${path}${searchParams ? `?${searchParams}` : ""}`;+ let backendUrl = `http://${backendHost}:${backendPort}/${path}${searchParams ? `?${searchParams}` : ""}`;if (backendSSL) {- backendUrl = `https://${backendHost}:8000/${path}${searchParams ? `?${searchParams}` : ""}`;+ backendUrl = `https://${backendHost}:${backendPort}/${path}${searchParams ? `?${searchParams}` : ""}`;}const requestId = getRequestId(request);const start = performance.now();diff --git a/frontend/app/api/queries/useGetSettingsQuery.ts b/frontend/app/api/queries/useGetSettingsQuery.tsindex 16158ec6e..d33b0c377 100644--- a/frontend/app/api/queries/useGetSettingsQuery.ts+++ b/frontend/app/api/queries/useGetSettingsQuery.ts@@ -79,6 +79,7 @@ export interface Settings {show_provider_ingest_settings?: boolean;segment_write_key?: string;environment?: string;+ langflow_port?: string | number | null;}async function getSettings(): Promise<Settings> {diff --git a/frontend/app/settings/_components/agent-settings-section.tsx b/frontend/app/settings/_components/agent-settings-section.tsxindex cf17b79ce..4397fba0b 100644--- a/frontend/app/settings/_components/agent-settings-section.tsx+++ b/frontend/app/settings/_components/agent-settings-section.tsx@@ -220,6 +220,7 @@ export function AgentSettingsSection() {flowId: settings.flow_id,editUrlOverride: settings.langflow_edit_url,publicUrl: settings.langflow_public_url,+ langflowPort: settings.langflow_port,isIbmAuthMode,runMode,}),diff --git a/frontend/app/settings/_components/ingest-settings-section.tsx b/frontend/app/settings/_components/ingest-settings-section.tsxindex c9271a4e7..04e977b7f 100644--- a/frontend/app/settings/_components/ingest-settings-section.tsx+++ b/frontend/app/settings/_components/ingest-settings-section.tsx@@ -275,6 +275,7 @@ export function IngestSettingsSection() {flowId: settings.ingest_flow_id,editUrlOverride: settings.langflow_ingest_edit_url,publicUrl: settings.langflow_public_url,+ langflowPort: settings.langflow_port,isIbmAuthMode,runMode,}),diff --git a/frontend/lib/fetch-server.ts b/frontend/lib/fetch-server.tsindex b87057a09..80cfa3e7b 100644--- a/frontend/lib/fetch-server.ts+++ b/frontend/lib/fetch-server.ts@@ -6,9 +6,10 @@ export async function fetchFromBackend(): Promise<Response> {const backendHost = process.env.OPENRAG_BACKEND_HOST || "localhost";const backendSSL = process.env.OPENRAG_BACKEND_SSL === "true";+ const backendPort = process.env.OPENRAG_BACKEND_PORT || "8000";const baseUrl = backendSSL- ? `https://${backendHost}:8000`- : `http://${backendHost}:8000`;+ ? `https://${backendHost}:${backendPort}`+ : `http://${backendHost}:${backendPort}`;const cookieStore = await cookies();const incoming = await headers();diff --git a/frontend/lib/url-utils.ts b/frontend/lib/url-utils.tsindex f553fc4d9..aa5c23026 100644--- a/frontend/lib/url-utils.ts+++ b/frontend/lib/url-utils.ts@@ -5,6 +5,8 @@ export interface LangflowEditUrlParams {editUrlOverride?: string | null;/** Operator-configured public Langflow URL (settings.langflow_public_url). */publicUrl?: string | null;+ /** Port for Langflow, provided by the backend (settings.langflow_port). */+ langflowPort?: number | string | null;/** Whether the deployment is in IBM auth mode. */isIbmAuthMode: boolean;/** Backend run mode ("oss" | "saas" | "on_prem"), used to pick the IBM URL derivation. */@@ -26,6 +28,7 @@ export function resolveLangflowEditUrl({flowId,editUrlOverride,publicUrl,+ langflowPort,isIbmAuthMode,runMode,locationOrigin = typeof window !== "undefined" ? window.location.origin : "",@@ -37,11 +40,12 @@ export function resolveLangflowEditUrl({: deriveCloudLangflowUrl(locationOrigin): null;+ const portToUse = langflowPort || "7860";let derivedFromOrigin = "";if (locationOrigin) {try {const url = new URL(locationOrigin);- derivedFromOrigin = `${url.protocol}//${url.hostname}:7860`;+ derivedFromOrigin = `${url.protocol}//${url.hostname}:${portToUse}`;} catch {derivedFromOrigin = "";}@@ -51,7 +55,7 @@ export function resolveLangflowEditUrl({ibmLangflowUrl ||publicUrl ||derivedFromOrigin ||- "http://localhost:7860"+ `http://localhost:${portToUse}`).replace(/\/$/, "");const computed = flowId ? `${base}/flow/${flowId}` : base;return editUrlOverride || computed;diff --git a/frontend/next.config.ts b/frontend/next.config.tsindex c54826743..47aec491d 100644--- a/frontend/next.config.ts+++ b/frontend/next.config.ts@@ -2,8 +2,12 @@ import dotenv from "dotenv";import type { NextConfig } from "next";import path from "path";-// Load environment variables from root .env file-dotenv.config({ path: path.resolve(__dirname, "../.env") });+// Load environment variables from the root env file. Honors ENV_FILE (set by+// the Makefile) so per-instance env files like `.env.instance2` are respected;+// defaults to `.env`. Absolute ENV_FILE paths are used as-is.+dotenv.config({+ path: path.resolve(__dirname, "..", process.env.ENV_FILE || ".env"),+});function getAllowedDevOrigins(): string[] {const allowedDevOrigins = process.env.NEXT_ALLOWED_DEV_ORIGINS;@@ -22,6 +26,11 @@ function getAllowedDevOrigins(): string[] {}const nextConfig: NextConfig = {+ // Build/dev output directory. Overridable via NEXT_DIST_DIR so multiple+ // `next dev` servers can run simultaneously from this same directory: Next.js+ // 16 acquires a lock at `<distDir>/lock` keyed on the project dir + distDir+ // (not the port), so a second instance must use a distinct distDir.+ distDir: process.env.NEXT_DIST_DIR || ".next",// Increase timeout for API routesexperimental: {proxyTimeout: 300000, // 5 minutesdiff --git a/frontend/playwright.config.ts b/frontend/playwright.config.tsindex 1dd0b1e7f..5ffa89165 100644--- a/frontend/playwright.config.ts+++ b/frontend/playwright.config.ts@@ -6,6 +6,7 @@ import path from "path";dotenv.config({ path: path.resolve(__dirname, "..", ".env") });const PORT = process.env.FRONTEND_PORT || 3000;+const BACKEND_PORT = process.env.OPENRAG_BACKEND_PORT || 8000;export default defineConfig({testDir: "./tests",@@ -35,7 +36,7 @@ export default defineConfig({{command: "make backend",cwd: path.resolve(__dirname, ".."),- url: "http://127.0.0.1:8000/health",+ url: `http://127.0.0.1:${BACKEND_PORT}/health`,reuseExistingServer: true,stdout: "pipe",stderr: "pipe",@@ -48,7 +49,7 @@ export default defineConfig({env: {PORT: String(PORT),VITE_PROXY_TARGET:- process.env.VITE_PROXY_TARGET || "http://127.0.0.1:8000",+ process.env.VITE_PROXY_TARGET || `http://127.0.0.1:${BACKEND_PORT}`,},},],diff --git a/kubernetes/helm/openrag/templates/backend/backend-dotenv.yaml b/kubernetes/helm/openrag/templates/backend/backend-dotenv.yamlindex d261c4da4..b893b4d18 100644--- a/kubernetes/helm/openrag/templates/backend/backend-dotenv.yaml+++ b/kubernetes/helm/openrag/templates/backend/backend-dotenv.yaml@@ -86,6 +86,7 @@ stringData:LANGFLOW_OPENSEARCH_HOST={{ include "openrag.langflow.opensearch.host" . | quote }}LANGFLOW_OPENSEARCH_PORT={{ include "openrag.langflow.opensearch.port" . | quote }}+# Google OAuth{{- if .Values.global.oauth.google.clientId }}GOOGLE_OAUTH_CLIENT_ID={{ .Values.global.oauth.google.clientId | quote }}diff --git a/scripts/ci/run_integration_suite.sh b/scripts/ci/run_integration_suite.shindex 8b4483bf6..710d8cdb9 100755--- a/scripts/ci/run_integration_suite.sh+++ b/scripts/ci/run_integration_suite.sh@@ -11,6 +11,22 @@ elsecompose_cmd=("$container_runtime" compose)fi+# Load variables from env file to find COMPOSE_PROJECT_NAME and OPENSEARCH_PORT+COMPOSE_PROJECT_NAME=""+OPENSEARCH_PORT=""+LANGFLOW_PORT=""+if [[ -f "$env_file" ]]; then+ COMPOSE_PROJECT_NAME="$(grep -E '^COMPOSE_PROJECT_NAME=' "$env_file" | cut -d= -f2- | tr -d '"'\')"+ OPENSEARCH_PORT="$(grep -E '^OPENSEARCH_PORT=' "$env_file" | cut -d= -f2- | tr -d '"'\')"+ LANGFLOW_PORT="$(grep -E '^LANGFLOW_PORT=' "$env_file" | cut -d= -f2- | tr -d '"'\')"+fi++COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-openrag}"+OPENSEARCH_PORT="${OPENSEARCH_PORT:-9200}"+LANGFLOW_PORT="${LANGFLOW_PORT:-7860}"++compose_cmd+=("-p" "$COMPOSE_PROJECT_NAME")+red=$'\033[0;31m'purple=$'\033[38;2;119;62;255m'yellow=$'\033[1;33m'@@ -52,7 +68,7 @@ test_jwt_opensearch() {-o "$response_file" \-H "Authorization: Bearer $test_token" \-H "Content-Type: application/json" \- https://localhost:9200/documents/_search \+ https://localhost:${OPENSEARCH_PORT}/documents/_search \-d '{"query":{"match_all":{}}}'; thenecho "${red}curl command failed (network error or HTTP 4xx/5xx)${nc}"head -c 400 "$response_file" 2>/dev/null || true@@ -151,7 +167,7 @@ uv run python scripts/docling_ctl.py status 2>&1 || trueecho "${yellow}Waiting for backend OIDC endpoint...${nc}"for i in $(seq 1 60); do- if "$container_runtime" exec openrag-backend curl -s http://localhost:8000/.well-known/openid-configuration >/dev/null 2>&1; then+ if "${compose_cmd[@]}" exec -T openrag-backend curl -s http://localhost:8000/.well-known/openid-configuration >/dev/null 2>&1; thenbreakfiif [[ "$i" -eq 60 ]]; then@@ -166,7 +182,7 @@ echo "${yellow}Fixing JWT key ownership for test runner (host UID $(id -u))...${echo "${yellow}Waiting for OpenSearch security config to be fully applied...${nc}"for i in $(seq 1 60); do- if "$container_runtime" logs os 2>&1 | grep -q "Security configuration applied successfully"; then+ if "${compose_cmd[@]}" logs opensearch 2>&1 | grep -q "Security configuration applied successfully"; thenecho "${purple}Security configuration applied${nc}"breakfi@@ -179,7 +195,7 @@ doneecho "${yellow}Verifying OIDC authenticator is active in OpenSearch...${nc}"for i in $(seq 1 30); do- authc_config="$(curl -k -s -u "admin:${OPENSEARCH_PASSWORD}" https://localhost:9200/_opendistro/_security/api/securityconfig 2>/dev/null || true)"+ authc_config="$(curl -k -s -u "admin:${OPENSEARCH_PASSWORD}" https://localhost:${OPENSEARCH_PORT}/_opendistro/_security/api/securityconfig 2>/dev/null || true)"if echo "$authc_config" | grep -q "openid_auth_domain"; thenecho "${purple}OIDC authenticator configured${nc}"echo "$authc_config" | grep -A 5 "openid_auth_domain" || true@@ -193,7 +209,7 @@ for i in $(seq 1 30); dosleep 2done-wait_for_url "Langflow" "http://localhost:7860/" 60+wait_for_url "Langflow" "http://localhost:${LANGFLOW_PORT}/" 60wait_for_url "docling-serve at ${docling_endpoint}" "${docling_endpoint}/health" 60echo "::endgroup::"@@ -209,8 +225,7 @@ case "$suite" inLOG_LEVEL="${LOG_LEVEL:-DEBUG}" \GOOGLE_OAUTH_CLIENT_ID="" \GOOGLE_OAUTH_CLIENT_SECRET="" \- OPENSEARCH_HOST=localhost OPENSEARCH_PORT=9200 \- LANGFLOW_OPENSEARCH_HOST=opensearch LANGFLOW_OPENSEARCH_PORT=9200 \+ OPENSEARCH_HOST=localhost OPENSEARCH_PORT=${OPENSEARCH_PORT} \OPENSEARCH_USERNAME=admin OPENSEARCH_PASSWORD="${OPENSEARCH_PASSWORD}" \DISABLE_STARTUP_INGEST="${DISABLE_STARTUP_INGEST:-true}" \uv run pytest tests/integration/core -vv -s --log-file=service-logs/pytest-core.log --log-file-level=DEBUG --junitxml=service-logs/junit-core.xml || test_result=1diff --git a/scripts/setup-e2e.sh b/scripts/setup-e2e.shold mode 100755new mode 100644index 7376f4c7f..ff6f8953f--- a/scripts/setup-e2e.sh+++ b/scripts/setup-e2e.sh@@ -42,6 +42,30 @@ elseCONTAINER_RUNTIME="podman"fi+# Load environment variables+COMPOSE_PROJECT_NAME=""+OPENSEARCH_PORT=""+LANGFLOW_PORT=""+FRONTEND_PORT=""+OPENRAG_BACKEND_PORT=""+if [ -f .env ]; then+ COMPOSE_PROJECT_NAME=$(grep -E '^COMPOSE_PROJECT_NAME=' .env | cut -d= -f2- | tr -d '"'\')+ OPENSEARCH_PORT=$(grep -E '^OPENSEARCH_PORT=' .env | cut -d= -f2- | tr -d '"'\')+ LANGFLOW_PORT=$(grep -E '^LANGFLOW_PORT=' .env | cut -d= -f2- | tr -d '"'\')+ FRONTEND_PORT=$(grep -E '^FRONTEND_PORT=' .env | cut -d= -f2- | tr -d '"'\')+ OPENRAG_BACKEND_PORT=$(grep -E '^OPENRAG_BACKEND_PORT=' .env | cut -d= -f2- | tr -d '"'\')+fi++COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-openrag}"+OPENSEARCH_PORT="${OPENSEARCH_PORT:-9200}"+LANGFLOW_PORT="${LANGFLOW_PORT:-7860}"+FRONTEND_PORT="${FRONTEND_PORT:-3000}"+OPENRAG_BACKEND_PORT="${OPENRAG_BACKEND_PORT:-8000}"++BACKEND_CONTAINER="${COMPOSE_PROJECT_NAME}-backend"+OPENSEARCH_CONTAINER="${COMPOSE_PROJECT_NAME}-opensearch"+BACKEND_PROXY_NAME="${COMPOSE_PROJECT_NAME}-backend-proxy"+echo "Using container runtime: $CONTAINER_RUNTIME"echo "Starting E2E Setup..."@@ -57,16 +81,16 @@ make dev-cpuecho "Starting docling..."make docling-# Forward backend port 8000 using a proxy container+# Forward backend port using a proxy container# We find the network of the backend container and use a proxy to bridge it to the host.-echo "Starting backend port forwarder at localhost:8000..."-${CONTAINER_RUNTIME} rm -f openrag-backend-proxy 2>/dev/null || true-BACKEND_NETWORK=$(${CONTAINER_RUNTIME} inspect openrag-backend -f '{{range $k,$v := .NetworkSettings.Networks}}{{$k}}{{end}}' | head -n 1)+echo "Starting backend port forwarder at localhost:${OPENRAG_BACKEND_PORT}..."+${CONTAINER_RUNTIME} rm -f ${BACKEND_PROXY_NAME} 2>/dev/null || true+BACKEND_NETWORK=$(${CONTAINER_RUNTIME} inspect ${BACKEND_CONTAINER} -f '{{range $k,$v := .NetworkSettings.Networks}}{{$k}}{{end}}' | head -n 1)${CONTAINER_RUNTIME} run -d --rm \- --name openrag-backend-proxy \+ --name ${BACKEND_PROXY_NAME} \--network "$BACKEND_NETWORK" \- -p 8000:8000 \- alpine/socat TCP-LISTEN:8000,fork,reuseaddr TCP:openrag-backend:8000+ -p ${OPENRAG_BACKEND_PORT}:8000 \+ alpine/socat TCP-LISTEN:8000,fork,reuseaddr TCP:${BACKEND_CONTAINER}:8000# On Linux/CI, Docker volumes are root-owned. Fix them so the host runner can write to them.if [ "$CI" = "true" ] && [[ "$OSTYPE" != "darwin"* ]]; then@@ -81,7 +105,7 @@ CERT_EXTRACT_TIMEOUT=60CERT_EXTRACT_ELAPSED=0# Wait for OpenSearch container to be running and certificate to be available-until ${CONTAINER_RUNTIME} exec os test -f /usr/share/opensearch/config/root-ca.pem 2>/dev/null; do+until ${CONTAINER_RUNTIME} exec ${OPENSEARCH_CONTAINER} test -f /usr/share/opensearch/config/root-ca.pem 2>/dev/null; dosleep 2CERT_EXTRACT_ELAPSED=$((CERT_EXTRACT_ELAPSED + 2))if [ $CERT_EXTRACT_ELAPSED -ge $CERT_EXTRACT_TIMEOUT ]; then@@ -96,7 +120,7 @@ done# Extract the certificate if availableif [ "$SKIP_CERT_VALIDATION" != "true" ]; thenmkdir -p securityconfig- if ${CONTAINER_RUNTIME} cp os:/usr/share/opensearch/config/root-ca.pem securityconfig/root-ca.pem 2>/dev/null; then+ if ${CONTAINER_RUNTIME} cp ${OPENSEARCH_CONTAINER}:/usr/share/opensearch/config/root-ca.pem securityconfig/root-ca.pem 2>/dev/null; thenecho "Successfully extracted CA certificate to securityconfig/root-ca.pem"chmod 644 securityconfig/root-ca.pemelse@@ -138,12 +162,12 @@ elseCURL_CERT_PATH="$OPENSEARCH_CA_CERT"fi-until curl -s $CURL_OPTS ${CURL_CERT_PATH:+"$CURL_CERT_PATH"} https://localhost:9200 >/dev/null; do+until curl -s $CURL_OPTS ${CURL_CERT_PATH:+"$CURL_CERT_PATH"} https://localhost:${OPENSEARCH_PORT} >/dev/null; dosleep 5ELAPSED=$((ELAPSED + 5))if [ $ELAPSED -ge $TIMEOUT ]; thenecho "ERROR: OpenSearch did not become ready within ${TIMEOUT}s"- ${CONTAINER_RUNTIME:-docker} logs os 2>&1 | tail -n 100+ ${CONTAINER_RUNTIME:-docker} logs ${OPENSEARCH_CONTAINER} 2>&1 | tail -n 100exit 1fiecho "Waiting for OpenSearch... (${ELAPSED}s/${TIMEOUT}s)"@@ -151,7 +175,7 @@ doneecho "Waiting for Langflow..."ELAPSED=0-until curl -s http://localhost:7860/health >/dev/null; do+until curl -s http://localhost:${LANGFLOW_PORT}/health >/dev/null; dosleep 5ELAPSED=$((ELAPSED + 5))if [ $ELAPSED -ge $TIMEOUT ]; then@@ -163,7 +187,7 @@ doneecho "Waiting for Frontend..."ELAPSED=0-until curl -s http://localhost:3000 >/dev/null; do+until curl -s http://localhost:${FRONTEND_PORT} >/dev/null; dosleep 5ELAPSED=$((ELAPSED + 5))if [ $ELAPSED -ge $TIMEOUT ]; then@@ -175,12 +199,12 @@ doneecho "Waiting for Backend (via proxy)..."ELAPSED=0-until [ "$(curl -s http://localhost:8000/search/health -o /dev/null -w "%{http_code}")" -eq 200 ]; do+until [ "$(curl -s http://localhost:${OPENRAG_BACKEND_PORT}/search/health -o /dev/null -w "%{http_code}")" -eq 200 ]; dosleep 5ELAPSED=$((ELAPSED + 5))if [ $ELAPSED -ge $TIMEOUT ]; thenecho "ERROR: Backend did not become ready within ${TIMEOUT}s"- ${CONTAINER_RUNTIME} logs openrag-backend 2>&1 | tail -n 100+ ${CONTAINER_RUNTIME} logs ${BACKEND_CONTAINER} 2>&1 | tail -n 100exit 1fiecho "Waiting for Backend... (${ELAPSED}s/${TIMEOUT}s)"@@ -188,7 +212,7 @@ doneecho "Waiting for OpenSearch security configuration to be applied..."ELAPSED=0-until ${CONTAINER_RUNTIME} logs os 2>&1 | grep -q "Security configuration applied successfully" || [ $ELAPSED -ge 60 ]; do+until ${CONTAINER_RUNTIME} logs ${OPENSEARCH_CONTAINER} 2>&1 | grep -q "Security configuration applied successfully" || [ $ELAPSED -ge 60 ]; dosleep 2ELAPSED=$((ELAPSED + 2))donediff --git a/src/api/oidc.py b/src/api/oidc.pyindex 1cc62b11d..d55a47dc4 100644--- a/src/api/oidc.py+++ b/src/api/oidc.py@@ -1,12 +1,15 @@-import os+import base64+from cryptography.hazmat.primitives import serializationfrom fastapi import Depends, Request-from pydantic import BaseModelfrom fastapi.responses import JSONResponse-import base64-from cryptography.hazmat.primitives import serialization+from pydantic import BaseModel+from config.settings import OPENRAG_BACKEND_PORT, OPENRAG_FQDNfrom dependencies import get_session_manager+from utils.logging_config import get_logger++logger = get_logger(__name__)class TokenIntrospectBody(BaseModel):@@ -18,9 +21,8 @@ async def oidc_discovery(session_manager=Depends(get_session_manager),):"""OIDC discovery endpoint"""- openrag_fqdn = os.getenv("OPENRAG_FQDN")- if openrag_fqdn:- base_url = f"http://{openrag_fqdn}:8000"+ if OPENRAG_FQDN:+ base_url = f"http://{OPENRAG_FQDN}:{OPENRAG_BACKEND_PORT}"else:base_url = str(request.base_url).rstrip("/")@@ -36,8 +38,16 @@ async def oidc_discovery("scopes_supported": ["openid", "email", "profile"],"token_endpoint_auth_methods_supported": ["client_secret_basic"],"claims_supported": [- "sub", "iss", "aud", "exp", "iat", "auth_time",- "email", "email_verified", "name", "preferred_username",+ "sub",+ "iss",+ "aud",+ "exp",+ "iat",+ "auth_time",+ "email",+ "email_verified",+ "name",+ "preferred_username",],}@@ -74,10 +84,9 @@ async def jwks_endpoint(return JSONResponse({"keys": [jwk]})- except Exception as e:- return JSONResponse(- {"error": f"Failed to generate JWKS: {str(e)}"}, status_code=500- )+ except Exception:+ logger.exception("Failed to generate JWKS")+ return JSONResponse({"error": "Failed to generate JWKS"}, status_code=500)async def token_introspection(@@ -105,7 +114,6 @@ async def token_introspection(else:return JSONResponse({"active": False})- except Exception as e:- return JSONResponse(- {"error": f"Token introspection failed: {str(e)}"}, status_code=500- )+ except Exception:+ logger.exception("Token introspection failed")+ return JSONResponse({"error": "Token introspection failed"}, status_code=500)diff --git a/src/api/settings/endpoints.py b/src/api/settings/endpoints.pyindex d3975f43e..b672161c2 100644--- a/src/api/settings/endpoints.py+++ b/src/api/settings/endpoints.py@@ -61,6 +61,7 @@ from config.settings import (INGEST_SAMPLE_DATA,LANGFLOW_CHAT_FLOW_ID,LANGFLOW_INGEST_FLOW_ID,+ LANGFLOW_PORT,LANGFLOW_PUBLIC_URL,LANGFLOW_URL,LOCALHOST_URL,@@ -241,6 +242,7 @@ async def get_settings(show_provider_ingest_settings=OPENRAG_SHOW_PROVIDER_INGEST_SETTINGS,segment_write_key=SEGMENT_WRITE_KEY or None,environment=ENVIRONMENT or None,+ langflow_port=str(LANGFLOW_PORT),)except Exception as e:diff --git a/src/api/settings/models.py b/src/api/settings/models.pyindex 9c9a6429d..53871ee58 100644--- a/src/api/settings/models.py+++ b/src/api/settings/models.py@@ -164,6 +164,7 @@ class SettingsResponse(BaseModel):show_provider_ingest_settings: bool = Falsesegment_write_key: str | None = Noneenvironment: str | None = None+ langflow_port: str | None = Noneclass OnboardingResponse(BaseModel):diff --git a/src/config/settings.py b/src/config/settings.pyindex 32ccd3a9b..54626c8df 100644--- a/src/config/settings.py+++ b/src/config/settings.py@@ -33,8 +33,8 @@ OPENSEARCH_PORT = get_env_int("OPENSEARCH_PORT", 9200)OPENSEARCH_URL = f"https://{OPENSEARCH_HOST}:{OPENSEARCH_PORT}"# Optional: Langflow-specific OpenSearch endpoint-LANGFLOW_OPENSEARCH_HOST = os.getenv("LANGFLOW_OPENSEARCH_HOST", OPENSEARCH_HOST)-LANGFLOW_OPENSEARCH_PORT = get_env_int("LANGFLOW_OPENSEARCH_PORT", OPENSEARCH_PORT)+LANGFLOW_OPENSEARCH_HOST = os.getenv("LANGFLOW_OPENSEARCH_HOST")+LANGFLOW_OPENSEARCH_PORT = get_env_int("LANGFLOW_OPENSEARCH_PORT")OPENSEARCH_USERNAME = os.getenv("OPENSEARCH_USERNAME", "admin")OPENSEARCH_PASSWORD = os.getenv("OPENSEARCH_PASSWORD")@@ -75,7 +75,8 @@ def get_opensearch_password() -> str | None:OPENRAG_FQDN = os.getenv("OPENRAG_FQDN")-LANGFLOW_URL = os.getenv("LANGFLOW_URL", "http://localhost:7860")+LANGFLOW_PORT = get_env_int("LANGFLOW_PORT", 7860)+LANGFLOW_URL = os.getenv("LANGFLOW_URL", f"http://localhost:{LANGFLOW_PORT}")# Optional: public URL for browser links (e.g., http://localhost:7860)LANGFLOW_PUBLIC_URL = os.getenv("LANGFLOW_PUBLIC_URL")LANGFLOW_CHAT_FLOW_ID = os.getenv("LANGFLOW_CHAT_FLOW_ID") or "1098eea1-6649-4e1d-aed1-b77249fb8dd0"@@ -85,9 +86,10 @@ LANGFLOW_INGEST_FLOW_ID = (LANGFLOW_URL_INGEST_FLOW_ID = (os.getenv("LANGFLOW_URL_INGEST_FLOW_ID") or "72c3d17c-2dac-4a73-b48a-6518473d7830")+OPENRAG_BACKEND_PORT = get_env_int("OPENRAG_BACKEND_PORT", 8000)OPENRAG_BACKEND_INTERNAL_URL = os.getenv("OPENRAG_BACKEND_INTERNAL_URL",- "http://openrag-backend:8000",+ f"http://openrag-backend:{OPENRAG_BACKEND_PORT}",).rstrip("/")# --- Backend ingestion-callback proxy router ------------------------------diff --git a/src/main.py b/src/main.pyindex 96c852998..8edd56f2f 100644--- a/src/main.py+++ b/src/main.py@@ -29,7 +29,7 @@ import atexitimport httpx # noqa: F401from app.factory import create_app-from config.settings import ACCESS_LOG_ENABLED+from config.settings import ACCESS_LOG_ENABLED, OPENRAG_BACKEND_PORTfrom services.default_docs_service import (_get_remote_docs_signature,_should_use_url_default_docs_ingest,@@ -102,7 +102,7 @@ if __name__ == "__main__":app,workers=1,host="0.0.0.0",- port=8000,+ port=OPENRAG_BACKEND_PORT,reload=False,access_log=ACCESS_LOG_ENABLED,log_config=None,diff --git a/src/services/monitor_service.py b/src/services/monitor_service.pyindex dd33e9dc1..331c02c66 100644--- a/src/services/monitor_service.py+++ b/src/services/monitor_service.py@@ -2,7 +2,7 @@ import jsonimport uuidfrom typing import Any-from config.settings import clients+from config.settings import OPENRAG_BACKEND_INTERNAL_URL, clientsfrom utils.logging_config import get_loggerlogger = get_logger(__name__)@@ -11,7 +11,7 @@ logger = get_logger(__name__)class MonitorService:def __init__(self, session_manager=None, webhook_base_url: str = None):self.session_manager = session_manager- self.webhook_base_url = webhook_base_url or "http://openrag-backend:8000"+ self.webhook_base_url = webhook_base_url or OPENRAG_BACKEND_INTERNAL_URLdef _trusted_opensearch_client(self):if clients.opensearch is None:diff --git a/src/session_manager.py b/src/session_manager.pyindex 81e5c80ae..b3b85b4f0 100644--- a/src/session_manager.py+++ b/src/session_manager.py@@ -207,11 +207,11 @@ class SessionManager:def _get_oidc_issuer(self) -> str:# Use OpenSearch-compatible issuer for OIDC validation- from config.settings import OPENRAG_FQDN+ from config.settings import OPENRAG_BACKEND_PORT, OPENRAG_FQDN- oidc_issuer = "http://openrag-backend:8000"+ oidc_issuer = f"http://openrag-backend:{OPENRAG_BACKEND_PORT}"if OPENRAG_FQDN:- oidc_issuer = f"http://{OPENRAG_FQDN}:8000"+ oidc_issuer = f"http://{OPENRAG_FQDN}:{OPENRAG_BACKEND_PORT}"return oidc_issuerdef _create_signed_jwt_token(diff --git a/src/tui/config_fields.py b/src/tui/config_fields.pyindex f3e0290ac..cd74614b8 100644--- a/src/tui/config_fields.py+++ b/src/tui/config_fields.py@@ -4,13 +4,14 @@ This is the single source of truth for all user-configurable fields.Both the TUI config screen and the CLI wizard consume these definitions."""-from dataclasses import dataclass, field as dataclass_field-from typing import Callable, Optional+from collections.abc import Callable+from dataclasses import dataclass+from dataclasses import field as dataclass_fieldfrom .utils.validation import (- validate_openai_api_key,validate_anthropic_api_key,validate_ollama_endpoint,+ validate_openai_api_key,validate_watsonx_endpoint,)@@ -28,7 +29,7 @@ class ConfigField:required: bool = Falseadvanced: bool = False # only shown in full/advanced modehelper_text: str = ""- validator: Optional[Callable[[str], bool]] = None+ validator: Callable[[str], bool] | None = Nonevalidator_error: str = ""@@ -44,243 +45,369 @@ class ConfigSection:CONFIG_SECTIONS: list[ConfigSection] = [# ── Security ────────────────────────────────────────────────- ConfigSection("Security", [- ConfigField(- "openrag_encryption_key", "OPENRAG_ENCRYPTION_KEY", "OpenRAG Master Key",- placeholder="Auto-generated secure Base64 key",- secret=True, required=True,- helper_text="32-byte Base64 key for securing your database credentials (auto-generates if empty)",- ),- ConfigField(- "openrag_tenant_id", "OPENRAG_TENANT_ID", "Tenant ID",- placeholder="openrag", default="openrag",- helper_text="Identifier for AAD tenant binding (default: openrag)",- ),- ConfigField(- "openrag_enforce_prerequisites", "OPENRAG_ENFORCE_PREREQUISITES", "Enforce Prerequisites",- placeholder="false", default="false",- advanced=True,- helper_text="If true, application will fail to start if the encryption key is missing",- ),- ]),-+ ConfigSection(+ "Security",+ [+ ConfigField(+ "openrag_encryption_key",+ "OPENRAG_ENCRYPTION_KEY",+ "OpenRAG Master Key",+ placeholder="Auto-generated secure Base64 key",+ secret=True,+ required=True,+ helper_text="32-byte Base64 key for securing your database credentials (auto-generates if empty)",+ ),+ ConfigField(+ "openrag_tenant_id",+ "OPENRAG_TENANT_ID",+ "Tenant ID",+ placeholder="openrag",+ default="openrag",+ helper_text="Identifier for AAD tenant binding (default: openrag)",+ ),+ ConfigField(+ "openrag_enforce_prerequisites",+ "OPENRAG_ENFORCE_PREREQUISITES",+ "Enforce Prerequisites",+ placeholder="false",+ default="false",+ advanced=True,+ helper_text="If true, application will fail to start if the encryption key is missing",+ ),+ ],+ ),# ── OpenSearch ──────────────────────────────────────────────- ConfigSection("OpenSearch", [- ConfigField(- "opensearch_password", "OPENSEARCH_PASSWORD", "Admin Password",- placeholder="Auto-generated secure password",- secret=True, required=True,- helper_text="Validate your password here: https://lowe.github.io/tryzxcvbn/",- ),- ConfigField(- "opensearch_username", "OPENSEARCH_USERNAME", "Admin Username",- placeholder="admin", default="admin",- helper_text="OpenSearch admin username (default: admin)",- ),- ConfigField(- "opensearch_host", "OPENSEARCH_HOST", "Host",- placeholder="opensearch", default="opensearch",- helper_text="Override for remote OpenSearch instances (default: opensearch)",- ),- ConfigField(- "opensearch_port", "OPENSEARCH_PORT", "Port",- placeholder="9200", default="9200",- helper_text="Override for remote OpenSearch instances (default: 9200)",- ),- ConfigField(- "opensearch_index_name", "OPENSEARCH_INDEX_NAME", "Index Name",- placeholder="documents", default="documents",- helper_text="Name of the index to use in OpenSearch",- ),- ]),-+ ConfigSection(+ "OpenSearch",+ [+ ConfigField(+ "opensearch_password",+ "OPENSEARCH_PASSWORD",+ "Admin Password",+ placeholder="Auto-generated secure password",+ secret=True,+ required=True,+ helper_text="Validate your password here: https://lowe.github.io/tryzxcvbn/",+ ),+ ConfigField(+ "opensearch_username",+ "OPENSEARCH_USERNAME",+ "Admin Username",+ placeholder="admin",+ default="admin",+ helper_text="OpenSearch admin username (default: admin)",+ ),+ ConfigField(+ "opensearch_host",+ "OPENSEARCH_HOST",+ "Host",+ placeholder="opensearch",+ default="opensearch",+ helper_text="Override for remote OpenSearch instances (default: opensearch)",+ ),+ ConfigField(+ "opensearch_port",+ "OPENSEARCH_PORT",+ "Port",+ placeholder="9200",+ default="9200",+ helper_text="Override for remote OpenSearch instances (default: 9200)",+ ),+ ConfigField(+ "opensearch_perf_port",+ "OPENSEARCH_PERF_PORT",+ "Performance Analyzer Port",+ placeholder="9600",+ default="9600",+ helper_text="OpenSearch performance analyzer port (default: 9600)",+ advanced=True,+ ),+ ConfigField(+ "opensearch_index_name",+ "OPENSEARCH_INDEX_NAME",+ "Index Name",+ placeholder="documents",+ default="documents",+ helper_text="Name of the index to use in OpenSearch",+ ),+ ],+ ),# ── Langflow ────────────────────────────────────────────────- ConfigSection("Langflow", [- ConfigField(- "langflow_superuser_password", "LANGFLOW_SUPERUSER_PASSWORD",- "Admin Password",- placeholder="Langflow password", secret=True,- helper_text="Leave empty for autologin (no password required)",- ),- ConfigField(- "langflow_superuser", "LANGFLOW_SUPERUSER", "Admin Username",- placeholder="admin", default="admin",- ),- ConfigField(- "langflow_data_path", "LANGFLOW_DATA_PATH", "Data Path",- placeholder="~/.openrag/data/langflow-data",- default="$HOME/.openrag/data/langflow-data",- helper_text="Directory to persist Langflow flows and state across restarts",- ),- ConfigField(- "langflow_public_url", "LANGFLOW_PUBLIC_URL", "Public URL",- placeholder="http://localhost:7860",- helper_text="External URL for Langflow access",- advanced=True,- ),- ]),-+ ConfigSection(+ "Langflow",+ [+ ConfigField(+ "langflow_superuser_password",+ "LANGFLOW_SUPERUSER_PASSWORD",+ "Admin Password",+ placeholder="Langflow password",+ secret=True,+ helper_text="Leave empty for autologin (no password required)",+ ),+ ConfigField(+ "langflow_superuser",+ "LANGFLOW_SUPERUSER",+ "Admin Username",+ placeholder="admin",+ default="admin",+ ),+ ConfigField(+ "langflow_data_path",+ "LANGFLOW_DATA_PATH",+ "Data Path",+ placeholder="~/.openrag/data/langflow-data",+ default="$HOME/.openrag/data/langflow-data",+ helper_text="Directory to persist Langflow flows and state across restarts",+ ),+ ConfigField(+ "langflow_public_url",+ "LANGFLOW_PUBLIC_URL",+ "Public URL",+ placeholder="http://localhost:7860",+ helper_text="External URL for Langflow access",+ advanced=True,+ ),+ ],+ ),# ── AI Providers ────────────────────────────────────────────- ConfigSection("AI Providers", [- ConfigField(- "openai_api_key", "OPENAI_API_KEY", "OpenAI API Key",- placeholder="sk-...", secret=True,- helper_text="Get a key: https://platform.openai.com/api-keys",- validator=validate_openai_api_key,- validator_error="Invalid OpenAI API key format (should start with sk-)",- ),- ConfigField(- "anthropic_api_key", "ANTHROPIC_API_KEY", "Anthropic API Key",- placeholder="sk-ant-...", secret=True,- helper_text="Get a key: https://console.anthropic.com/settings/keys",- validator=validate_anthropic_api_key,- validator_error="Invalid Anthropic API key format (should start with sk-ant-)",- ),- ConfigField(- "ollama_endpoint", "OLLAMA_ENDPOINT", "Ollama Base URL",- placeholder="http://localhost:11434",- helper_text="Endpoint of your Ollama server",- validator=validate_ollama_endpoint,- validator_error="Invalid Ollama endpoint URL format",- ),- ConfigField(- "watsonx_api_key", "WATSONX_API_KEY", "IBM watsonx.ai API Key",- placeholder="", secret=True,- helper_text="Get a key: https://cloud.ibm.com/iam/apikeys",- ),- ConfigField(- "watsonx_endpoint", "WATSONX_ENDPOINT", "IBM watsonx.ai Endpoint",- placeholder="https://us-south.ml.cloud.ibm.com",- helper_text="Example: https://us-south.ml.cloud.ibm.com",- validator=validate_watsonx_endpoint,- validator_error="Invalid watsonx.ai endpoint URL format",- ),- ConfigField(- "watsonx_project_id", "WATSONX_PROJECT_ID", "IBM watsonx.ai Project ID",- placeholder="",- helper_text="Find in your IBM Cloud project settings",- ),- ]),-+ ConfigSection(+ "AI Providers",+ [+ ConfigField(+ "openai_api_key",+ "OPENAI_API_KEY",+ "OpenAI API Key",+ placeholder="sk-...",+ secret=True,+ helper_text="Get a key: https://platform.openai.com/api-keys",+ validator=validate_openai_api_key,+ validator_error="Invalid OpenAI API key format (should start with sk-)",+ ),+ ConfigField(+ "anthropic_api_key",+ "ANTHROPIC_API_KEY",+ "Anthropic API Key",+ placeholder="sk-ant-...",+ secret=True,+ helper_text="Get a key: https://console.anthropic.com/settings/keys",+ validator=validate_anthropic_api_key,+ validator_error="Invalid Anthropic API key format (should start with sk-ant-)",+ ),+ ConfigField(+ "ollama_endpoint",+ "OLLAMA_ENDPOINT",+ "Ollama Base URL",+ placeholder="http://localhost:11434",+ helper_text="Endpoint of your Ollama server",+ validator=validate_ollama_endpoint,+ validator_error="Invalid Ollama endpoint URL format",+ ),+ ConfigField(+ "watsonx_api_key",+ "WATSONX_API_KEY",+ "IBM watsonx.ai API Key",+ placeholder="",+ secret=True,+ helper_text="Get a key: https://cloud.ibm.com/iam/apikeys",+ ),+ ConfigField(+ "watsonx_endpoint",+ "WATSONX_ENDPOINT",+ "IBM watsonx.ai Endpoint",+ placeholder="https://us-south.ml.cloud.ibm.com",+ helper_text="Example: https://us-south.ml.cloud.ibm.com",+ validator=validate_watsonx_endpoint,+ validator_error="Invalid watsonx.ai endpoint URL format",+ ),+ ConfigField(+ "watsonx_project_id",+ "WATSONX_PROJECT_ID",+ "IBM watsonx.ai Project ID",+ placeholder="",+ helper_text="Find in your IBM Cloud project settings",+ ),+ ],+ ),# ── Google OAuth ────────────────────────────────────────────- ConfigSection("Google OAuth", [- ConfigField(- "google_oauth_client_id", "GOOGLE_OAUTH_CLIENT_ID", "Client ID",- placeholder="xxx.apps.googleusercontent.com",- helper_text="Create credentials: https://console.cloud.google.com/apis/credentials",- ),- ConfigField(- "google_oauth_client_secret", "GOOGLE_OAUTH_CLIENT_SECRET",- "Client Secret",- placeholder="", secret=True,- ),- ], advanced=True, gate_prompt="Configure Google OAuth?"),-+ ConfigSection(+ "Google OAuth",+ [+ ConfigField(+ "google_oauth_client_id",+ "GOOGLE_OAUTH_CLIENT_ID",+ "Client ID",+ placeholder="xxx.apps.googleusercontent.com",+ helper_text="Create credentials: https://console.cloud.google.com/apis/credentials",+ ),+ ConfigField(+ "google_oauth_client_secret",+ "GOOGLE_OAUTH_CLIENT_SECRET",+ "Client Secret",+ placeholder="",+ secret=True,+ ),+ ],+ advanced=True,+ gate_prompt="Configure Google OAuth?",+ ),# ── Microsoft Graph OAuth ───────────────────────────────────- ConfigSection("Microsoft Graph OAuth", [- ConfigField(- "microsoft_graph_oauth_client_id", "MICROSOFT_GRAPH_OAUTH_CLIENT_ID",- "Client ID",- placeholder="",- helper_text="Create app: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",- ),- ConfigField(- "microsoft_graph_oauth_client_secret",- "MICROSOFT_GRAPH_OAUTH_CLIENT_SECRET", "Client Secret",- placeholder="", secret=True,- ),- ], advanced=True, gate_prompt="Configure Microsoft Graph OAuth?"),-+ ConfigSection(+ "Microsoft Graph OAuth",+ [+ ConfigField(+ "microsoft_graph_oauth_client_id",+ "MICROSOFT_GRAPH_OAUTH_CLIENT_ID",+ "Client ID",+ placeholder="",+ helper_text="Create app: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",+ ),+ ConfigField(+ "microsoft_graph_oauth_client_secret",+ "MICROSOFT_GRAPH_OAUTH_CLIENT_SECRET",+ "Client Secret",+ placeholder="",+ secret=True,+ ),+ ],+ advanced=True,+ gate_prompt="Configure Microsoft Graph OAuth?",+ ),# ── AWS ─────────────────────────────────────────────────────- ConfigSection("AWS", [- ConfigField(- "aws_access_key_id", "AWS_ACCESS_KEY_ID", "Access Key ID",- placeholder="",- helper_text="Create keys: https://console.aws.amazon.com/iam/home#/security_credentials",- ),- ConfigField(- "aws_secret_access_key", "AWS_SECRET_ACCESS_KEY", "Secret Access Key",- placeholder="", secret=True,- ),- ConfigField(- "aws_s3_endpoint", "AWS_S3_ENDPOINT", "S3 Endpoint URL (optional)",- placeholder="",- helper_text="Leave empty for AWS S3. For MinIO, R2, or other S3-compatible services, enter the endpoint URL.",- ),- ConfigField(- "aws_region", "AWS_REGION", "AWS Region (optional)",- placeholder="us-east-1",- default="us-east-1",- helper_text="AWS region (e.g. us-east-1, eu-west-1). Default: us-east-1.",- ),- ], advanced=True, gate_prompt="Configure AWS credentials?"),-+ ConfigSection(+ "AWS",+ [+ ConfigField(+ "aws_access_key_id",+ "AWS_ACCESS_KEY_ID",+ "Access Key ID",+ placeholder="",+ helper_text="Create keys: https://console.aws.amazon.com/iam/home#/security_credentials",+ ),+ ConfigField(+ "aws_secret_access_key",+ "AWS_SECRET_ACCESS_KEY",+ "Secret Access Key",+ placeholder="",+ secret=True,+ ),+ ConfigField(+ "aws_s3_endpoint",+ "AWS_S3_ENDPOINT",+ "S3 Endpoint URL (optional)",+ placeholder="",+ helper_text="Leave empty for AWS S3. For MinIO, R2, or other S3-compatible services, enter the endpoint URL.",+ ),+ ConfigField(+ "aws_region",+ "AWS_REGION",+ "AWS Region (optional)",+ placeholder="us-east-1",+ default="us-east-1",+ helper_text="AWS region (e.g. us-east-1, eu-west-1). Default: us-east-1.",+ ),+ ],+ advanced=True,+ gate_prompt="Configure AWS credentials?",+ ),# ── IBM Cloud Object Storage ─────────────────────────────────- ConfigSection("IBM Cloud Object Storage", [- ConfigField(- "ibm_cos_api_key", "IBM_COS_API_KEY", "API Key",- placeholder="",- helper_text="Create API key at https://cloud.ibm.com/iam/apikeys",- secret=True,- ),- ConfigField(- "ibm_cos_service_instance_id", "IBM_COS_SERVICE_INSTANCE_ID",- "Service Instance ID (CRN)",- placeholder="crn:v1:bluemix:...",- ),- ConfigField(- "ibm_cos_endpoint", "IBM_COS_ENDPOINT", "Service Endpoint",- placeholder="https://s3.us-south.cloud-object-storage.appdomain.cloud",- helper_text="Endpoints: https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints",- ),- ConfigField(- "ibm_cos_hmac_access_key_id", "IBM_COS_HMAC_ACCESS_KEY_ID",- "HMAC Access Key ID (optional)",- placeholder="",- ),- ConfigField(- "ibm_cos_hmac_secret_access_key", "IBM_COS_HMAC_SECRET_ACCESS_KEY",- "HMAC Secret Access Key (optional)",- placeholder="", secret=True,- ),- ], advanced=True, gate_prompt="Configure IBM Cloud Object Storage?"),-+ ConfigSection(+ "IBM Cloud Object Storage",+ [+ ConfigField(+ "ibm_cos_api_key",+ "IBM_COS_API_KEY",+ "API Key",+ placeholder="",+ helper_text="Create API key at https://cloud.ibm.com/iam/apikeys",+ secret=True,+ ),+ ConfigField(+ "ibm_cos_service_instance_id",+ "IBM_COS_SERVICE_INSTANCE_ID",+ "Service Instance ID (CRN)",+ placeholder="crn:v1:bluemix:...",+ ),+ ConfigField(+ "ibm_cos_endpoint",+ "IBM_COS_ENDPOINT",+ "Service Endpoint",+ placeholder="https://s3.us-south.cloud-object-storage.appdomain.cloud",+ helper_text="Endpoints: https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints",+ ),+ ConfigField(+ "ibm_cos_hmac_access_key_id",+ "IBM_COS_HMAC_ACCESS_KEY_ID",+ "HMAC Access Key ID (optional)",+ placeholder="",+ ),+ ConfigField(+ "ibm_cos_hmac_secret_access_key",+ "IBM_COS_HMAC_SECRET_ACCESS_KEY",+ "HMAC Secret Access Key (optional)",+ placeholder="",+ secret=True,+ ),+ ],+ advanced=True,+ gate_prompt="Configure IBM Cloud Object Storage?",+ ),# ── Langfuse ────────────────────────────────────────────────- ConfigSection("Langfuse", [- ConfigField(- "langfuse_secret_key", "LANGFUSE_SECRET_KEY", "Secret Key",- placeholder="sk-lf-...", secret=True,- helper_text="Get keys from your Langfuse project settings",- ),- ConfigField(- "langfuse_public_key", "LANGFUSE_PUBLIC_KEY", "Public Key",- placeholder="pk-lf-...", secret=True,- ),- ConfigField(- "langfuse_host", "LANGFUSE_HOST", "Host",- placeholder="https://cloud.langfuse.com",- helper_text="Leave empty for Langfuse Cloud, or set for self-hosted",- ),- ], gate_prompt="Configure Langfuse tracing?"),-+ ConfigSection(+ "Langfuse",+ [+ ConfigField(+ "langfuse_secret_key",+ "LANGFUSE_SECRET_KEY",+ "Secret Key",+ placeholder="sk-lf-...",+ secret=True,+ helper_text="Get keys from your Langfuse project settings",+ ),+ ConfigField(+ "langfuse_public_key",+ "LANGFUSE_PUBLIC_KEY",+ "Public Key",+ placeholder="pk-lf-...",+ secret=True,+ ),+ ConfigField(+ "langfuse_host",+ "LANGFUSE_HOST",+ "Host",+ placeholder="https://cloud.langfuse.com",+ helper_text="Leave empty for Langfuse Cloud, or set for self-hosted",+ ),+ ],+ gate_prompt="Configure Langfuse tracing?",+ ),# ── Storage ─────────────────────────────────────────────────- ConfigSection("Storage", [- ConfigField(- "openrag_documents_paths", "OPENRAG_DOCUMENTS_PATHS", "Documents Paths",- placeholder="~/.openrag/documents",- default="$HOME/.openrag/documents",- helper_text="Directories containing documents to ingest (comma-separated)",- ),- ]),-+ ConfigSection(+ "Storage",+ [+ ConfigField(+ "openrag_documents_paths",+ "OPENRAG_DOCUMENTS_PATHS",+ "Documents Paths",+ placeholder="~/.openrag/documents",+ default="$HOME/.openrag/documents",+ helper_text="Directories containing documents to ingest (comma-separated)",+ ),+ ],+ ),# ── Advanced ────────────────────────────────────────────────- ConfigSection("Advanced", [- ConfigField(- "webhook_base_url", "WEBHOOK_BASE_URL", "Webhook Base URL",- placeholder="https://your-domain.com",- helper_text="External URL for continuous ingestion webhooks",- ),- ], advanced=True),+ ConfigSection(+ "Advanced",+ [+ ConfigField(+ "webhook_base_url",+ "WEBHOOK_BASE_URL",+ "Webhook Base URL",+ placeholder="https://your-domain.com",+ helper_text="External URL for continuous ingestion webhooks",+ ),+ ],+ advanced=True,+ ),]@@ -289,7 +416,7 @@ def get_all_fields() -> list[ConfigField]:return [f for section in CONFIG_SECTIONS for f in section.fields]-def get_field(name: str) -> Optional[ConfigField]:+def get_field(name: str) -> ConfigField | None:"""Look up a config field by attribute name."""for f in get_all_fields():if f.name == name:diff --git a/src/tui/managers/container_manager.py b/src/tui/managers/container_manager.pyindex 321b096be..dfb3b75b4 100644--- a/src/tui/managers/container_manager.py+++ b/src/tui/managers/container_manager.py@@ -5,21 +5,23 @@ import jsonimport osimport reimport time+from collections.abc import AsyncIteratorfrom dataclasses import dataclass, fieldfrom enum import Enumfrom pathlib import Path-from typing import Dict, List, Optional, AsyncIterator++from utils.gpu_detection import detect_gpu_devicesfrom utils.logging_config import get_logger++from ..utils.platform import PlatformDetector, RuntimeInfo, RuntimeType+try:from importlib.resources import filesexcept ImportError:- from importlib_resources import files+ from importlib_resources import files # type: ignorelogger = get_logger(__name__)-from ..utils.platform import PlatformDetector, RuntimeInfo, RuntimeType-from utils.gpu_detection import detect_gpu_devices-class ServiceStatus(Enum):"""Container service status."""@@ -39,19 +41,19 @@ class ServiceInfo:name: strstatus: ServiceStatus- health: Optional[str] = None- ports: List[str] = field(default_factory=list)- image: Optional[str] = None- image_digest: Optional[str] = None- created: Optional[str] = None- error_message: Optional[str] = None+ health: str | None = None+ ports: list[str] = field(default_factory=list)+ image: str | None = None+ image_digest: str | None = None+ created: str | None = None+ error_message: str | None = Nonedef __post_init__(self):if self.ports is None:self.ports = []-def format_port_conflict_message(conflicts: List[tuple[str, int, str]], max_shown: int = 3) -> str:+def format_port_conflict_message(conflicts: list[tuple[str, int, str]], max_shown: int = 3) -> str:"""Format port conflicts into a user-facing error message."""shown = [f"{name} (port {port})" for name, port, _ in conflicts[:max_shown]]conflict_str = ", ".join(shown)@@ -61,11 +63,14 @@ def format_port_conflict_message(conflicts: List[tuple[str, int, str]], max_showmsg = f"Cannot start services: Port conflicts detected for {conflict_str}."configurable = any(- "frontend" in name.lower() or "langflow" in name.lower()+ "frontend" in name.lower()+ or "langflow" in name.lower()+ or "opensearch" in name.lower()+ or "dashboards" in name.lower()for name, _, _ in conflicts)if configurable:- msg += " You can set FRONTEND_PORT or LANGFLOW_PORT in your .env file to use different ports."+ msg += " You can set FRONTEND_PORT, LANGFLOW_PORT, OPENSEARCH_PORT, OPENSEARCH_DASHBOARDS_PORT, or OPENSEARCH_PERF_PORT in your .env file to use different ports."else:msg += " Please stop the conflicting services first."return msg@@ -85,13 +90,13 @@ class ContainerManager:"opensearchproject/opensearch-dashboards",}- def __init__(self, compose_file: Optional[Path] = None):+ def __init__(self, compose_file: Path | None = None):self.platform_detector = PlatformDetector()self.runtime_info = self.platform_detector.detect_runtime()self.compose_file = compose_file or self._find_compose_file("docker-compose.yml")self.gpu_compose_file = self._find_compose_file("docker-compose.gpu.yml")- self.services_cache: Dict[str, ServiceInfo] = {}- self.last_status_update = 0+ self.services_cache: dict[str, ServiceInfo] = {}+ self.last_status_update = 0.0# Auto-select GPU override if GPU is availabletry:has_gpu, _ = detect_gpu_devices()@@ -108,13 +113,17 @@ class ContainerManager:"langflow",]+ # Get compose project name from env or default to "openrag"+ env = self._get_env_from_file()+ project_name = env.get("COMPOSE_PROJECT_NAME", "openrag")+# Map container names to service namesself.container_name_map = {- "openrag-backend": "openrag-backend",- "openrag-frontend": "openrag-frontend",- "os": "opensearch",- "osdash": "dashboards",- "langflow": "langflow",+ f"{project_name}-backend": "openrag-backend",+ f"{project_name}-frontend": "openrag-frontend",+ f"{project_name}-opensearch": "opensearch",+ f"{project_name}-dashboards": "dashboards",+ f"{project_name}-langflow": "langflow",}@staticmethod@@ -125,25 +134,27 @@ class ContainerManager:def _is_openrag_repository(self, repository: str) -> bool:"""Check whether repository is OpenRAG-related, with optional registry prefix."""repo = repository.lower()- return any(repo == known or repo.endswith(f"/{known}") for known in self.OPENRAG_IMAGE_REPOS)+ return any(+ repo == known or repo.endswith(f"/{known}") for known in self.OPENRAG_IMAGE_REPOS+ )def _find_compose_file(self, filename: str) -> Path:"""Find compose file in centralized TUI directory, current directory, or package resources."""from utils.paths import get_tui_compose_file-+self._compose_search_log = f"Searching for {filename}:\n"-+# First check centralized TUI directory (~/.openrag/tui/)is_gpu = "gpu" in filenametui_path = get_tui_compose_file(gpu=is_gpu)self._compose_search_log += f" 1. TUI directory: {tui_path.absolute()}"-+if tui_path.exists():self._compose_search_log += " ✓ FOUND"return tui_pathelse:self._compose_search_log += " ✗ NOT FOUND"-+# Then check current working directory (for backward compatibility)cwd_path = Path(filename)self._compose_search_log += f"\n 2. Current directory: {cwd_path.absolute()}"@@ -155,21 +166,21 @@ class ContainerManager:self._compose_search_log += " ✗ NOT FOUND"# Finally check package resources- self._compose_search_log += f"\n 3. Package resources: "+ self._compose_search_log += "\n 3. Package resources: "try:pkg_files = files("tui._assets")self._compose_search_log += f"{pkg_files}"compose_resource = pkg_files / filenameif compose_resource.is_file():- self._compose_search_log += f" ✓ FOUND, copying to TUI directory"+ self._compose_search_log += " ✓ FOUND, copying to TUI directory"# Copy to TUI directorytui_path.parent.mkdir(parents=True, exist_ok=True)content = compose_resource.read_text()tui_path.write_text(content)return tui_pathelse:- self._compose_search_log += f" ✗ NOT FOUND"+ self._compose_search_log += " ✗ NOT FOUND"except Exception as e:self._compose_search_log += f" ✗ SKIPPED ({e})"# Don't log this as an error since it's expected when running from source@@ -178,24 +189,25 @@ class ContainerManager:self._compose_search_log += f"\n 4. Falling back to: {tui_path.absolute()}"return tui_path- def _get_env_from_file(self) -> Dict[str, str]:+ def _get_env_from_file(self) -> dict[str, str]:"""Read environment variables from .env file, prioritizing file values over os.environ.-+Uses python-dotenv's load_dotenv() for standard .env file parsing, which handles:- Quoted values (single and double quotes)- Variable expansion (${VAR})- Multiline values- Escaped characters- Comments-+This ensures Docker Compose commands use the latest values from .env file,even if os.environ has stale values."""from dotenv import load_dotenv+from utils.paths import get_tui_env_file-+env = dict(os.environ) # Start with current environment-+# Check centralized TUI .env location firsttui_env_file = get_tui_env_file()if tui_env_file.exists():@@ -203,7 +215,7 @@ class ContainerManager:else:# Fall back to CWD .env for backward compatibilityenv_file = Path(".env")-+if env_file.exists():try:# Load .env file with override=True to ensure file values take precedence@@ -214,13 +226,15 @@ class ContainerManager:logger.debug(f"Loaded environment from {env_file}")except Exception as e:logger.debug(f"Error reading .env file for Docker Compose: {e}")-+return envdef is_available(self) -> bool:"""Check if container runtime with compose is available."""- return (self.runtime_info.runtime_type != RuntimeType.NONE and- len(self.runtime_info.compose_command) > 0)+ return (+ self.runtime_info.runtime_type != RuntimeType.NONE+ and len(self.runtime_info.compose_command) > 0+ )def get_runtime_info(self) -> RuntimeInfo:"""Get container runtime information."""@@ -232,104 +246,109 @@ class ContainerManager:return self.platform_detector.get_compose_installation_instructions()return self.platform_detector.get_installation_instructions()- def _extract_ports_from_compose(self) -> Dict[str, List[int]]:+ def _extract_ports_from_compose(self) -> dict[str, list[int]]:"""Extract port mappings from compose files.-+Returns:Dict mapping service name to list of host ports"""- service_ports: Dict[str, List[int]] = {}-+ service_ports: dict[str, list[int]] = {}+compose_files = [self.compose_file]- if hasattr(self, 'cpu_compose_file') and self.cpu_compose_file and self.cpu_compose_file.exists():+ if (+ hasattr(self, "cpu_compose_file")+ and self.cpu_compose_file+ and self.cpu_compose_file.exists()+ ):compose_files.append(self.cpu_compose_file)-+for compose_file in compose_files:if not compose_file.exists():continue-+try:content = compose_file.read_text()current_service = Nonein_ports_section = False-+for line in content.splitlines():# Detect service names- service_match = re.match(r'^ (\w[\w-]*):$', line)+ service_match = re.match(r"^ (\w[\w-]*):$", line)if service_match:current_service = service_match.group(1)in_ports_section = Falseif current_service not in service_ports:service_ports[current_service] = []continue-+# Detect ports section- if current_service and re.match(r'^ ports:$', line):+ if current_service and re.match(r"^ ports:$", line):in_ports_section = Truecontinue-+# Exit ports section on new top-level key- if in_ports_section and re.match(r'^ \w+:', line):+ if in_ports_section and re.match(r"^ \w+:", line):in_ports_section = False-+# Extract port mappingsif in_ports_section and current_service:host_port = None# Match env var patterns like: - "${FRONTEND_PORT:-3000}:3000"- env_match = re.search(r'\$\{(\w+):-(\d+)\}:\d+', line)+ env_match = re.search(r"\$\{(\w+):-(\d+)\}:\d+", line)if env_match:var_name, default_port = env_match.group(1), env_match.group(2)- host_port = int(os.getenv(var_name, default_port))+ # Use centralized env resolution instead of os.getenv+ env = self._get_env_from_file()+ host_port = int(env.get(var_name, default_port))else:# Match literal patterns like: - "3000:3000", - 9200:9200port_match = re.search(r'["\']?(\d+):\d+["\']?', line)if port_match:host_port = int(port_match.group(1))- if host_port is not None and host_port not in service_ports[current_service]:+ if (+ host_port is not None+ and host_port not in service_ports[current_service]+ ):service_ports[current_service].append(host_port)-+except Exception as e:logger.debug(f"Error parsing {compose_file} for ports: {e}")continue-+return service_ports- async def check_ports_available(self) -> tuple[bool, List[tuple[str, int, str]]]:+ async def check_ports_available(self) -> tuple[bool, list[tuple[str, int, str]]]:"""Check if required ports are available.-+Returns:Tuple of (all_available, conflicts) where conflicts is a list of(service_name, port, error_message) tuples"""import socket-+service_ports = self._extract_ports_from_compose()- conflicts: List[tuple[str, int, str]] = []-+ conflicts: list[tuple[str, int, str]] = []+for service_name, ports in service_ports.items():for port in ports:try:# Try to bind to the port to check if it's availablesock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.settimeout(0.5)- result = sock.connect_ex(('127.0.0.1', port))+ result = sock.connect_ex(("127.0.0.1", port))sock.close()-+if result == 0:# Port is in use- conflicts.append((- service_name,- port,- f"Port {port} is already in use"- ))+ conflicts.append((service_name, port, f"Port {port} is already in use"))except Exception as e:logger.debug(f"Error checking port {port}: {e}")continue-+return (len(conflicts) == 0, conflicts)async def _run_compose_command(- self, args: List[str], cpu_mode: Optional[bool] = None+ self, args: list[str], cpu_mode: bool | None = None) -> tuple[bool, str, str]:"""Run a compose command and return (success, stdout, stderr)."""if not self.is_available():@@ -339,18 +358,19 @@ class ContainerManager:use_gpu = self.use_gpu_composeelse:use_gpu = not cpu_mode-+# Build compose command with override patterncmd = self.runtime_info.compose_command.copy()-+# Add --env-file to explicitly specify the .env locationfrom utils.paths import get_tui_env_file+tui_env_file = get_tui_env_file()if tui_env_file.exists():cmd.extend(["--env-file", str(tui_env_file)])elif Path(".env").exists():cmd.extend(["--env-file", ".env"])-+cmd.extend(["-f", str(self.compose_file)])if use_gpu and self.gpu_compose_file.exists():cmd.extend(["-f", str(self.gpu_compose_file)])@@ -359,7 +379,7 @@ class ContainerManager:try:# Get environment variables from .env file to ensure latest valuesenv = self._get_env_from_file()-+process = await asyncio.create_subprocess_exec(*cmd,stdout=asyncio.subprocess.PIPE,@@ -379,7 +399,7 @@ class ContainerManager:return False, "", f"Command execution failed: {e}"async def _run_compose_command_streaming(- self, args: List[str], cpu_mode: Optional[bool] = None+ self, args: list[str], cpu_mode: bool | None = None) -> AsyncIterator[tuple[str, bool]]:"""Run a compose command and yield output with progress bar support.@@ -395,18 +415,19 @@ class ContainerManager:use_gpu = self.use_gpu_composeelse:use_gpu = not cpu_mode-+# Build compose command with override patterncmd = self.runtime_info.compose_command.copy()-+# Add --env-file to explicitly specify the .env locationfrom utils.paths import get_tui_env_file+tui_env_file = get_tui_env_file()if tui_env_file.exists():cmd.extend(["--env-file", str(tui_env_file)])elif Path(".env").exists():cmd.extend(["--env-file", ".env"])-+cmd.extend(["-f", str(self.compose_file)])if use_gpu and self.gpu_compose_file.exists():cmd.extend(["-f", str(self.gpu_compose_file)])@@ -415,7 +436,7 @@ class ContainerManager:try:# Get environment variables from .env file to ensure latest valuesenv = self._get_env_from_file()-+process = await asyncio.create_subprocess_exec(*cmd,stdout=asyncio.subprocess.PIPE,@@ -441,12 +462,12 @@ class ContainerManager:if cr_pos != -1 and (nl_pos == -1 or cr_pos < nl_pos):line = buffer[:cr_pos]- buffer = buffer[cr_pos + 1:]+ buffer = buffer[cr_pos + 1 :]if line.strip():yield (line.strip(), True)elif nl_pos != -1:line = buffer[:nl_pos]- buffer = buffer[nl_pos + 1:]+ buffer = buffer[nl_pos + 1 :]if line.strip():yield (line.strip(), False)else:@@ -459,9 +480,9 @@ class ContainerManager:async def _stream_compose_command(self,- args: List[str],- success_flag: Dict[str, bool],- cpu_mode: Optional[bool] = None,+ args: list[str],+ success_flag: dict[str, bool],+ cpu_mode: bool | None = None,) -> AsyncIterator[tuple[str, bool]]:"""Run compose command with live output and record success/failure.@@ -478,18 +499,19 @@ class ContainerManager:use_gpu = self.use_gpu_composeelse:use_gpu = not cpu_mode-+# Build compose command with override patterncmd = self.runtime_info.compose_command.copy()-+# Add --env-file to explicitly specify the .env locationfrom utils.paths import get_tui_env_file+tui_env_file = get_tui_env_file()if tui_env_file.exists():cmd.extend(["--env-file", str(tui_env_file)])elif Path(".env").exists():cmd.extend(["--env-file", ".env"])-+cmd.extend(["-f", str(self.compose_file)])if use_gpu and self.gpu_compose_file.exists():cmd.extend(["-f", str(self.gpu_compose_file)])@@ -498,7 +520,7 @@ class ContainerManager:try:# Get environment variables from .env file to ensure latest valuesenv = self._get_env_from_file()-+process = await asyncio.create_subprocess_exec(*cmd,stdout=asyncio.subprocess.PIPE,@@ -535,13 +557,13 @@ class ContainerManager:if cr_pos != -1 and (nl_pos == -1 or cr_pos < nl_pos):# Carriage return found - extract and yield as replaceable lineline = buffer[:cr_pos]- buffer = buffer[cr_pos + 1:]+ buffer = buffer[cr_pos + 1 :]if line.strip():yield (line.strip(), True) # replace_last=True for progress updateselif nl_pos != -1:# Newline found - extract and yield as new lineline = buffer[:nl_pos]- buffer = buffer[nl_pos + 1:]+ buffer = buffer[nl_pos + 1 :]if line.strip():lowered = line.lower()yield (line.strip(), False) # replace_last=False for new lines@@ -555,7 +577,7 @@ class ContainerManager:success_flag["value"] = Falseyield (f"Command exited with status {returncode}", False)- async def _run_runtime_command(self, args: List[str]) -> tuple[bool, str, str]:+ async def _run_runtime_command(self, args: list[str]) -> tuple[bool, str, str]:"""Run a runtime command (docker/podman) and return (success, stdout, stderr)."""if not self.is_available():return False, "", "No container runtime available"@@ -579,7 +601,7 @@ class ContainerManager:async def _list_openrag_images(self, include_created: bool = False- ) -> tuple[bool, List[Dict[str, str]], str]:+ ) -> tuple[bool, list[dict[str, str]], str]:"""List OpenRAG-related images available in the container runtime."""format_parts = ["{{.Repository}}:{{.Tag}}", "{{.ID}}"]if include_created:@@ -591,7 +613,7 @@ class ContainerManager:if not success:return False, [], stderr- images: List[Dict[str, str]] = []+ images: list[dict[str, str]] = []for raw_line in stdout.strip().splitlines():if not raw_line.strip():continue@@ -622,9 +644,7 @@ class ContainerManager:return True, images, ""- def _process_service_json(- self, service: Dict, services: Dict[str, ServiceInfo]- ) -> None:+ def _process_service_json(self, service: dict, services: dict[str, ServiceInfo]) -> None:"""Process a service JSON object and add it to the services dict."""# Debug print to see the actual service datalogger.debug("Processing service data", service_data=service)@@ -653,9 +673,7 @@ class ContainerManager:# Extract portsports_str = service.get("Ports", "")- ports = (- [p.strip() for p in ports_str.split(",") if p.strip()] if ports_str else []- )+ ports = [p.strip() for p in ports_str.split(",") if p.strip()] if ports_str else []# Extract imageimage = service.get("Image", "N/A")@@ -668,57 +686,52 @@ class ContainerManager:image=image,)- async def get_container_version(self) -> Optional[str]:+ async def get_container_version(self) -> str | None:"""Get the version tag from existing containers.Checks the backend container image tag to determine version.-+Returns:Version string if found, None if no containers exist or version can't be determined"""try:# Check for backend container first (most reliable)+ env = self._get_env_from_file()+ project_name = env.get("COMPOSE_PROJECT_NAME", "openrag")success, stdout, _ = await self._run_runtime_command(- ["ps", "--all", "--filter", "name=openrag-backend", "--format", "{{.Image}}"]+ [+ "ps",+ "--all",+ "--filter",+ f"name={project_name}-backend",+ "--format",+ "{{.Image}}",+ ])-+if success and stdout.strip():image_tag = stdout.strip().splitlines()[0].strip()if not image_tag or image_tag == "N/A":return None-+# Extract version from image tag (e.g., langflowai/openrag-backend:0.1.47)if ":" in image_tag:version = image_tag.split(":")[-1]# If version is "latest", check .env file for OPENRAG_VERSIONif version == "latest":- # Try to get version from .env file- try:- from pathlib import Path- env_file = Path(".env")- if env_file.exists():- env_content = env_file.read_text()- for line in env_content.splitlines():- line = line.strip()- if line.startswith("OPENRAG_VERSION"):- env_version = line.split("=", 1)[1].strip()- # Remove quotes if present- env_version = env_version.strip("'\"")- if env_version and env_version != "latest":- return env_version- except Exception:- pass- # If still "latest", we can't determine version - return None+ env_version = env.get("OPENRAG_VERSION", "").strip().strip("'\"")+ if env_version and env_version != "latest":+ return env_versionreturn None# Return version if it looks like a version number (not "latest")if version and version != "latest":return version-+# Fallback: check all containers for version tagssuccess, stdout, _ = await self._run_runtime_command(["ps", "--all", "--format", "{{.Image}}"])-+if success and stdout.strip():images = stdout.strip().splitlines()for image in images:@@ -729,42 +742,41 @@ class ContainerManager:return versionexcept Exception as e:logger.debug(f"Error getting container version: {e}")-+return None- async def check_version_mismatch(self) -> tuple[bool, Optional[str], str]:+ async def check_version_mismatch(self) -> tuple[bool, str | None, str]:"""Check if existing containers have a different version than the current TUI.-+Returns:Tuple of (has_mismatch, container_version, tui_version)"""try:from ..utils.version_check import get_current_version-+tui_version = get_current_version()if tui_version == "unknown":return False, None, tui_version-+container_version = await self.get_container_version()-+if container_version is None:# No containers exist, no mismatchreturn False, None, tui_version-+# Compare versionsfrom ..utils.version_check import compare_versions+comparison = compare_versions(container_version, tui_version)has_mismatch = comparison != 0-+return has_mismatch, container_version, tui_versionexcept Exception as e:logger.debug(f"Error checking version mismatch: {e}")return False, None, "unknown"- async def get_service_status(- self, force_refresh: bool = False- ) -> Dict[str, ServiceInfo]:+ async def get_service_status(self, force_refresh: bool = False) -> dict[str, ServiceInfo]:"""Get current status of all services."""current_time = time.time()@@ -828,9 +840,7 @@ class ContainerManager:passelse:# For Docker, use compose ps command- success, stdout, stderr = await self._run_compose_command(- ["ps", "--format", "json"]- )+ success, stdout, stderr = await self._run_compose_command(["ps", "--format", "json"])if success and stdout.strip():try:@@ -849,9 +859,7 @@ class ContainerManager:except json.JSONDecodeError:# Fallback to parsing text outputlines = stdout.strip().split("\n")- if (- len(lines) > 1- ): # Make sure we have at least a header and one line+ if len(lines) > 1: # Make sure we have at least a header and one linefor line in lines[1:]: # Skip headerif line.strip():parts = line.split()@@ -871,25 +879,21 @@ class ContainerManager:else:status = ServiceStatus.UNKNOWN- services[name] = ServiceInfo(- name=name, status=status- )+ services[name] = ServiceInfo(name=name, status=status)# Add expected services that weren't foundfor expected in self.expected_services:if expected not in services:- services[expected] = ServiceInfo(- name=expected, status=ServiceStatus.MISSING- )+ services[expected] = ServiceInfo(name=expected, status=ServiceStatus.MISSING)self.services_cache = servicesself.last_status_update = current_timereturn services- async def get_images_digests(self, images: List[str]) -> Dict[str, str]:+ async def get_images_digests(self, images: list[str]) -> dict[str, str]:"""Return a map of image -> digest/ID (sha256:...)."""- digests: Dict[str, str] = {}+ digests: dict[str, str] = {}for image in images:if not image or image in digests:continue@@ -924,6 +928,7 @@ class ContainerManager:# Try YAML (if available) - import here to avoid hard dependencytry:import yaml+cfg = yaml.safe_load(text) or {}services = cfg.get("services", {})if isinstance(services, dict):@@ -942,7 +947,7 @@ class ContainerManager:async def _parse_compose_images(self) -> list[str]:"""Get resolved image names from compose files using docker/podman compose, with robust fallbacks."""from utils.paths import get_tui_env_file-+images: set[str] = set()# Try both GPU and CPU modes to get all images@@ -950,14 +955,14 @@ class ContainerManager:try:# Build compose command with override patterncmd = self.runtime_info.compose_command.copy()-+# Add --env-file to explicitly specify the .env locationtui_env_file = get_tui_env_file()if tui_env_file.exists():cmd.extend(["--env-file", str(tui_env_file)])elif Path(".env").exists():cmd.extend(["--env-file", ".env"])-+cmd.extend(["-f", str(self.compose_file)])if use_gpu and self.gpu_compose_file.exists():cmd.extend(["-f", str(self.gpu_compose_file)])@@ -973,21 +978,23 @@ class ContainerManager:stdout_text = stdout.decode() if stdout else ""if process.returncode == 0 and stdout_text.strip():- from_cfg = self._extract_images_from_compose_config(stdout_text, tried_json=True)+ from_cfg = self._extract_images_from_compose_config(+ stdout_text, tried_json=True+ )if from_cfg:images.update(from_cfg)continue# Fallback to YAML output (for older compose versions)cmd = self.runtime_info.compose_command.copy()-+# Add --env-file to explicitly specify the .env locationtui_env_file = get_tui_env_file()if tui_env_file.exists():cmd.extend(["--env-file", str(tui_env_file)])elif Path(".env").exists():cmd.extend(["--env-file", ".env"])-+cmd.extend(["-f", str(self.compose_file)])if use_gpu and self.gpu_compose_file.exists():cmd.extend(["-f", str(self.gpu_compose_file)])@@ -1003,7 +1010,9 @@ class ContainerManager:stdout_text = stdout.decode() if stdout else ""if process.returncode == 0 and stdout_text.strip():- from_cfg = self._extract_images_from_compose_config(stdout_text, tried_json=False)+ from_cfg = self._extract_images_from_compose_config(+ stdout_text, tried_json=False+ )if from_cfg:images.update(from_cfg)continue@@ -1017,7 +1026,7 @@ class ContainerManager:compose_files = [self.compose_file]if self.gpu_compose_file.exists():compose_files.append(self.gpu_compose_file)-+for compose in compose_files:try:if not compose.exists():@@ -1060,16 +1069,17 @@ class ContainerManager:return resultsasync def start_services(- self, cpu_mode: Optional[bool] = None- ) -> AsyncIterator[tuple[bool, str]]:+ self, cpu_mode: bool | None = None+ ) -> AsyncIterator[tuple[bool, str, bool]]:"""Start all services and yield progress updates."""if not self.is_available():- yield False, "No container runtime available"+ yield False, "No container runtime available", Falsereturn# Ensure OPENRAG_VERSION is set in .env filetry:from ..managers.env_manager import EnvManager+env_manager = EnvManager()env_manager.ensure_openrag_version()except Exception:@@ -1082,8 +1092,8 @@ class ContainerManager:use_gpu = not cpu_mode# Show the search process for debugging- if hasattr(self, '_compose_search_log'):- for line in self._compose_search_log.split('\n'):+ if hasattr(self, "_compose_search_log"):+ for line in self._compose_search_log.split("\n"):if line.strip():yield False, line, False@@ -1095,7 +1105,11 @@ class ContainerManager:compose_files_str += f" + {self.gpu_compose_file.absolute()}"yield False, f"Compose files: {compose_files_str}", Falseif not self.compose_file.exists():- yield False, f"ERROR: Base compose file not found at {self.compose_file.absolute()}", False+ yield (+ False,+ f"ERROR: Base compose file not found at {self.compose_file.absolute()}",+ False,+ )return# Check for port conflicts before starting@@ -1103,7 +1117,7 @@ class ContainerManager:ports_available, conflicts = await self.check_ports_available()if not ports_available:yield False, "ERROR: Port conflicts detected:", False- for service_name, port, error_msg in conflicts:+ for service_name, _port, error_msg in conflicts:yield False, f" - {service_name}: {error_msg}", Falseyield False, "", Falseyield False, format_port_conflict_message(conflicts), False@@ -1111,7 +1125,7 @@ class ContainerManager:yield False, "Starting OpenRAG services...", False- missing_images: List[str] = []+ missing_images: list[str] = []try:images_info = await self.get_project_images_info()missing_images = [image for image, digest in images_info if digest == "-"]@@ -1127,7 +1141,11 @@ class ContainerManager:):yield False, message, replace_lastif not pull_success["value"]:- yield False, "Some images failed to pull; attempting to start services anyway...", False+ yield (+ False,+ "Some images failed to pull; attempting to start services anyway...",+ False,+ )# Check if containers already exist (stopped or otherwise)# Use compose ps -q to check for any existing containers in the project@@ -1150,24 +1168,29 @@ class ContainerManager:up_success = {"value": True}error_messages = []- async for message, replace_last in self._stream_compose_command(compose_cmd, up_success, cpu_mode):+ async for message, replace_last in self._stream_compose_command(+ compose_cmd, up_success, cpu_mode+ ):# Detect error patterns in the outputlower_msg = message.lower()-+# Check for common error patterns- if any(pattern in lower_msg for pattern in [- "port.*already.*allocated",- "address already in use",- "bind.*address already in use",- "port is already allocated"- ]):+ if any(+ pattern in lower_msg+ for pattern in [+ "port.*already.*allocated",+ "address already in use",+ "bind.*address already in use",+ "port is already allocated",+ ]+ ):error_messages.append("Port conflict detected")up_success["value"] = Falseelif "error" in lower_msg or "failed" in lower_msg:# Generic error detectionif message not in error_messages:error_messages.append(message)-+yield False, message, replace_lastif up_success["value"]:@@ -1190,9 +1213,7 @@ class ContainerManager:else:yield False, f"Failed to stop services: {stderr}"- async def restart_services(- self, cpu_mode: bool = False- ) -> AsyncIterator[tuple[bool, str]]:+ async def restart_services(self, cpu_mode: bool = False) -> AsyncIterator[tuple[bool, str]]:"""Restart all services and yield progress updates."""yield False, "Restarting OpenRAG services..."@@ -1205,7 +1226,7 @@ class ContainerManager:async def upgrade_services(self, cpu_mode: bool = False- ) -> AsyncIterator[tuple[bool, str]]:+ ) -> AsyncIterator[tuple[bool, str, bool]]:"""Upgrade services (pull latest images and restart) and yield progress updates."""yield False, "Pulling latest images...", False@@ -1256,11 +1277,14 @@ class ContainerManager:# Use alpine container to delete files owned by container usercmd = [- "run", "--rm",- "-v", f"{path}:/work:Z",+ "run",+ "--rm",+ "-v",+ f"{path}:/work:Z","alpine",- "sh", "-c",- "rm -rf /work/* /work/.[!.]* 2>/dev/null; echo done"+ "sh",+ "-c",+ "rm -rf /work/* /work/.[!.]* 2>/dev/null; echo done",]success, stdout, stderr = await self._run_runtime_command(cmd)@@ -1281,15 +1305,26 @@ class ContainerManager:# The volume name is 'opensearch-data' as defined in docker-compose.yml.# Docker Compose usually prefixes it with the project name (defaulting to the directory name).volume_name = "opensearch-data"-- possible_names = list(dict.fromkeys([- volume_name,- f"{Path.cwd().name.lower()}_{volume_name}", # e.g. openrag_opensearch-data- f"{Path.cwd().name.lower().replace('-', '')}_{volume_name}", # e.g. openrag_opensearch-data (dashes stripped)- ]))++ # Get project name from env to include COMPOSE_PROJECT_NAME-derived prefix+ env = self._get_env_from_file()+ project_name = env.get("COMPOSE_PROJECT_NAME", "openrag")++ possible_names = list(+ dict.fromkeys(+ [+ volume_name,+ f"{project_name}_{volume_name}", # e.g. openrag_opensearch-data or custom_opensearch-data+ f"{Path.cwd().name.lower()}_{volume_name}", # e.g. openrag_opensearch-data+ f"{Path.cwd().name.lower().replace('-', '')}_{volume_name}", # e.g. openrag_opensearch-data (dashes stripped)+ ]+ )+ )# List volumes and find the correct one- list_success, stdout, _ = await self._run_runtime_command(["volume", "ls", "--format", "{{.Name}}"])+ list_success, stdout, _ = await self._run_runtime_command(+ ["volume", "ls", "--format", "{{.Name}}"]+ )if not list_success:yield False, "Could not list Docker volumes"return@@ -1302,8 +1337,16 @@ class ContainerManager:return# Only clear the volume we know exists- cmd = ["run", "--rm", "-v", f"{found_name}:/work:Z", "alpine", "sh", "-c",- "rm -rf /work/* /work/.[!.]* 2>/dev/null; echo done"]+ cmd = [+ "run",+ "--rm",+ "-v",+ f"{found_name}:/work:Z",+ "alpine",+ "sh",+ "-c",+ "rm -rf /work/* /work/.[!.]* 2>/dev/null; echo done",+ ]success, stdout, stderr = await self._run_runtime_command(cmd)if success and "done" in stdout:yield True, f"OpenSearch data volume '{found_name}' cleared successfully"@@ -1356,9 +1399,7 @@ class ContainerManager:f"System reset completed - removed {removed} OpenRAG image(s)",)- async def get_service_logs(- self, service_name: str, lines: int = 100- ) -> tuple[bool, str]:+ async def get_service_logs(self, service_name: str, lines: int = 100) -> tuple[bool, str]:"""Get logs for a specific service."""success, stdout, stderr = await self._run_compose_command(["logs", "--tail", str(lines), service_name]@@ -1384,7 +1425,7 @@ class ContainerManager:try:# Get environment variables from .env file to ensure latest valuesenv = self._get_env_from_file()-+process = await asyncio.create_subprocess_exec(*cmd,stdout=asyncio.subprocess.PIPE,@@ -1406,7 +1447,7 @@ class ContainerManager:except Exception as e:yield f"Error following logs: {e}"- async def get_system_stats(self) -> Dict[str, Dict[str, str]]:+ async def get_system_stats(self) -> dict[str, dict[str, str]]:"""Get system resource usage statistics."""stats = {}@@ -1480,20 +1521,18 @@ class ContainerManager:if self.runtime_info.runtime_type != RuntimeType.PODMAN:return True, "Not using Podman"- is_sufficient, memory_mb, message = (- self.platform_detector.check_podman_macos_memory()- )+ is_sufficient, memory_mb, message = self.platform_detector.check_podman_macos_memory()return is_sufficient, messageasync def prune_old_images(self) -> AsyncIterator[tuple[bool, str]]:"""Prune old OpenRAG images and dependencies, keeping only the latest versions.-+This method:1. Lists all images2. Identifies OpenRAG-related images (openrag-backend, openrag-frontend, langflow, opensearch, dashboards)3. For each repository, keeps only the latest/currently used image4. Removes old images-+Yields:Tuples of (success, message) for progress updates"""@@ -1508,7 +1547,7 @@ class ContainerManager:yield False, f"Failed to list images: {stderr}"return- images_by_repo = {}+ images_by_repo: dict[str, list[dict[str, str]]] = {}for image in images:repo = image["repo"]if repo not in images_by_repo:@@ -1558,9 +1597,7 @@ class ContainerManager:# Remove old imagesfor img in images_to_remove:yield False, f"Removing old image: {img['full_tag']}"- success, stdout, stderr = await self._run_runtime_command(- ["rmi", img["id"]]- )+ success, stdout, stderr = await self._run_runtime_command(["rmi", img["id"]])if success:total_removed += 1yield False, f" ✓ Removed {img['full_tag']}"@@ -1578,13 +1615,13 @@ class ContainerManager:async def prune_all_images(self) -> AsyncIterator[tuple[bool, str]]:"""Stop services and prune ALL OpenRAG images and dependencies.-+This is a more aggressive pruning that:1. Stops all running services2. Removes ALL OpenRAG-related images (not just old versions)-+This frees up maximum disk space but requires re-downloading images on next start.-+Yields:Tuples of (success, message) for progress updates"""@@ -1602,6 +1639,7 @@ class ContainerManager:# Give services time to fully stopimport asyncio+await asyncio.sleep(2)yield False, "Scanning for OpenRAG images..."diff --git a/src/tui/managers/docling_manager.py b/src/tui/managers/docling_manager.pyindex 73c61d85b..b8aa47892 100644--- a/src/tui/managers/docling_manager.py+++ b/src/tui/managers/docling_manager.py@@ -21,12 +21,12 @@ class DoclingManager:_instance = None_initialized = False- def __new__(cls):+ def __new__(cls) -> Any:if cls._instance is None:cls._instance = super().__new__(cls)return cls._instance- def __init__(self):+ def __init__(self) -> None:# Only initialize onceif self._initialized:return@@ -58,7 +58,7 @@ class DoclingManager:# Try to recover existing process from PID fileself._recover_from_pid_file()- def cleanup(self):+ def cleanup(self) -> None:"""Cleanup resources but keep docling-serve running across sessions."""# Don't stop the process on exit - let it persist# Just clean up our references@@ -295,6 +295,8 @@ class DoclingManager:cmd = ["uvx",+ "--python",+ "3.13","--from","docling-serve[ui]==1.20.0","--with",@@ -444,10 +446,10 @@ class DoclingManager:passreturn False, f"Error starting docling serve: {str(e)}"- def _start_output_capture(self):- """Start a thread to tail the docling-serve log file."""+ def _start_output_capture(self) -> None:+ """Start a thread to capture log file output."""- def tail_log_file():+ def tail_log_file() -> None:if not self._log_file_path.exists():self._add_log_entry("No log file available")returndiff --git a/src/tui/managers/env_manager.py b/src/tui/managers/env_manager.pyindex 7f13e66e1..21060f58f 100644--- a/src/tui/managers/env_manager.py+++ b/src/tui/managers/env_manager.py@@ -7,9 +7,9 @@ import stringfrom dataclasses import dataclass, fieldfrom datetime import datetimefrom pathlib import Path-from typing import Dict, List, Optionalfrom dotenv import load_dotenv+from utils.logging_config import get_loggerfrom ..utils.validation import (@@ -17,6 +17,7 @@ from ..utils.validation import (validate_google_oauth_client_id,validate_non_empty,validate_openai_api_key,+ validate_port,validate_url,)@@ -36,6 +37,10 @@ class EnvConfig:opensearch_username: str = "admin"opensearch_host: str = "opensearch"opensearch_port: str = "9200"+ opensearch_dashboards_port: str = "5601"+ opensearch_perf_port: str = "9600"+ compose_project_name: str = "openrag"+ langflow_port: str = "7860"opensearch_index_name: str = "documents"langflow_secret_key: str = ""langflow_superuser: str = "admin"@@ -104,20 +109,21 @@ class EnvConfig:openrag_version: str = ""# Validation errors- validation_errors: Dict[str, str] = field(default_factory=dict)+ validation_errors: dict[str, str] = field(default_factory=dict)class EnvManager:"""Manages environment configuration for OpenRAG."""assignment_pattern = re.compile(r"^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=")-- def __init__(self, env_file: Optional[Path] = None):++ def __init__(self, env_file: Path | None = None):if env_file:self.env_file = env_fileelse:# Use centralized location for TUI .env file- from utils.paths import get_tui_env_file, get_legacy_paths+ from utils.paths import get_legacy_paths, get_tui_env_file+self.env_file = get_tui_env_file()# Check for legacy .env in current directory and migrate if needed@@ -125,17 +131,17 @@ class EnvManager:if not self.env_file.exists() and legacy_env.exists():try:import shutil+self.env_file.parent.mkdir(parents=True, exist_ok=True)shutil.copy2(legacy_env, self.env_file)os.chmod(self.env_file, 0o600)logger.info(f"Migrated .env from {legacy_env} to {self.env_file}")-except Exception as e:logger.warning(f"Failed to migrate .env file: {e}")self.config = EnvConfig()-+def generate_secure_password(self) -> str:"""Generate a secure password for OpenSearch."""# Ensure at least one character from each category@@ -165,6 +171,7 @@ class EnvManager:def generate_openrag_encryption_key(self) -> str:"""Generate a secure AES-256 base64 master key for OpenRAG."""import base64+return base64.b64encode(secrets.token_bytes(32)).decode("ascii")def _quote_env_value(self, value: str) -> str:@@ -176,7 +183,7 @@ class EnvManager:escaped_value = value.replace("'", "'\\''")return f"'{escaped_value}'"- def _env_attr_map(self) -> Dict[str, str]:+ def _env_attr_map(self) -> dict[str, str]:"""Map env vars to EnvConfig attribute names."""return { # pragma: allowlist secret"OPENAI_API_KEY": "openai_api_key", # pragma: allowlist secret@@ -192,6 +199,10 @@ class EnvManager:"OPENSEARCH_USERNAME": "opensearch_username","OPENSEARCH_HOST": "opensearch_host","OPENSEARCH_PORT": "opensearch_port",+ "OPENSEARCH_DASHBOARDS_PORT": "opensearch_dashboards_port",+ "OPENSEARCH_PERF_PORT": "opensearch_perf_port",+ "COMPOSE_PROJECT_NAME": "compose_project_name",+ "LANGFLOW_PORT": "langflow_port","OPENSEARCH_INDEX_NAME": "opensearch_index_name","LANGFLOW_SECRET_KEY": "langflow_secret_key", # pragma: allowlist secret"LANGFLOW_SUPERUSER": "langflow_superuser",@@ -313,6 +324,7 @@ class EnvManager:if not self.config.openrag_version:try:from ..utils.version_check import get_current_version+current_version = get_current_version()if current_version != "unknown":self.config.openrag_version = current_version@@ -374,17 +386,36 @@ class EnvManager:# Validate documents paths only if provided (optional)if self.config.openrag_documents_paths:- is_valid, error_msg, _ = validate_documents_paths(- self.config.openrag_documents_paths- )+ is_valid, error_msg, _ = validate_documents_paths(self.config.openrag_documents_paths)if not is_valid:self.config.validation_errors["openrag_documents_paths"] = error_msg+ # Validate port settings+ if self.config.langflow_port and not validate_port(self.config.langflow_port):+ self.config.validation_errors["langflow_port"] = (+ "Invalid Langflow port (must be a number between 1 and 65535)"+ )++ if self.config.opensearch_port and not validate_port(self.config.opensearch_port):+ self.config.validation_errors["opensearch_port"] = (+ "Invalid OpenSearch port (must be a number between 1 and 65535)"+ )++ if self.config.opensearch_dashboards_port and not validate_port(+ self.config.opensearch_dashboards_port+ ):+ self.config.validation_errors["opensearch_dashboards_port"] = (+ "Invalid OpenSearch Dashboards port (must be a number between 1 and 65535)"+ )++ if self.config.opensearch_perf_port and not validate_port(self.config.opensearch_perf_port):+ self.config.validation_errors["opensearch_perf_port"] = (+ "Invalid OpenSearch performance port (must be a number between 1 and 65535)"+ )+# Validate required fieldsif not validate_non_empty(self.config.opensearch_password):- self.config.validation_errors["opensearch_password"] = (- "OpenSearch password is required"- )+ self.config.validation_errors["opensearch_password"] = "OpenSearch password is required"# Langflow secret key is auto-generated; no user input required@@ -392,11 +423,8 @@ class EnvManager:if mode == "full":# Validate OAuth settings if provided- if (+ if self.config.google_oauth_client_id and not validate_google_oauth_client_id(self.config.google_oauth_client_id- and not validate_google_oauth_client_id(- self.config.google_oauth_client_id- )):self.config.validation_errors["google_oauth_client_id"] = ("Invalid Google OAuth client ID format"@@ -417,12 +445,8 @@ class EnvManager:)# Validate optional URLs if provided- if self.config.webhook_base_url and not validate_url(- self.config.webhook_base_url- ):- self.config.validation_errors["webhook_base_url"] = (- "Invalid webhook URL format"- )+ if self.config.webhook_base_url and not validate_url(self.config.webhook_base_url):+ self.config.validation_errors["webhook_base_url"] = "Invalid webhook URL format"if self.config.langflow_public_url and not validate_url(self.config.langflow_public_url@@ -454,34 +478,70 @@ class EnvManager:# Core settingsf.write("# Core settings\n")- f.write(f"LANGFLOW_SECRET_KEY={self._quote_env_value(self.config.langflow_secret_key)}\n")+ f.write(+ f"LANGFLOW_SECRET_KEY={self._quote_env_value(self.config.langflow_secret_key)}\n"+ )# Only write LANGFLOW_SUPERUSER and password if password is setif self.config.langflow_superuser_password:- f.write(f"LANGFLOW_SUPERUSER={self._quote_env_value(self.config.langflow_superuser)}\n")+ f.write(+ f"LANGFLOW_SUPERUSER={self._quote_env_value(self.config.langflow_superuser)}\n"+ )f.write(f"LANGFLOW_SUPERUSER_PASSWORD={self._quote_env_value(self.config.langflow_superuser_password)}\n")- f.write(f"LANGFLOW_CHAT_FLOW_ID={self._quote_env_value(self.config.langflow_chat_flow_id)}\n")+ f.write(+ f"LANGFLOW_CHAT_FLOW_ID={self._quote_env_value(self.config.langflow_chat_flow_id)}\n"+ )f.write(f"LANGFLOW_INGEST_FLOW_ID={self._quote_env_value(self.config.langflow_ingest_flow_id)}\n")- f.write(f"LANGFLOW_URL_INGEST_FLOW_ID={self._quote_env_value(self.config.langflow_url_ingest_flow_id)}\n")+ f.write(+ f"LANGFLOW_URL_INGEST_FLOW_ID={self._quote_env_value(self.config.langflow_url_ingest_flow_id)}\n"+ )f.write(f"NUDGES_FLOW_ID={self._quote_env_value(self.config.nudges_flow_id)}\n")- f.write(f"OPENRAG_ENCRYPTION_KEY={self._quote_env_value(self.config.openrag_encryption_key)}\n")- f.write(f"OPENRAG_TENANT_ID={self._quote_env_value(self.config.openrag_tenant_id)}\n")- f.write(f"OPENRAG_ENFORCE_PREREQUISITES={self._quote_env_value(self.config.openrag_enforce_prerequisites)}\n")- f.write(f"OPENSEARCH_PASSWORD={self._quote_env_value(self.config.opensearch_password)}\n")+ f.write(+ f"OPENRAG_ENCRYPTION_KEY={self._quote_env_value(self.config.openrag_encryption_key)}\n"+ )+ f.write(+ f"OPENRAG_TENANT_ID={self._quote_env_value(self.config.openrag_tenant_id)}\n"+ )+ f.write(+ f"OPENRAG_ENFORCE_PREREQUISITES={self._quote_env_value(self.config.openrag_enforce_prerequisites)}\n"+ )+ f.write(+ f"OPENSEARCH_PASSWORD={self._quote_env_value(self.config.opensearch_password)}\n"+ )if self.config.opensearch_username and self.config.opensearch_username != "admin":- f.write(f"OPENSEARCH_USERNAME={self._quote_env_value(self.config.opensearch_username)}\n")+ f.write(+ f"OPENSEARCH_USERNAME={self._quote_env_value(self.config.opensearch_username)}\n"+ )if self.config.opensearch_host and self.config.opensearch_host != "opensearch":- f.write(f"OPENSEARCH_HOST={self._quote_env_value(self.config.opensearch_host)}\n")+ f.write(+ f"OPENSEARCH_HOST={self._quote_env_value(self.config.opensearch_host)}\n"+ )if self.config.opensearch_port and self.config.opensearch_port != "9200":- f.write(f"OPENSEARCH_PORT={self._quote_env_value(self.config.opensearch_port)}\n")- f.write(f"OPENSEARCH_INDEX_NAME={self._quote_env_value(self.config.opensearch_index_name)}\n")+ f.write(+ f"OPENSEARCH_PORT={self._quote_env_value(self.config.opensearch_port)}\n"+ )+ if (+ self.config.opensearch_dashboards_port+ and self.config.opensearch_dashboards_port != "5601"+ ):+ f.write(+ f"OPENSEARCH_DASHBOARDS_PORT={self._quote_env_value(self.config.opensearch_dashboards_port)}\n"+ )+ if self.config.opensearch_perf_port and self.config.opensearch_perf_port != "9600":+ f.write(+ f"OPENSEARCH_PERF_PORT={self._quote_env_value(self.config.opensearch_perf_port)}\n"+ )+ f.write(+ f"OPENSEARCH_INDEX_NAME={self._quote_env_value(self.config.opensearch_index_name)}\n"+ )# Expand $HOME in paths before writing to .env# This ensures paths work with all compose implementations (docker, podman)from utils.paths import expand_path+f.write(f"OPENRAG_DOCUMENTS_PATHS={self._quote_env_value(expand_path(self.config.openrag_documents_paths))}\n")@@ -507,18 +567,29 @@ class EnvManager:f.write(f"LANGFLOW_DATA_PATH={self._quote_env_value(expand_path(self.config.langflow_data_path))}\n")- # Set OPENRAG_VERSION to TUI version- if self.config.openrag_version:- f.write(f"OPENRAG_VERSION={self._quote_env_value(self.config.openrag_version)}\n")- else:- # Fallback: try to get current version+ # Write OPENRAG_VERSION once+ version_to_write = self.config.openrag_version+ if not version_to_write:try:from ..utils.version_check import get_current_version+current_version = get_current_version()if current_version != "unknown":- f.write(f"OPENRAG_VERSION={self._quote_env_value(current_version)}\n")+ version_to_write = current_versionexcept Exception:pass++ if version_to_write:+ f.write(f"OPENRAG_VERSION={self._quote_env_value(version_to_write)}\n")++ # Write COMPOSE_PROJECT_NAME only if non-default+ if (+ self.config.compose_project_name+ and self.config.compose_project_name != "openrag"+ ):+ f.write(+ f"COMPOSE_PROJECT_NAME={self._quote_env_value(self.config.compose_project_name)}\n"+ )f.write("\n")# Provider API keys and endpoints (optional - can be set during onboarding)@@ -544,13 +615,21 @@ class EnvManager:# Ingestion settingsf.write("# Ingestion settings\n")- f.write(f"DISABLE_INGEST_WITH_LANGFLOW={self._quote_env_value(self.config.disable_ingest_with_langflow)}\n")- f.write(f"INGEST_SAMPLE_DATA={self._quote_env_value(self.config.ingest_sample_data)}\n")+ f.write(+ f"DISABLE_INGEST_WITH_LANGFLOW={self._quote_env_value(self.config.disable_ingest_with_langflow)}\n"+ )+ f.write(+ f"INGEST_SAMPLE_DATA={self._quote_env_value(self.config.ingest_sample_data)}\n"+ )f.write("\n")# Langflow auth settingsf.write("# Langflow auth settings\n")- f.write(f"LANGFLOW_AUTO_LOGIN={self._quote_env_value(self.config.langflow_auto_login)}\n")+ f.write(+ f"LANGFLOW_AUTO_LOGIN={self._quote_env_value(self.config.langflow_auto_login)}\n"+ )+ if self.config.langflow_port and self.config.langflow_port != "7860":+ f.write(f"LANGFLOW_PORT={self._quote_env_value(self.config.langflow_port)}\n")f.write(f"LANGFLOW_NEW_USER_IS_ACTIVE={self._quote_env_value(self.config.langflow_new_user_is_active)}\n")@@ -560,10 +639,7 @@ class EnvManager:f.write("\n")# OAuth settings- if (- self.config.google_oauth_client_id- or self.config.google_oauth_client_secret- ):+ if self.config.google_oauth_client_id or self.config.google_oauth_client_secret:f.write("# Google OAuth settings\n")f.write(f"GOOGLE_OAUTH_CLIENT_ID={self._quote_env_value(self.config.google_oauth_client_id)}\n"@@ -646,7 +722,7 @@ class EnvManager:logger.error("Error saving .env file", error=str(e))return False- def get_no_auth_setup_fields(self) -> List[tuple[str, str, str, bool]]:+ def get_no_auth_setup_fields(self) -> list[tuple[str, str, str, bool]]:"""Get fields required for no-auth setup mode. Returns (field_name, display_name, placeholder, can_generate)."""return [("openai_api_key", "OpenAI API Key", "sk-... or leave empty", False),@@ -676,7 +752,7 @@ class EnvManager:),]- def get_full_setup_fields(self) -> List[tuple[str, str, str, bool]]:+ def get_full_setup_fields(self) -> list[tuple[str, str, str, bool]]:"""Get all fields for full setup mode."""base_fields = self.get_no_auth_setup_fields()@@ -747,6 +823,7 @@ class EnvManager:"""Ensure OPENRAG_VERSION is set in .env file to match TUI version."""try:from ..utils.version_check import get_current_version+current_version = get_current_version()if current_version == "unknown":return@@ -773,7 +850,9 @@ class EnvManager:for line in lines:if line.strip().startswith("OPENRAG_VERSION"):# Replace existing line- new_lines.append(f"OPENRAG_VERSION={self._quote_env_value(current_version)}")+ new_lines.append(+ f"OPENRAG_VERSION={self._quote_env_value(current_version)}"+ )updated = Trueelse:new_lines.append(line)@@ -785,19 +864,21 @@ class EnvManager:if "LANGFLOW_DATA_PATH" in line:insert_pos = i + 1break- new_lines.insert(insert_pos, f"OPENRAG_VERSION={self._quote_env_value(current_version)}")+ new_lines.insert(+ insert_pos, f"OPENRAG_VERSION={self._quote_env_value(current_version)}"+ )fd = os.open(self.env_file, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)# Ensure pre-existing files get restricted permissionsos.chmod(self.env_file, 0o600)- with os.fdopen(fd, 'w') as f:+ with os.fdopen(fd, "w") as f:f.write("\n".join(new_lines) + "\n")f.flush()os.fsync(f.fileno())else:# Create new .env file with just OPENRAG_VERSIONfd = os.open(self.env_file, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)- with os.fdopen(fd, 'w') as f:+ with os.fdopen(fd, "w") as f:content = (f"# OpenRAG Environment Configuration\n"f"# Generated by OpenRAG TUI\n\n"@@ -809,7 +890,7 @@ class EnvManager:except Exception as e:logger.error(f"Error ensuring OPENRAG_VERSION: {e}")- def generate_compose_volume_mounts(self) -> List[str]:+ def generate_compose_volume_mounts(self) -> list[str]:"""Generate Docker Compose volume mount strings from documents paths."""# Expand $HOME before validationpaths_str = self.config.openrag_documents_paths.replace("$HOME", str(Path.home()))diff --git a/src/tui/utils/validation.py b/src/tui/utils/validation.pyindex cdbeb8106..560e97760 100644--- a/src/tui/utils/validation.py+++ b/src/tui/utils/validation.py@@ -1,9 +1,7 @@"""Input validation utilities for TUI."""-import osimport refrom pathlib import Path-from typing import Optionalclass ValidationError(Exception):@@ -17,9 +15,7 @@ def validate_env_var_name(name: str) -> bool:return bool(re.match(r"^[A-Z][A-Z0-9_]*$", name))-def validate_path(- path: str, must_exist: bool = False, must_be_dir: bool = False-) -> bool:+def validate_path(path: str, must_exist: bool = False, must_be_dir: bool = False) -> bool:"""Validate file/directory path."""if not path:return False@@ -96,6 +92,26 @@ def validate_non_empty(value: str) -> bool:return bool(value and value.strip())+def validate_port(port_str: str) -> bool:+ """+ Validate port number format and range.++ Args:+ port_str: Port number as string++ Returns:+ True if port is valid (numeric and in range 1-65535), False otherwise+ """+ if not port_str:+ return False++ try:+ port = int(port_str)+ return 1 <= port <= 65535+ except (ValueError, TypeError):+ return False++def validate_documents_paths(paths_str: str) -> tuple[bool, str, list[str]]:"""Validate comma-separated documents paths for volume mounting.diff --git a/src/utils/env_utils.py b/src/utils/env_utils.pyindex 654861d38..15f00fc1a 100644--- a/src/utils/env_utils.py+++ b/src/utils/env_utils.py@@ -1,10 +1,12 @@"""Environment variable parsing utilities."""+import osfrom typing import Any, TypeVarT = TypeVar("T")-def safe_int(val: Any, default: int) -> int:++def safe_int(val: Any, default: int | None = None) -> int | None:"""Safely parse a value to an integer."""if val is None or val == "":return default@@ -13,7 +15,8 @@ def safe_int(val: Any, default: int) -> int:except (TypeError, ValueError):return default-def safe_float(val: Any, default: float) -> float:++def safe_float(val: Any, default: float | None = None) -> float | None:"""Safely parse a value to a float."""if val is None or val == "":return default@@ -22,10 +25,12 @@ def safe_float(val: Any, default: float) -> float:except (TypeError, ValueError):return default-def get_env_int(key: str, default: int) -> int:++def get_env_int(key: str, default: int | None = None) -> int | None:"""Get an environment variable as an integer."""return safe_int(os.getenv(key), default)-def get_env_float(key: str, default: float) -> float:++def get_env_float(key: str, default: float | None = None) -> float | None:"""Get an environment variable as a float."""return safe_float(os.getenv(key), default)diff --git a/src/utils/langflow_headers.py b/src/utils/langflow_headers.pyindex 21ba56383..ab8c4414c 100644--- a/src/utils/langflow_headers.py+++ b/src/utils/langflow_headers.py@@ -96,9 +96,10 @@ async def add_provider_credentials_to_headers(# Inject OpenSearch URL so Langflow flows always use the correct endpointfrom config.settings import LANGFLOW_OPENSEARCH_HOST, LANGFLOW_OPENSEARCH_PORT- headers["X-LANGFLOW-GLOBAL-VAR-OPENSEARCH_URL"] = (- f"https://{LANGFLOW_OPENSEARCH_HOST}:{LANGFLOW_OPENSEARCH_PORT}"- )+ if LANGFLOW_OPENSEARCH_HOST and LANGFLOW_OPENSEARCH_PORT:+ headers["X-LANGFLOW-GLOBAL-VAR-OPENSEARCH_URL"] = (+ f"https://{LANGFLOW_OPENSEARCH_HOST}:{LANGFLOW_OPENSEARCH_PORT}"+ )# IBM mode: inject OpenSearch Basic credentials as separate global varsfrom config.settings import IBM_AUTH_ENABLED