feat: add federation authority, provider, and relying party directories to Dockerfile; enhance entrypoint script for database normalization
This commit is contained in:
+18
-5
@@ -4,26 +4,39 @@ set -eu
|
||||
APP_DIR="$1"
|
||||
PORT="$2"
|
||||
DB_PATH="${DJANGO_DB_PATH:-$APP_DIR/db/db.sqlite3}"
|
||||
DUMP_SRC="$APP_DIR/dumps/example.json"
|
||||
LEGACY_DB_PATH="$APP_DIR/db.sqlite3"
|
||||
|
||||
cd "$APP_DIR"
|
||||
|
||||
mkdir -p logs static "$(dirname "$DB_PATH")"
|
||||
|
||||
if [ ! -f "$DB_PATH" ] && [ -f "$LEGACY_DB_PATH" ]; then
|
||||
mkdir -p "$(dirname "$DB_PATH")"
|
||||
cp "$LEGACY_DB_PATH" "$DB_PATH"
|
||||
fi
|
||||
|
||||
if [ ! -f "$DB_PATH" ] && [ "${LOAD_FIXTURE_ON_EMPTY_DB:-true}" = "true" ]; then
|
||||
TMP_DUMP="$(mktemp)"
|
||||
python /app/scripts/rewrite_dumps.py dumps/example.json "$TMP_DUMP"
|
||||
python manage.py migrate
|
||||
python manage.py loaddata "$TMP_DUMP"
|
||||
rm -f "$TMP_DUMP"
|
||||
if [ -f "$DUMP_SRC" ]; then
|
||||
TMP_DUMP="$(mktemp)"
|
||||
python /app/scripts/rewrite_dumps.py "$DUMP_SRC" "$TMP_DUMP"
|
||||
python manage.py loaddata "$TMP_DUMP"
|
||||
rm -f "$TMP_DUMP"
|
||||
fi
|
||||
else
|
||||
python manage.py migrate
|
||||
fi
|
||||
|
||||
python /app/scripts/normalize_db_urls.py "$DB_PATH"
|
||||
|
||||
# With DEBUG disabled Django no longer serves app static assets implicitly.
|
||||
# Collect them into STATIC_ROOT so the explicit /static/ URL can serve them.
|
||||
python manage.py collectstatic --noinput
|
||||
|
||||
if grep -aEq '127\.0\.0\.1|provider:8002' "$DB_PATH"; then
|
||||
if grep -aEq '127\.0\.0\.1|provider:8002' "$DB_PATH" \
|
||||
&& [ -n "${DJANGO_ALLOWED_HOSTS:-}" ] \
|
||||
&& [ "${DJANGO_ALLOWED_HOSTS:-*}" != "*" ]; then
|
||||
echo "Refusing to start: bootstrap data still contains internal/local URLs" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user