Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions self-hosted/docker-build/run_backend.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /bin/bash

# Set data directories
export DATA_DIR=${DATA_DIR:-/convex/data}
export TMPDIR=${TMPDIR:-"$DATA_DIR/tmp"}
export STORAGE_DIR=${STORAGE_DIR:-"$DATA_DIR/storage"}
Expand All @@ -8,17 +9,29 @@ export SQLITE_DB=${SQLITE_DB:-"$DATA_DIR/db.sqlite3"}
set -e
mkdir -p "$TMPDIR" "$STORAGE_DIR"

# Load credentials (if any)
source ./read_credentials.sh

# Determine database configuration
if [ -n "$DATABASE_URL" ]; then
# If DATABASE_URL is set, use Postgres
# If DATABASE_URL is set, use PostgreSQL
DB_SPEC="$DATABASE_URL"
DB_FLAGS=(--db postgres-v5)
DB_FLAGS=(--db postgres-v5 "$DB_SPEC")

# Add --do-not-require-ssl flag if POSTGRES_SSL is false
if [ "$POSTGRES_SSL" == "false" ]; then
DB_FLAGS+=("--do-not-require-ssl")
fi

# For PostgreSQL, we just pass the flags (without the DB_SPEC at the end)
DB_ARGS="${DB_FLAGS[@]}"
else
# Otherwise fallback to SQLite
# Otherwise, fallback to SQLite
DB_SPEC="$SQLITE_DB"
DB_FLAGS=()

# For SQLite, we pass both the flags and the DB_SPEC (connection string)
DB_ARGS="${DB_FLAGS[@]} $DB_SPEC"
fi

# --port and --site-proxy-port are internal to the container, so we pick them to
Expand All @@ -37,5 +50,4 @@ exec ./convex-local-backend "$@" \
--beacon-tag "self-hosted-docker" \
${DISABLE_BEACON:+--disable-beacon} \
${REDACT_LOGS_TO_CLIENT:+--redact-logs-to-client} \
"${DB_FLAGS[@]}" \
"$DB_SPEC"
$DB_ARGS