Skip to content

Commit 220dcc3

Browse files
committed
Only create DB directory if using embedded DB
If an external database is being used there is no need to create the local database files. This prevents the database files from being created unless the embedded database is being used.
1 parent d67f0e5 commit 220dcc3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

entrypoint.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/sh
22
set -e
33

4+
if [ "$DATABASE_URL" = "postgresql://postgres@localhost:5432/sourcebot" ]; then
5+
DATABASE_EMBEDDED="true"
6+
fi
7+
48
echo -e "\e[34m[Info] Sourcebot version: $NEXT_PUBLIC_SOURCEBOT_VERSION\e[0m"
59

610
# If we don't have a PostHog key, then we need to disable telemetry.
@@ -30,7 +34,7 @@ if [ ! -d "$DATA_CACHE_DIR" ]; then
3034
fi
3135

3236
# Check if DATABASE_DATA_DIR exists, if not initialize it
33-
if [ ! -d "$DATABASE_DATA_DIR" ]; then
37+
if [ "$DATABASE_EMBEDDED" = "true" ] && [ ! -d "$DATABASE_DATA_DIR" ]; then
3438
echo -e "\e[34m[Info] Initializing database at $DATABASE_DATA_DIR...\e[0m"
3539
mkdir -p $DATABASE_DATA_DIR && chown -R postgres:postgres "$DATABASE_DATA_DIR"
3640
su postgres -c "initdb -D $DATABASE_DATA_DIR"
@@ -129,7 +133,7 @@ echo "{\"version\": \"$NEXT_PUBLIC_SOURCEBOT_VERSION\", \"install_id\": \"$SOURC
129133

130134

131135
# Start the database and wait for it to be ready before starting any other service
132-
if [ "$DATABASE_URL" = "postgresql://postgres@localhost:5432/sourcebot" ]; then
136+
if [ "$DATABASE_EMBEDDED" = "true" ]; then
133137
su postgres -c "postgres -D $DATABASE_DATA_DIR" &
134138
until pg_isready -h localhost -p 5432 -U postgres; do
135139
echo -e "\e[34m[Info] Waiting for the database to be ready...\e[0m"

0 commit comments

Comments
 (0)