Enhance Docker entrypoint script with detailed logging for database connection attempts and schema application. Implement error handling for database checks and seeding process. Update documentation for environment variables and troubleshooting steps to improve clarity and usability.

This commit is contained in:
2026-05-23 12:59:36 +02:00
parent 054141020d
commit eff0aeb8c3
2 changed files with 107 additions and 24 deletions
+30 -21
View File
@@ -26,8 +26,8 @@ Die App startet **nicht**, wenn `DATABASE_URL` fehlt oder Postgres nicht erreich
1. Neues **Database** → PostgreSQL (16).
2. Notieren:
- Benutzer, Passwort, Datenbankname
- **Internal URL** (Host ist oft der Service-Name, z.B. `postgresql-xxxxx` oder was Coolify anzeigt)
- Benutzer, Passwort, Datenbankname
- **Internal URL** (Host ist oft der Service-Name, z.B. `postgresql-xxxxx` oder was Coolify anzeigt)
3. Format für die App:
```text
@@ -50,22 +50,26 @@ postgresql://flixcooks:geheim@postgresql-flixcooks:5432/flixcooks
2. Dockerfile-Pfad: `Dockerfile` (Root).
3. Port: **80** (Container exponiert Apache auf 80).
4. Health Check (optional, empfohlen):
- Path: `/health.php`
- Erwartet HTTP 200 mit `{"status":"ok"}`
- Path: `/health.php`
- Erwartet HTTP 200 mit `{"status":"ok"}`
### Environment Variables (Pflicht)
| Variable | Beschreibung |
|----------|----------------|
| `DATABASE_URL` | Interne Postgres-URL von Coolify |
| Variable | Beschreibung |
| --------------------- | --------------------------------- |
| `DATABASE_URL` | Interne Postgres-URL von Coolify |
| `FLIXCOOKS_ADMIN_KEY` | Starkes Passwort für `/admin.php` |
### Environment Variables (optional)
| Variable | Default | Beschreibung |
|----------|---------|----------------|
| `RUN_DB_SEED` | `false` | Einmalig `true` setzen → importiert `data/recipes.json` beim Start |
| `DB_WAIT_MAX_TRIES` | `30` | Warteversuche bis Postgres da ist (à 2 s) |
| Variable | Default | Beschreibung |
| ------------------- | ------- | ------------------------------------------------------------------ |
| `RUN_DB_SEED` | `false` | Einmalig `true` setzen → importiert `data/recipes.json` beim Start |
| `DB_WAIT_MAX_TRIES` | `30` | Warteversuche bis Postgres da ist (à 2 s) |
Nach dem ersten erfolgreichen Deploy: `RUN_DB_SEED` wieder auf `false` oder entfernen.
@@ -73,9 +77,11 @@ Nach dem ersten erfolgreichen Deploy: `RUN_DB_SEED` wieder auf `false` oder entf
Mount für Impressum/Datenschutz (`data/site.json`):
| Mount Path (Container) | Inhalt |
|------------------------|--------|
| `/var/www/html/data` | `site.json` bleibt nach Redeploy erhalten |
| Mount Path (Container) | Inhalt |
| ---------------------- | ----------------------------------------- |
| `/var/www/html/data` | `site.json` bleibt nach Redeploy erhalten |
Rezepte liegen in Postgres **kein** Volume für Rezepte nötig.
@@ -131,10 +137,13 @@ curl http://127.0.0.1:8080/health.php
## 7. Troubleshooting
| Problem | Lösung |
|---------|--------|
| Container startet nicht | Logs: DB nicht erreichbar → `DATABASE_URL` Host/Passwort prüfen |
| 503 „Datenbank nicht verfügbar“ | Gleiches Netzwerk in Coolify? Internal URL? |
| Leere Seite, Health OK | `RUN_DB_SEED=true` einmalig oder Admin-Rezepte anlegen |
| Admin geht nicht | `FLIXCOOKS_ADMIN_KEY` gesetzt? |
| `site.json` verloren nach Deploy | Volume auf `/var/www/html/data` mounten |
| Problem | Lösung |
| -------------------------------- | --------------------------------------------------------------- |
| Container startet nicht | Logs: DB nicht erreichbar → `DATABASE_URL` Host/Passwort prüfen |
| 503 „Datenbank nicht verfügbar“ | Gleiches Netzwerk in Coolify? Internal URL? |
| Leere Seite, Health OK | `RUN_DB_SEED=true` einmalig oder Admin-Rezepte anlegen |
| Admin geht nicht | `FLIXCOOKS_ADMIN_KEY` gesetzt? |
| `site.json` verloren nach Deploy | Volume auf `/var/www/html/data` mounten |