Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

chore: Check required envs for make dev cmds (#2221)

Mike Fortmaneae874d61d69
diff --git a/Makefile b/Makefile
index a7f154f87..d773c6a07 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,10 @@ endif
hostname ?= 0.0.0.0
+# Environment variables that must be non-empty in .env for dev targets to work.
+# Add new vars here as they become required.
+REQUIRED_ENV_VARS := LANGFLOW_SUPERUSER LANGFLOW_SUPERUSER_PASSWORD OPENSEARCH_PASSWORD LANGFLOW_SECRET_KEY
+
# Default values for dev-branch builds (can be overridden via command line)
# Usage: make dev-branch BRANCH=test-openai-responses REPO=https://github.com/myorg/langflow.git
BRANCH ?= main
@@ -418,7 +422,74 @@ ensure-backend-volumes: ## Create and permission backend volume directories
@chmod 775 flows keys config data openrag-documents 2>/dev/null \
|| echo "$(YELLOW)Warning: Could not chmod backend volume directories.$(NC)"
-dev: ensure-langflow-data ensure-backend-volumes ## Start full stack with GPU support
+check-env: ## Verify required environment variables are set in .env
+ @missing=""; \
+ for var in $(REQUIRED_ENV_VARS); do \
+ val="$$(eval echo "\$$$$var")"; \
+ if [ -z "$$val" ]; then \
+ missing="$$missing $$var"; \
+ fi; \
+ done; \
+ if [ -n "$$missing" ]; then \
+ echo "$(RED)Error: the following required variables are missing or empty in $(ENV_FILE):$(NC)"; \
+ for var in $$missing; do \
+ echo " - $$var"; \
+ done; \
+ echo ""; \
+ echo "$(YELLOW)Set them in $(ENV_FILE) and try again.$(NC)"; \
+ echo "Tip: 'make generate-langflow-password' can auto-generate Langflow credentials."; \
+ exit 1; \
+ fi; \
+ pw="$${OPENSEARCH_PASSWORD}"; \
+ pw_errors=""; \
+ if [ $${#pw} -lt 8 ]; then \
+ pw_errors="$$pw_errors\n - at least 8 characters"; \
+ fi; \
+ if ! printf '%s' "$$pw" | grep -q '[A-Z]'; then \
+ pw_errors="$$pw_errors\n - at least one uppercase letter"; \
+ fi; \
+ if ! printf '%s' "$$pw" | grep -q '[a-z]'; then \
+ pw_errors="$$pw_errors\n - at least one lowercase letter"; \
+ fi; \
+ if ! printf '%s' "$$pw" | grep -q '[0-9]'; then \
+ pw_errors="$$pw_errors\n - at least one digit"; \
+ fi; \
+ if ! printf '%s' "$$pw" | grep -q '[^A-Za-z0-9]'; then \
+ pw_errors="$$pw_errors\n - at least one special character"; \
+ fi; \
+ if [ -n "$$pw_errors" ]; then \
+ echo "$(RED)Error: OPENSEARCH_PASSWORD does not meet the required policy:$(NC)"; \
+ printf "$$pw_errors\n"; \
+ echo ""; \
+ echo "$(YELLOW)Update OPENSEARCH_PASSWORD in $(ENV_FILE) and try again.$(NC)"; \
+ exit 1; \
+ fi
+
+generate-langflow-password: ## Auto-generate and append Langflow superuser credentials to .env
+ @PW=$$(openssl rand -base64 24 | tr -d '/+=' | head -c 24) || \
+ { echo "$(RED)Error: failed to generate password$(NC)"; exit 1; }; \
+ if [ -z "$$PW" ]; then \
+ echo "$(RED)Error: generated password is empty$(NC)"; exit 1; \
+ fi; \
+ if grep -q '^LANGFLOW_SUPERUSER=' "$(ENV_FILE)" 2>/dev/null; then \
+ sed -i.bak "s/^LANGFLOW_SUPERUSER=.*/LANGFLOW_SUPERUSER='admin'/" "$(ENV_FILE)" && rm -f "$(ENV_FILE).bak" || \
+ { rm -f "$(ENV_FILE).bak"; echo "$(RED)Error: failed to update LANGFLOW_SUPERUSER in $(ENV_FILE)$(NC)"; exit 1; }; \
+ else \
+ echo "LANGFLOW_SUPERUSER='admin'" >> "$(ENV_FILE)" || \
+ { echo "$(RED)Error: failed to append LANGFLOW_SUPERUSER to $(ENV_FILE)$(NC)"; exit 1; }; \
+ fi; \
+ if grep -q '^LANGFLOW_SUPERUSER_PASSWORD=' "$(ENV_FILE)" 2>/dev/null; then \
+ sed -i.bak "s/^LANGFLOW_SUPERUSER_PASSWORD=.*/LANGFLOW_SUPERUSER_PASSWORD='$$PW'/" "$(ENV_FILE)" && rm -f "$(ENV_FILE).bak" || \
+ { rm -f "$(ENV_FILE).bak"; echo "$(RED)Error: failed to update LANGFLOW_SUPERUSER_PASSWORD in $(ENV_FILE)$(NC)"; exit 1; }; \
+ else \
+ echo "LANGFLOW_SUPERUSER_PASSWORD='$$PW'" >> "$(ENV_FILE)" || \
+ { echo "$(RED)Error: failed to append LANGFLOW_SUPERUSER_PASSWORD to $(ENV_FILE)$(NC)"; exit 1; }; \
+ fi; \
+ echo "$(GREEN)Langflow superuser credentials written to $(ENV_FILE)$(NC)"; \
+ echo " LANGFLOW_SUPERUSER=admin"; \
+ echo " LANGFLOW_SUPERUSER_PASSWORD=$$PW"
+
+dev: ensure-langflow-data ensure-backend-volumes check-env ## Start full stack with GPU support
@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)"
@@ -428,7 +499,7 @@ dev: ensure-langflow-data ensure-backend-volumes ## Start full stack with GPU su
@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
+dev-cpu: ensure-langflow-data ensure-backend-volumes check-env ## Start full stack with CPU only
@echo "$(YELLOW)Starting OpenRAG with CPU only...$(NC)"
$(COMPOSE_CMD) up -d $(SERVICES)
@echo "$(PURPLE)Services started!$(NC)"
@@ -438,7 +509,7 @@ dev-cpu: ensure-langflow-data ensure-backend-volumes ## Start full stack with CP
@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
+dev-build: ensure-langflow-data ensure-backend-volumes check-env ## 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)"
@@ -450,7 +521,7 @@ dev-build: ensure-langflow-data ensure-backend-volumes ## Start full stack with
@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
+dev-build-cpu: ensure-langflow-data ensure-backend-volumes check-env ## 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)"
@@ -462,7 +533,7 @@ dev-build-cpu: ensure-langflow-data ensure-backend-volumes ## Start full stack w
@echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"
@echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"
-dev-local: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development
+dev-local: ensure-langflow-data ensure-backend-volumes check-env ## 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)"
@@ -474,7 +545,7 @@ dev-local: ensure-langflow-data ensure-backend-volumes ## Start infrastructure f
@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
+dev-local-cpu: ensure-langflow-data ensure-backend-volumes check-env ## 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)"
@@ -492,7 +563,7 @@ dev-local-cpu: ensure-langflow-data ensure-backend-volumes ## Start infrastructu
# Usage: make dev-branch BRANCH=test-openai-responses
# make dev-branch BRANCH=feature-x REPO=https://github.com/myorg/langflow.git
-dev-branch: ensure-langflow-data ensure-backend-volumes ## Build & run full stack with custom Langflow branch
+dev-branch: ensure-langflow-data ensure-backend-volumes check-env ## Build & run full stack with custom Langflow branch
@echo "$(YELLOW)Building Langflow from branch: $(BRANCH)$(NC)"
@echo " $(CYAN)Repository:$(NC) $(REPO)"
@echo ""
@@ -508,7 +579,7 @@ dev-branch: ensure-langflow-data ensure-backend-volumes ## Build & run full stac
@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
+dev-branch-cpu: ensure-langflow-data ensure-backend-volumes check-env ## Build & run full stack with custom Langflow branch and CPU only mode
@echo "$(YELLOW)Building Langflow from branch: $(BRANCH)$(NC)"
@echo " $(CYAN)Repository:$(NC) $(REPO)"
@echo ""
@@ -524,7 +595,7 @@ dev-branch-cpu: ensure-langflow-data ensure-backend-volumes ## Build & run full
@echo " $(CYAN)OpenSearch:$(NC) http://localhost:$${OPENSEARCH_PORT:-9200}"
@echo " $(CYAN)Dashboards:$(NC) http://localhost:$${OPENSEARCH_DASHBOARDS_PORT:-5601}"
-dev-branch-local: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development with custom Langflow branch
+dev-branch-local: ensure-langflow-data ensure-backend-volumes check-env ## Start infrastructure for local development with custom Langflow branch
@echo "$(YELLOW)Building Langflow from branch: $(BRANCH)$(NC)"
@echo " $(CYAN)Repository:$(NC) $(REPO)"
@echo ""
@@ -540,7 +611,7 @@ dev-branch-local: ensure-langflow-data ensure-backend-volumes ## Start infrastru
@echo ""
@echo "$(YELLOW)Now run 'make backend' and 'make frontend' in separate terminals$(NC)"
-dev-branch-local-cpu: ensure-langflow-data ensure-backend-volumes ## Start infrastructure for local development, with CPU only and custom Langflow branch
+dev-branch-local-cpu: ensure-langflow-data ensure-backend-volumes check-env ## Start infrastructure for local development, with CPU only and custom Langflow branch
@echo "$(YELLOW)Building Langflow from branch: $(BRANCH)$(NC)"
@echo " $(CYAN)Repository:$(NC) $(REPO)"
@echo ""
diff --git a/scripts/setup-e2e.sh b/scripts/setup-e2e.sh
index eba0e8785..a0dcd02a2 100644
--- a/scripts/setup-e2e.sh
+++ b/scripts/setup-e2e.sh
@@ -95,6 +95,20 @@ fi
mkdir -p langflow-data
chmod 777 langflow-data
+# Ensure LANGFLOW_SECRET_KEY is set (CI provides most vars via env, but not this one)
+if [ -z "${LANGFLOW_SECRET_KEY:-}" ]; then
+ LANGFLOW_SECRET_KEY=$(grep -E "^LANGFLOW_SECRET_KEY=" .env 2>/dev/null | cut -d= -f2- | tr -d "\"'")
+fi
+if [ -z "${LANGFLOW_SECRET_KEY:-}" ]; then
+ LANGFLOW_SECRET_KEY=$(openssl rand -base64 32)
+fi
+export LANGFLOW_SECRET_KEY
+if grep -q '^LANGFLOW_SECRET_KEY=' .env 2>/dev/null; then
+ sed -i.bak "s/^LANGFLOW_SECRET_KEY=.*/LANGFLOW_SECRET_KEY='${LANGFLOW_SECRET_KEY}'/" .env && rm -f .env.bak
+else
+ echo "LANGFLOW_SECRET_KEY='${LANGFLOW_SECRET_KEY}'" >> .env
+fi
+
# Start required services (CPU)
echo "Starting required services (CPU)..."
make dev-cpu SERVICES="opensearch langflow openrag-backend openrag-frontend"