Files
flixcooks-website/docs/COOLIFY.md
T
smacksandClaude Sonnet 4.6 86fbd8e4bb 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>
2026-06-18 09:53:39 +02:00

128 lines
4.9 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# FlixCooks auf Coolify deployen
Zwei getrennte Ressourcen: **PostgreSQL** und **PHP-Web-App** (dieses Repo als Dockerfile).
## Architektur
```
┌──────────────────── Coolify Server ────────────────────┐
│ │
│ ┌──────────────┐ ┌─────────────────────────┐ │
│ │ PostgreSQL │◄────────│ FlixCooks (dieses Image) │ │
│ │ (Service B) │ :5432 │ Apache + PHP 8.3 │ │
│ └──────────────┘ │ Port 80 → Traefik/HTTPS │ │
│ ▲ └─────────────────────────┘ │
│ │ │
│ Volume (Daten) │
└─────────────────────────────────────────────────────────┘
```
Die App startet **nicht**, wenn `DATABASE_URL` fehlt oder Postgres nicht erreichbar ist. Rezepte, Impressum und Datenschutz liegen komplett in Postgres.
---
## 1. PostgreSQL in Coolify anlegen
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)
3. Format für die App:
```text
postgresql://USER:PASSWORD@HOST:5432/DATABASE
```
Beispiel (Platzhalter durch Coolify-Werte ersetzen):
```text
postgresql://flixcooks:geheim@postgresql-flixcooks:5432/flixcooks
```
**Wichtig:** In der App den **internen** Hostnamen verwenden (gleiches Coolify-Netzwerk), nicht `127.0.0.1`.
---
## 2. Web-App in Coolify anlegen
1. Neues **Application** → Build Pack: **Dockerfile** (Repository dieses Projekts).
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"}`
### Environment Variables (Pflicht)
| Variable | Beschreibung |
| --------------------- | --------------------------------- |
| `DATABASE_URL` | Interne Postgres-URL von Coolify |
| `FLIXCOOKS_ADMIN_KEY` | Starkes Passwort für `/admin.php` |
### Environment Variables (optional)
| Variable | Default | Beschreibung |
| ------------------- | ------- | ---------------------------------------------------------------------------- |
| `DB_WAIT_MAX_TRIES` | `30` | Warteversuche bis Postgres da ist (à 2 s) |
### Persistent Storage
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.
---
## 3. Erstes Deployment (Checkliste)
1. Postgres-Service läuft (healthy).
2. App mit `DATABASE_URL` + `FLIXCOOKS_ADMIN_KEY` deployen.
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()`). 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
export FLIXCOOKS_ADMIN_KEY="dein-geheimes-passwort"
docker compose build
docker compose up -d
curl http://127.0.0.1:8080/health.php
```
---
## 5. Updates / Redeploy
- Neues Image bauen lassen (Git push → Coolify rebuild).
- Postgres-Volume bleibt → Daten bleiben.
- Kein manuelles `db-seed` bei Updates, außer du leerst die DB bewusst.
---
## 6. Sicherheit
- `.env` wird **nicht** ins Image kopiert (`.dockerignore`).
- Admin-Key **nur** über `FLIXCOOKS_ADMIN_KEY` in Coolify setzen. Ohne diese Variable ist `/admin.php` deaktiviert.
- Postgres nicht öffentlich exponieren, wenn nicht nötig (nur interne URL).
---
## 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 | Rezepte über `/admin.php` anlegen, Site-Settings befüllen |
| Admin geht nicht | `FLIXCOOKS_ADMIN_KEY` gesetzt? |