feat: update database path configuration and improve entrypoint script for SQLite handling

This commit is contained in:
gabdevele
2026-06-17 19:42:57 +02:00 Unverified
parent b8554830e4
commit 85a821ff0f
10 changed files with 20 additions and 9 deletions
+1
View File
@@ -1,3 +1,4 @@
*/db.sqlite3
*/db/db.sqlite3
*/logs/
*/static/
+6
View File
@@ -72,6 +72,12 @@ curl -sS http://127.0.0.1:5555/api/v1/auth/cie/session/<state>
docker compose down -v
```
If the stack was started before June 17, 2026 DB path fix, also remove legacy SQLite files that were created outside named volumes:
```bash
rm -f federation_authority/db.sqlite3 provider/db.sqlite3 relying_party/db.sqlite3
```
## Logs
```bash
docker compose logs -f
+3
View File
@@ -9,6 +9,7 @@ services:
DJANGO_SECRET_KEY: ${FEDERATION_AUTHORITY_SECRET_KEY:-visione-cie-authority-local-dev}
DJANGO_ALLOWED_HOSTS: ${CIE_AUTH_ALLOWED_HOSTS:-*}
DJANGO_TRUST_ANCHOR: ${DJANGO_TRUST_ANCHOR:-http://federation-authority:8000}
DJANGO_DB_PATH: /app/federation_authority/db/db.sqlite3
LOAD_FIXTURE_ON_EMPTY_DB: ${FEDERATION_AUTHORITY_LOAD_FIXTURE_ON_EMPTY_DB:-true}
expose:
- "8000"
@@ -28,6 +29,7 @@ services:
DJANGO_ALLOWED_HOSTS: ${CIE_AUTH_ALLOWED_HOSTS:-*}
DJANGO_TRUST_ANCHOR: ${DJANGO_TRUST_ANCHOR:-http://federation-authority:8000}
DJANGO_PROVIDER_ISSUER: ${DJANGO_PROVIDER_ISSUER:-http://provider:8002/oidc/op}
DJANGO_DB_PATH: /app/provider/db/db.sqlite3
LOAD_FIXTURE_ON_EMPTY_DB: ${PROVIDER_LOAD_FIXTURE_ON_EMPTY_DB:-true}
expose:
- "8002"
@@ -53,6 +55,7 @@ services:
DJANGO_RP_SHARED_SECRET: ${DJANGO_RP_SHARED_SECRET:-change-me-for-local-dev}
DJANGO_RP_DEFAULT_PROVIDER: ${DJANGO_RP_DEFAULT_PROVIDER:-http://provider:8002/oidc/op}
DJANGO_RP_BASE_URL: ${DJANGO_RP_BASE_URL:-http://relying-party:8001}
DJANGO_DB_PATH: /app/relying_party/db/db.sqlite3
LOAD_FIXTURE_ON_EMPTY_DB: ${RELYING_PARTY_LOAD_FIXTURE_ON_EMPTY_DB:-true}
expose:
- "8001"
+4 -3
View File
@@ -3,12 +3,13 @@ set -eu
APP_DIR="$1"
PORT="$2"
DB_PATH="${DJANGO_DB_PATH:-$APP_DIR/db/db.sqlite3}"
cd "$APP_DIR"
mkdir -p logs static
mkdir -p logs static "$(dirname "$DB_PATH")"
if [ ! -f "$APP_DIR/db.sqlite3" ] && [ "${LOAD_FIXTURE_ON_EMPTY_DB:-true}" = "true" ]; then
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
@@ -22,7 +23,7 @@ fi
# 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' "$APP_DIR/db.sqlite3"; then
if grep -aEq '127\.0\.0\.1|provider:8002' "$DB_PATH"; then
echo "Refusing to start: bootstrap data still contains internal/local URLs" >&2
exit 1
fi
@@ -66,7 +66,7 @@ DJAGGER_DOCUMENT = {
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': os.getenv('DJANGO_DB_PATH', os.path.join(BASE_DIR, 'db', 'db.sqlite3')),
}
}
@@ -191,7 +191,7 @@ DATABASES = {
# },
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': os.getenv('DJANGO_DB_PATH', os.path.join(BASE_DIR, 'db', 'db.sqlite3')),
}
}
+1 -1
View File
@@ -70,7 +70,7 @@ DJAGGER_DOCUMENT = {
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': os.getenv('DJANGO_DB_PATH', os.path.join(BASE_DIR, 'db', 'db.sqlite3')),
}
}
+1 -1
View File
@@ -79,7 +79,7 @@ DATABASES = {
# },
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': os.getenv('DJANGO_DB_PATH', os.path.join(BASE_DIR, 'db', 'db.sqlite3')),
}
}
+1 -1
View File
@@ -76,7 +76,7 @@ DJAGGER_DOCUMENT = {
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': os.getenv('DJANGO_DB_PATH', os.path.join(BASE_DIR, 'db', 'db.sqlite3')),
}
}
@@ -81,7 +81,7 @@ DATABASES = {
# },
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': os.getenv('DJANGO_DB_PATH', os.path.join(BASE_DIR, 'db', 'db.sqlite3')),
}
}