Update entrypoint.sh
Browse files- entrypoint.sh +9 -7
entrypoint.sh
CHANGED
|
@@ -32,7 +32,7 @@ if [ -z "$NANGO_ENCRYPTION_KEY" ]; then
|
|
| 32 |
echo "π Default encryption keys initialized."
|
| 33 |
fi
|
| 34 |
|
| 35 |
-
# 3. PARSE DATABASE_URL β
|
| 36 |
if [ -z "$DATABASE_URL" ]; then
|
| 37 |
echo "β DATABASE_URL not set."
|
| 38 |
exit 1
|
|
@@ -51,6 +51,7 @@ DB_HOST="${DB_HOSTPORT%%:*}"
|
|
| 51 |
DB_PORT="${DB_HOSTPORT##*:}"
|
| 52 |
[ "$DB_PORT" = "$DB_HOST" ] && DB_PORT="5432"
|
| 53 |
|
|
|
|
| 54 |
export NANGO_DB_USER="$DB_USER"
|
| 55 |
export NANGO_DB_PASSWORD="$DB_PASSWORD"
|
| 56 |
export NANGO_DB_HOST="$DB_HOST"
|
|
@@ -59,14 +60,15 @@ export NANGO_DB_NAME="$DB_NAME"
|
|
| 59 |
export NANGO_DB_SSL="true"
|
| 60 |
export NANGO_DB_SSL_REJECT_UNAUTHORIZED="false"
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
echo "ποΈ DB β $DB_HOST:$DB_PORT/$DB_NAME as $DB_USER"
|
| 63 |
|
| 64 |
-
# 4. PATCH
|
| 65 |
-
|
| 66 |
-
# so uuid_generate_v4() is invisible even if the
|
| 67 |
-
# extension exists. gen_random_uuid() is native
|
| 68 |
-
# Postgres 13+ β no extension, no search_path needed.
|
| 69 |
-
echo "π§ Patching Nango migrations: uuid_generate_v4 β gen_random_uuid..."
|
| 70 |
find /app/nango -type f \( -name "*.cjs" -o -name "*.js" -o -name "*.ts" \) \
|
| 71 |
-exec grep -l "uuid_generate_v4" {} \; | while IFS= read -r file; do
|
| 72 |
sed -i 's/uuid_generate_v4()/gen_random_uuid()/g' "$file"
|
|
|
|
| 32 |
echo "π Default encryption keys initialized."
|
| 33 |
fi
|
| 34 |
|
| 35 |
+
# 3. PARSE DATABASE_URL β ALL DB ENV VARS
|
| 36 |
if [ -z "$DATABASE_URL" ]; then
|
| 37 |
echo "β DATABASE_URL not set."
|
| 38 |
exit 1
|
|
|
|
| 51 |
DB_PORT="${DB_HOSTPORT##*:}"
|
| 52 |
[ "$DB_PORT" = "$DB_HOST" ] && DB_PORT="5432"
|
| 53 |
|
| 54 |
+
# Nango server package reads these
|
| 55 |
export NANGO_DB_USER="$DB_USER"
|
| 56 |
export NANGO_DB_PASSWORD="$DB_PASSWORD"
|
| 57 |
export NANGO_DB_HOST="$DB_HOST"
|
|
|
|
| 60 |
export NANGO_DB_SSL="true"
|
| 61 |
export NANGO_DB_SSL_REJECT_UNAUTHORIZED="false"
|
| 62 |
|
| 63 |
+
# records + keystore packages read DATABASE_URL directly
|
| 64 |
+
export DATABASE_URL="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}?sslmode=require"
|
| 65 |
+
export RECORDS_DATABASE_URL="$DATABASE_URL"
|
| 66 |
+
export KEYSTORE_DATABASE_URL="$DATABASE_URL"
|
| 67 |
+
|
| 68 |
echo "ποΈ DB β $DB_HOST:$DB_PORT/$DB_NAME as $DB_USER"
|
| 69 |
|
| 70 |
+
# 4. PATCH uuid_generate_v4 β gen_random_uuid IN MIGRATIONS
|
| 71 |
+
echo "π§ Patching Nango migrations..."
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
find /app/nango -type f \( -name "*.cjs" -o -name "*.js" -o -name "*.ts" \) \
|
| 73 |
-exec grep -l "uuid_generate_v4" {} \; | while IFS= read -r file; do
|
| 74 |
sed -i 's/uuid_generate_v4()/gen_random_uuid()/g' "$file"
|