Remove static JSON files and seed step; migrate site settings to Postgres
All content (recipes + imprint/privacy settings) now lives exclusively in Postgres. The app no longer requires a seed step on first deploy. Changes: - helpers.php: load_site_settings() returns defaults when site_settings table is empty instead of throwing DatabaseUnavailableException; removes legacy JSONB migration path - data/recipes.json, data/site.json: deleted (content already in DB) - scripts/db-seed.php: deleted (no longer needed) - docker-compose.yml: remove RUN_DB_SEED env var and data/ volume mount - docker/entrypoint.sh: remove RUN_DB_SEED seed block - docs/COOLIFY.md: update deployment guide to reflect seedless workflow - .claude/launch.json: add dev server configurations for preview tool Fresh deploys now start with placeholder legal pages and an empty recipe list; the admin fills in real content via /admin.php without any CLI step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+17
-39
@@ -12,13 +12,12 @@ Zwei getrennte Ressourcen: **PostgreSQL** und **PHP-Web-App** (dieses Repo als D
|
||||
│ │ (Service B) │ :5432 │ Apache + PHP 8.3 │ │
|
||||
│ └──────────────┘ │ Port 80 → Traefik/HTTPS │ │
|
||||
│ ▲ └─────────────────────────┘ │
|
||||
│ │ ▲ │
|
||||
│ Volume (Daten) Volume optional: │
|
||||
│ data/ (site.json) │
|
||||
│ │ │
|
||||
│ Volume (Daten) │
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
Die App startet **nicht**, wenn `DATABASE_URL` fehlt oder Postgres nicht erreichbar ist.
|
||||
Die App startet **nicht**, wenn `DATABASE_URL` fehlt oder Postgres nicht erreichbar ist. Rezepte, Impressum und Datenschutz liegen komplett in Postgres.
|
||||
|
||||
---
|
||||
|
||||
@@ -65,25 +64,13 @@ postgresql://flixcooks:geheim@postgresql-flixcooks:5432/flixcooks
|
||||
### 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 |
|
||||
| ------------------- | ------- | ---------------------------------------------------------------------------- |
|
||||
| `DB_WAIT_MAX_TRIES` | `30` | Warteversuche bis Postgres da ist (à 2 s) |
|
||||
|
||||
### Persistent Storage
|
||||
|
||||
Nach dem ersten erfolgreichen Deploy: `RUN_DB_SEED` wieder auf `false` oder entfernen.
|
||||
|
||||
### Persistent Storage (empfohlen)
|
||||
|
||||
Mount für Impressum/Datenschutz (`data/site.json`):
|
||||
|
||||
|
||||
| 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.
|
||||
Nur PostgreSQL benötigt persistenten Speicher. Für die Web-App selbst ist kein `/var/www/html/data`-Volume mehr nötig, weil Rezepte und Site-Settings in Postgres liegen.
|
||||
|
||||
---
|
||||
|
||||
@@ -91,28 +78,21 @@ Rezepte liegen in Postgres – **kein** Volume für Rezepte nötig.
|
||||
|
||||
1. Postgres-Service läuft (healthy).
|
||||
2. App mit `DATABASE_URL` + `FLIXCOOKS_ADMIN_KEY` deployen.
|
||||
3. Einmalig `RUN_DB_SEED=true` → Redeploy → Rezepte prüfen auf der Startseite.
|
||||
4. `RUN_DB_SEED` deaktivieren.
|
||||
5. `https://deine-domain/admin.php` testen.
|
||||
6. `https://deine-domain/health.php` → `{"status":"ok"}`.
|
||||
3. `https://deine-domain/health.php` → `{"status":"ok"}`.
|
||||
4. `https://deine-domain/admin.php` → Rezepte anlegen, Impressum/Datenschutz unter „Site settings" befüllen.
|
||||
|
||||
### Schema ohne Seed
|
||||
|
||||
Tabellen legt der Container beim Start automatisch an (`scripts/schema.sql` via `require_database()`). Ohne Seed ist die DB leer → Seite lädt, aber keine Rezepte, bis du im Admin anlegst oder seedest.
|
||||
Tabellen legt der Container beim Start automatisch an (`scripts/schema.sql` via `require_database()`). Eine leere DB ist kein Fehler — die Site startet mit Platzhalter-Impressum/Datenschutz und zeigt eine leere Rezeptliste. Inhalte werden ausschließlich über `/admin.php` gepflegt.
|
||||
|
||||
---
|
||||
|
||||
## 4. Lokaler Test vor Coolify
|
||||
|
||||
```bash
|
||||
# Starkes Admin-Passwort setzen
|
||||
export FLIXCOOKS_ADMIN_KEY="dein-geheimes-passwort"
|
||||
|
||||
# Mit Seed
|
||||
export RUN_DB_SEED=true
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
|
||||
curl http://127.0.0.1:8080/health.php
|
||||
```
|
||||
|
||||
@@ -122,7 +102,6 @@ curl http://127.0.0.1:8080/health.php
|
||||
|
||||
- Neues Image bauen lassen (Git push → Coolify rebuild).
|
||||
- Postgres-Volume bleibt → Daten bleiben.
|
||||
- `data/`-Volume bleibt → Site-Settings bleiben.
|
||||
- Kein manuelles `db-seed` bei Updates, außer du leerst die DB bewusst.
|
||||
|
||||
---
|
||||
@@ -138,12 +117,11 @@ 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 | Rezepte über `/admin.php` anlegen, Site-Settings befüllen |
|
||||
| Admin geht nicht | `FLIXCOOKS_ADMIN_KEY` gesetzt? |
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user