Skip to content

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

Python

fix: Factory reset results in a Backend start-up error: "Permission denied"

Mike Pawlowski6ab80364287a
diff --git a/Makefile b/Makefile
index ac37c4a9a..ad4da2496 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,13 @@ REPO ?= https://github.com/langflow-ai/langflow.git
# Auto-detect container runtime: prefer docker, fall back to podman
CONTAINER_RUNTIME := $(shell command -v docker >/dev/null 2>&1 && echo "docker" || echo "podman")
+
+# Host UID/GID — injected into docker-compose so openrag-backend runs as the
+# host user in all modes, keeping keys/ and config/ ownership consistent.
+# Named OPENRAG_UID/GID (not UID/GID) since UID is read-only in bash.
+export OPENRAG_UID := $(shell id -u)
+export OPENRAG_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
# Only pass --env-file if the file actually exists
ifneq (,$(wildcard $(ENV_FILE)))
@@ -74,7 +81,7 @@ endef
# PHONY TARGETS
######################
.PHONY: help check_tools help_docker help_dev help_test help_local help_utils \
- dev dev-cpu dev-local dev-local-cpu dev-local-build-lf dev-local-build-lf-cpu stop clean build logs \
+ dev dev-cpu dev-local dev-local-cpu dev-local-build-lf dev-local-build-lf-cpu ensure-rsa-keys stop clean build logs \
shell-backend shell-frontend install \
test test-unit test-integration test-ci test-ci-local test-sdk test-os-jwt lint \
backend frontend docling docling-stop install-be install-fe build-be build-fe build-os build-lf logs-be logs-fe logs-lf logs-os \
@@ -339,7 +346,17 @@ dev-cpu: ## Start full stack with CPU only
@echo " $(CYAN)OpenSearch:$(NC) http://localhost:9200"
@echo " $(CYAN)Dashboards:$(NC) http://localhost:5601"
-dev-local: ## Start infrastructure for local development
+ensure-rsa-keys: ## Generate RSA keys for JWT signing if absent, or fix permissions if present
+ @if [ ! -f keys/private_key.pem ]; then \
+ echo "$(YELLOW)Generating RSA keys for JWT signing...$(NC)"; \
+ uv run python -c "from src.main import generate_jwt_keys; generate_jwt_keys()"; \
+ else \
+ echo "$(CYAN)RSA keys already exist, ensuring correct permissions...$(NC)"; \
+ chmod 600 keys/private_key.pem 2>/dev/null || true; \
+ chmod 644 keys/public_key.pem 2>/dev/null || true; \
+ fi
+
+dev-local: ensure-rsa-keys ## 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 up -d opensearch openrag-backend dashboards langflow
@echo "$(PURPLE)Infrastructure started!$(NC)"
@@ -350,7 +367,7 @@ dev-local: ## Start infrastructure for local development
@echo ""
@echo "$(YELLOW)Now run 'make backend' and 'make frontend' in separate terminals$(NC)"
-dev-local-cpu: ## Start infrastructure for local development, with CPU only
+dev-local-cpu: ensure-rsa-keys ## Start infrastructure for local development, with CPU only
@echo "$(YELLOW)Starting infrastructure only (for local development)...$(NC)"
$(COMPOSE_CMD) up -d opensearch openrag-backend dashboards langflow
@echo "$(PURPLE)Infrastructure started!$(NC)"
@@ -361,7 +378,7 @@ dev-local-cpu: ## Start infrastructure for local development, with CPU only
@echo ""
@echo "$(YELLOW)Now run 'make backend' and 'make frontend' in separate terminals$(NC)"
-dev-local-build-lf: ## Start infrastructure for local development, building only Langflow image
+dev-local-build-lf: ensure-rsa-keys ## 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
@echo "$(YELLOW)Starting infrastructure only (for local development)...$(NC)"
@@ -374,7 +391,7 @@ dev-local-build-lf: ## Start infrastructure for local development, building only
@echo ""
@echo "$(YELLOW)Now run 'make backend' and 'make frontend' in separate terminals$(NC)"
-dev-local-build-lf-cpu: ## Start infrastructure for local development, building only Langflow image with CPU only
+dev-local-build-lf-cpu: ensure-rsa-keys ## Start infrastructure for local development, building only Langflow image with CPU only
@echo "$(YELLOW)Building Langflow image (CPU)...$(NC)"
$(COMPOSE_CMD) build langflow
@echo "$(YELLOW)Starting infrastructure only (for local development)...$(NC)"
@@ -669,18 +686,10 @@ test-integration: ## Run integration tests (requires infrastructure)
@echo "$(CYAN)Make sure to run 'make dev-local' first!$(NC)"
uv run pytest tests/integration/ -v
-test-ci: ## Start infra, run integration + SDK tests, tear down (uses DockerHub images)
+test-ci: ensure-rsa-keys ## Start infra, run integration + SDK tests, tear down (uses DockerHub images)
@set -e; \
echo "$(YELLOW)Installing test dependencies...$(NC)"; \
uv sync --group dev; \
- if [ ! -f keys/private_key.pem ]; then \
- echo "$(YELLOW)Generating RSA keys for JWT signing...$(NC)"; \
- uv run python -c "from src.main import generate_jwt_keys; generate_jwt_keys()"; \
- else \
- echo "$(CYAN)RSA keys already exist, ensuring correct permissions...$(NC)"; \
- chmod 600 keys/private_key.pem 2>/dev/null || true; \
- chmod 644 keys/public_key.pem 2>/dev/null || true; \
- fi; \
echo "$(YELLOW)Cleaning up old containers and volumes...$(NC)"; \
$(COMPOSE_CMD) down -v 2>/dev/null || true; \
echo "$(YELLOW)Pulling latest images...$(NC)"; \
@@ -784,18 +793,10 @@ test-ci: ## Start infra, run integration + SDK tests, tear down (uses DockerHub
$(COMPOSE_CMD) down -v 2>/dev/null || true; \
exit $$TEST_RESULT
-test-ci-local: ## Same as test-ci but builds all images locally
+test-ci-local: ensure-rsa-keys ## Same as test-ci but builds all images locally
@set -e; \
echo "$(YELLOW)Installing test dependencies...$(NC)"; \
uv sync --group dev; \
- if [ ! -f keys/private_key.pem ]; then \
- echo "$(YELLOW)Generating RSA keys for JWT signing...$(NC)"; \
- uv run python -c "from src.main import generate_jwt_keys; generate_jwt_keys()"; \
- else \
- echo "$(CYAN)RSA keys already exist, ensuring correct permissions...$(NC)"; \
- chmod 600 keys/private_key.pem 2>/dev/null || true; \
- chmod 644 keys/public_key.pem 2>/dev/null || true; \
- fi; \
echo "$(YELLOW)Cleaning up old containers and volumes...$(NC)"; \
$(COMPOSE_CMD) down -v 2>/dev/null || true; \
echo "$(YELLOW)Building all images locally...$(NC)"; \
diff --git a/docker-compose.yml b/docker-compose.yml
index 68e4206ba..d9a3218c6 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -49,6 +49,7 @@ services:
context: .
dockerfile: Dockerfile.backend
container_name: openrag-backend
+ user: "${OPENRAG_UID:-103000}:${OPENRAG_GID:-103000}"
depends_on:
- langflow
environment: