Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: add separate db variables as alternative to connection string (#639)

Bernd Strehl1a3fcc0041fc
diff --git a/entrypoint.sh b/entrypoint.sh
index 3d9b918ebc..2d7745803d 100644
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -1,5 +1,18 @@
#!/bin/sh
+# Check if DATABASE_URL is not set
+if [ -z "$DATABASE_URL" ]; then
+ # Check if all required variables are provided
+ if [ -n "$DATABASE_HOST" ] && [ -n "$DATABASE_USERNAME" ] && [ -n "$DATABASE_PASSWORD" ] && [ -n "$DATABASE_NAME" ]; then
+ # Construct DATABASE_URL from the provided variables
+ DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}"
+ export DATABASE_URL
+ else
+ echo "Error: Required database environment variables are not set. Provide a postgres url for DATABASE_URL."
+ exit 1
+ fi
+fi
+
# Set DIRECT_URL to the value of DATABASE_URL, required for migrations
export DIRECT_URL=$DATABASE_URL