Skip to content

Commit e0a6960

Browse files
feat
1 parent d24de79 commit e0a6960

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ ENV DATA_DIR=/data
185185
ENV DATA_CACHE_DIR=$DATA_DIR/.sourcebot
186186
ENV DATABASE_DATA_DIR=$DATA_CACHE_DIR/db
187187
ENV REDIS_DATA_DIR=$DATA_CACHE_DIR/redis
188-
ENV DATABASE_URL="postgresql://postgres@localhost:5432/sourcebot"
189188
ENV REDIS_URL="redis://localhost:6379"
190189
ENV SRC_TENANT_ENFORCEMENT_MODE=strict
191190
ENV SOURCEBOT_PUBLIC_KEY_PATH=/app/public.pem

entrypoint.sh

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

4+
# Check if DATABASE_URL is not set
5+
if [ -z "$DATABASE_URL" ]; then
6+
# Check if the individual database variables are set and construct the URL
7+
if [ -n "$DATABASE_HOST" ] && [ -n "$DATABASE_USERNAME" ] && [ -n "$DATABASE_PASSWORD" ] && [ -n "$DATABASE_NAME" ]; then
8+
DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}"
9+
10+
if [ -n "$DATABASE_ARGS" ]; then
11+
DATABASE_URL="${DATABASE_URL}?$DATABASE_ARGS"
12+
fi
13+
14+
export DATABASE_URL
15+
else
16+
# Otherwise, fallback to a default value
17+
DATABASE_URL="postgresql://postgres@localhost:5432/sourcebot"
18+
export DATABASE_URL
19+
fi
20+
fi
21+
422
if [ "$DATABASE_URL" = "postgresql://postgres@localhost:5432/sourcebot" ]; then
523
DATABASE_EMBEDDED="true"
624
fi

0 commit comments

Comments
 (0)