Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Feat: Add the functionality to load environment variables from a .env file (#6331)

liwenju0ef7e96e486f3
diff --git a/docker/launch_backend_service.sh b/docker/launch_backend_service.sh
index 56f2d570f0..c2adb7e75e 100644
--- a/docker/launch_backend_service.sh
+++ b/docker/launch_backend_service.sh
@@ -3,6 +3,27 @@
# Exit immediately if a command exits with a non-zero status
set -e
+# Function to load environment variables from .env file
+load_env_file() {
+ # Get the directory of the current script
+ local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ local env_file="$script_dir/.env"
+
+ # Check if .env file exists
+ if [ -f "$env_file" ]; then
+ echo "Loading environment variables from: $env_file"
+ # Source the .env file
+ set -a
+ source "$env_file"
+ set +a
+ else
+ echo "Warning: .env file not found at: $env_file"
+ fi
+}
+
+# Load environment variables
+load_env_file
+
# Unset HTTP proxies that might be set by Docker daemon
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
export PYTHONPATH=$(pwd)