From e0a6960807e527751b75671784156e75944dbb8f Mon Sep 17 00:00:00 2001 From: bkellam Date: Thu, 2 Oct 2025 12:37:18 -0700 Subject: [PATCH 1/3] feat --- Dockerfile | 1 - entrypoint.sh | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d04b2518a..010f59400 100644 --- a/Dockerfile +++ b/Dockerfile @@ -185,7 +185,6 @@ ENV DATA_DIR=/data ENV DATA_CACHE_DIR=$DATA_DIR/.sourcebot ENV DATABASE_DATA_DIR=$DATA_CACHE_DIR/db ENV REDIS_DATA_DIR=$DATA_CACHE_DIR/redis -ENV DATABASE_URL="postgresql://postgres@localhost:5432/sourcebot" ENV REDIS_URL="redis://localhost:6379" ENV SRC_TENANT_ENFORCEMENT_MODE=strict ENV SOURCEBOT_PUBLIC_KEY_PATH=/app/public.pem diff --git a/entrypoint.sh b/entrypoint.sh index 6753353fe..b031b326c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,24 @@ #!/bin/sh set -e +# Check if DATABASE_URL is not set +if [ -z "$DATABASE_URL" ]; then + # Check if the individual database variables are set and construct the URL + if [ -n "$DATABASE_HOST" ] && [ -n "$DATABASE_USERNAME" ] && [ -n "$DATABASE_PASSWORD" ] && [ -n "$DATABASE_NAME" ]; then + DATABASE_URL="postgresql://${DATABASE_USERNAME}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}" + + if [ -n "$DATABASE_ARGS" ]; then + DATABASE_URL="${DATABASE_URL}?$DATABASE_ARGS" + fi + + export DATABASE_URL + else + # Otherwise, fallback to a default value + DATABASE_URL="postgresql://postgres@localhost:5432/sourcebot" + export DATABASE_URL + fi +fi + if [ "$DATABASE_URL" = "postgresql://postgres@localhost:5432/sourcebot" ]; then DATABASE_EMBEDDED="true" fi From fad05715b3480813f0702406bac2cfd1100ae172 Mon Sep 17 00:00:00 2001 From: bkellam Date: Thu, 2 Oct 2025 12:39:35 -0700 Subject: [PATCH 2/3] docs --- docs/docs/configuration/environment-variables.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/configuration/environment-variables.mdx b/docs/docs/configuration/environment-variables.mdx index 70da72d8a..d49073fd3 100644 --- a/docs/docs/configuration/environment-variables.mdx +++ b/docs/docs/configuration/environment-variables.mdx @@ -19,7 +19,7 @@ The following environment variables allow you to configure your Sourcebot deploy | `DATA_CACHE_DIR` | `$DATA_DIR/.sourcebot` |

The root data directory in which all data written to disk by Sourcebot will be located.

| | `DATA_DIR` | `/data` |

The directory within the container to store all persistent data. Typically, this directory will be volume mapped such that data is persisted across container restarts (e.g., `docker run -v $(pwd):/data`)

| | `DATABASE_DATA_DIR` | `$DATA_CACHE_DIR/db` |

The data directory for the default Postgres database.

| -| `DATABASE_URL` | `postgresql://postgres@ localhost:5432/sourcebot` |

Connection string of your Postgres database. By default, a Postgres database is automatically provisioned at startup within the container.

If you'd like to use a non-default schema, you can provide it as a parameter in the database url

| +| `DATABASE_URL` | `postgresql://postgres@ localhost:5432/sourcebot` |

Connection string of your Postgres database. By default, a Postgres database is automatically provisioned at startup within the container.

If you'd like to use a non-default schema, you can provide it as a parameter in the database url.

You can also use `DATABASE_HOST`, `DATABASE_USERNAME`, `DATABASE_PASSWORD`, `DATABASE_NAME`, and `DATABASE_ARGS` to construct the database url.

| | `EMAIL_FROM_ADDRESS` | `-` |

The email address that transactional emails will be sent from. See [this doc](/docs/configuration/transactional-emails) for more info.

| | `FORCE_ENABLE_ANONYMOUS_ACCESS` | `false` |

When enabled, [anonymous access](/docs/configuration/auth/access-settings#anonymous-access) to the organization will always be enabled

| `REDIS_DATA_DIR` | `$DATA_CACHE_DIR/redis` |

The data directory for the default Redis instance.

| From 925bb87c73ecfa5665db743301c5cc43b5e72f22 Mon Sep 17 00:00:00 2001 From: bkellam Date: Thu, 2 Oct 2025 12:42:48 -0700 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dc51f5b6..89530b9e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Added support for passing db connection url as seperate `DATABASE_HOST`, `DATABASE_USERNAME`, `DATABASE_PASSWORD`, `DATABASE_NAME`, and `DATABASE_ARGS` env vars. [#545](https://github.com/sourcebot-dev/sourcebot/pull/545) + ## [4.7.3] - 2025-09-29 ### Fixed