125 lines
3.2 KiB
Markdown
125 lines
3.2 KiB
Markdown
# Rezepte - Docker & Modern Stack
|
|
|
|
Dieses Repository enthält zwei Welten: den modernen Node.js / React Stack sowie die historische PHP Legacy-App. Über Docker Compose Profile kannst du gezielt nur die benötigten Teile starten.
|
|
|
|
## Services & Ports
|
|
|
|
| Service | Profil | Port Host -> Container | Beschreibung |
|
|
|--------------|-----------|------------------------|--------------|
|
|
| mysql | default | 3307 -> 3306 | MySQL 8 Datenbank |
|
|
| backend | default | 3001 -> 3001 | Node.js API (Express + Prisma) |
|
|
| frontend | default | 3000 -> 80 | React Build via nginx |
|
|
| php-app | legacy | 8082 -> 80 | Altes PHP Frontend |
|
|
| phpmyadmin | admin | 8083 -> 80 | DB Verwaltung |
|
|
|
|
## Node / Modern Stack
|
|
Empfohlene Node Version: **22.12.0** (`.nvmrc`, `.tool-versions`).
|
|
|
|
Lokal ohne Docker (Entwicklung Hot Reload):
|
|
```bash
|
|
nvm use
|
|
cd backend && npm install && npm run dev # startet API auf :3001
|
|
cd ../frontend && npm install && npm run dev # startet Vite auf :5173
|
|
```
|
|
|
|
## Docker Nutzung
|
|
|
|
### Standard (nur moderner Stack: DB + API + Frontend)
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
Öffnen: http://localhost:3000
|
|
|
|
### Mit Legacy PHP zusätzlich
|
|
```bash
|
|
docker compose --profile legacy up -d
|
|
```
|
|
Öffnen: http://localhost:8082
|
|
|
|
### Mit phpMyAdmin zusätzlich
|
|
```bash
|
|
docker compose --profile admin up -d
|
|
```
|
|
Öffnen: http://localhost:8083
|
|
|
|
### Beide Zusatz-Profile
|
|
```bash
|
|
docker compose --profile legacy --profile admin up -d
|
|
```
|
|
|
|
### Alles stoppen
|
|
```bash
|
|
docker compose down
|
|
```
|
|
|
|
### Neu bauen (z.B. nach Codeänderungen Backend/Frontend)
|
|
```bash
|
|
docker compose build backend frontend
|
|
docker compose up -d
|
|
```
|
|
|
|
### Nur Backend neu bauen
|
|
```bash
|
|
docker compose build backend && docker compose up -d backend
|
|
```
|
|
|
|
### Logs
|
|
```bash
|
|
docker compose logs -f backend
|
|
docker compose logs -f frontend
|
|
docker compose logs -f mysql
|
|
```
|
|
|
|
## CORS Hinweis
|
|
Aktuell ist `CORS_ORIGIN="*"` (Testphase). Für Produktion einschränken, z.B.:
|
|
```yaml
|
|
CORS_ORIGIN: http://esprimo:3000,http://localhost:3000
|
|
```
|
|
Danach Backend neu bauen.
|
|
|
|
## Datenbankzugang
|
|
|
|
## Datenbankzugang
|
|
|
|
### Für die Anwendung:
|
|
- Host: mysql
|
|
- Database: rezepte
|
|
- User: rezepte_user
|
|
- Password: rezepte_pass
|
|
|
|
### Für phpMyAdmin:
|
|
- Server: mysql
|
|
- Username: rezepte_user
|
|
- Password: rezepte_pass
|
|
|
|
### Root-Zugang:
|
|
- Username: root
|
|
- Password: rezepte123
|
|
|
|
## Entwicklung innerhalb Docker
|
|
|
|
Status:
|
|
```bash
|
|
docker compose ps
|
|
```
|
|
|
|
Direktes DB Login (Host hat mysql Client):
|
|
```bash
|
|
mysql -h 127.0.0.1 -P 3307 -u rezepte_user -p'rezepte_pass' rezepte
|
|
```
|
|
|
|
## Datenvolumes
|
|
|
|
Die MySQL-Daten werden in einem Docker-Volume gespeichert und bleiben auch nach dem Stoppen der Container erhalten.
|
|
|
|
## Datenbankinitialisierung
|
|
|
|
Beim ersten Start importiert MySQL automatisch SQL-Skripte aus `sql-init/`.
|
|
|
|
## Weiterführend
|
|
- Moderne Stack Doku: `NODEJS_README.md`
|
|
- Traefik / Registry Deploy: siehe entsprechende `*_SETUP.md` Dateien
|
|
- Sicherheitshärtung TODO: CORS einschränken, CSP Header, chown Migration verbessern
|
|
- Erweiterte Compose Overrides: siehe `legacy/README_COMPOSE_LEGACY.md`
|
|
- Beispiel Umgebungsvariablen: `.env.example`
|
|
- CI Build Tags: Branch, Semver, `sha-<short>`, Run-ID, `latest` (nur main) |