docker setup
# Conflicts: # .gitignore # backend/vite.config.js # frontend/package-lock.json
This commit is contained in:
parent
f01a0a967f
commit
c62234e1ca
546 changed files with 141382 additions and 757 deletions
296
DOCKER-SETUP.md
Normal file
296
DOCKER-SETUP.md
Normal file
|
|
@ -0,0 +1,296 @@
|
|||
# Docker Setup für Thats-Me Projekt
|
||||
|
||||
## Übersicht
|
||||
|
||||
Dieses Projekt verwendet Docker mit Laravel Sail für das Backend und einen Node-Container für die Quasar Frontend App.
|
||||
|
||||
### Services
|
||||
|
||||
- **laravel.test** - Laravel Backend (PHP 8.4)
|
||||
- **quasar.app** - Quasar Frontend App (Node 20)
|
||||
- **mysql** - MySQL 8.0 Database
|
||||
- **mailpit** - E-Mail Testing Tool
|
||||
- **redis** - Cache & Queue Service
|
||||
|
||||
### Domains
|
||||
|
||||
Das Setup konfiguriert 4 Domains über Traefik:
|
||||
|
||||
1. **thats-me.test** - Laravel Webseite/Landingpage
|
||||
2. **portal.thats-me.test** - Laravel Admin Panel
|
||||
3. **api.thats-me.test** - Laravel API für Quasar App
|
||||
4. **app.thats-me.test** - Quasar Frontend App
|
||||
|
||||
Zusätzlich:
|
||||
|
||||
- **assets.thats-me.test** - Vite Dev Server für Laravel Assets
|
||||
|
||||
## Voraussetzungen
|
||||
|
||||
1. **Docker Desktop** installiert
|
||||
2. **Traefik Proxy** muss als externes Netzwerk verfügbar sein:
|
||||
```bash
|
||||
docker network create proxy
|
||||
```
|
||||
3. **Laravel Sail** muss im Backend installiert sein:
|
||||
```bash
|
||||
cd backend
|
||||
composer require laravel/sail --dev
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
### 1. Environment Dateien einrichten
|
||||
|
||||
**Root .env Datei:**
|
||||
|
||||
```bash
|
||||
cp .env.docker .env
|
||||
```
|
||||
|
||||
**Backend .env Datei:**
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
```
|
||||
|
||||
Bearbeite `backend/.env` und stelle sicher, dass diese Einstellungen gesetzt sind:
|
||||
|
||||
```env
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=mysql
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=thats-me
|
||||
DB_USERNAME=sail
|
||||
DB_PASSWORD=password
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailpit
|
||||
MAIL_PORT=1025
|
||||
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
```
|
||||
|
||||
### 2. Hosts-Datei konfigurieren
|
||||
|
||||
Füge folgende Einträge zu deiner `/etc/hosts` Datei hinzu:
|
||||
|
||||
```
|
||||
127.0.0.1 thats-me.test
|
||||
127.0.0.1 portal.thats-me.test
|
||||
127.0.0.1 api.thats-me.test
|
||||
127.0.0.1 app.thats-me.test
|
||||
127.0.0.1 assets.thats-me.test
|
||||
```
|
||||
|
||||
### 3. Docker Container starten
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### 4. Laravel Installation abschließen
|
||||
|
||||
Beim ersten Start:
|
||||
|
||||
```bash
|
||||
# In den Laravel Container einsteigen
|
||||
docker-compose exec laravel.test bash
|
||||
|
||||
# Composer Dependencies installieren
|
||||
composer install
|
||||
|
||||
# Datenbank migrieren
|
||||
php artisan migrate
|
||||
|
||||
# Optional: Seeder ausführen
|
||||
php artisan db:seed
|
||||
```
|
||||
|
||||
### 5. Frontend Dependencies installieren
|
||||
|
||||
Der Quasar Container installiert automatisch die Dependencies beim Start.
|
||||
Falls manuell nötig:
|
||||
|
||||
```bash
|
||||
docker-compose exec quasar.app npm install
|
||||
```
|
||||
|
||||
## Verwendung
|
||||
|
||||
### Container starten
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Container stoppen
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
### Logs ansehen
|
||||
|
||||
```bash
|
||||
# Alle Services
|
||||
docker-compose logs -f
|
||||
|
||||
# Nur Laravel
|
||||
docker-compose logs -f laravel.test
|
||||
|
||||
# Nur Quasar
|
||||
docker-compose logs -f quasar.app
|
||||
```
|
||||
|
||||
### In Container einsteigen
|
||||
|
||||
**Laravel:**
|
||||
|
||||
```bash
|
||||
docker-compose exec laravel.test bash
|
||||
```
|
||||
|
||||
**Quasar:**
|
||||
|
||||
```bash
|
||||
docker-compose exec quasar.app sh
|
||||
```
|
||||
|
||||
**MySQL:**
|
||||
|
||||
```bash
|
||||
docker-compose exec mysql mysql -u sail -p
|
||||
# Passwort: password
|
||||
```
|
||||
|
||||
### Artisan Commands
|
||||
|
||||
```bash
|
||||
docker-compose exec laravel.test php artisan migrate
|
||||
docker-compose exec laravel.test php artisan cache:clear
|
||||
docker-compose exec laravel.test php artisan queue:work
|
||||
```
|
||||
|
||||
### NPM Commands (Frontend)
|
||||
|
||||
```bash
|
||||
docker-compose exec quasar.app npm run dev
|
||||
docker-compose exec quasar.app npm run build
|
||||
```
|
||||
|
||||
## Zugriff auf die Anwendung
|
||||
|
||||
### Mit Traefik (empfohlen)
|
||||
|
||||
- **Hauptwebseite:** https://thats-me.test
|
||||
- **Admin Portal:** https://portal.thats-me.test
|
||||
- **API:** https://api.thats-me.test
|
||||
- **Frontend App:** https://app.thats-me.test
|
||||
- **Vite Assets:** https://assets.thats-me.test
|
||||
|
||||
### Direkt über Ports
|
||||
|
||||
- **Laravel App:** http://localhost (Port 80 über Traefik)
|
||||
- **Vite Dev Server:** http://localhost:5179 (Host) → 5173 (Container)
|
||||
- **Quasar App:** http://localhost:9000
|
||||
- **Mailpit Dashboard:** http://localhost:8028
|
||||
- **MySQL:** localhost:33070
|
||||
- **Redis:** localhost:6383
|
||||
|
||||
## Vite Development Server
|
||||
|
||||
Um den Vite Dev Server für Laravel zu starten:
|
||||
|
||||
```bash
|
||||
docker-compose exec laravel.test npm install
|
||||
docker-compose exec laravel.test npm run dev
|
||||
```
|
||||
|
||||
Dann ist HMR (Hot Module Replacement) unter https://assets.thats-me.test verfügbar.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Proxy-Netzwerk existiert nicht
|
||||
|
||||
```bash
|
||||
docker network create proxy
|
||||
```
|
||||
|
||||
### Port-Konflikte
|
||||
|
||||
Ändere die Ports in der `.env` Datei:
|
||||
|
||||
```env
|
||||
FORWARD_DB_PORT=33071
|
||||
FORWARD_MAILPIT_DASHBOARD_PORT=8029
|
||||
QUASAR_PORT=9001
|
||||
VITE_PORT=5180
|
||||
```
|
||||
|
||||
### Permission-Probleme
|
||||
|
||||
```bash
|
||||
# User/Group IDs in .env anpassen
|
||||
WWWUSER=1000
|
||||
WWWGROUP=1000
|
||||
```
|
||||
|
||||
### Container neu bauen
|
||||
|
||||
```bash
|
||||
docker-compose down -v
|
||||
docker-compose build --no-cache
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Quasar startet nicht
|
||||
|
||||
```bash
|
||||
# Manuell im Container starten
|
||||
docker-compose exec quasar.app sh
|
||||
cd /app
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## Entwicklung ohne Traefik
|
||||
|
||||
Falls Sie kein Traefik haben, können Sie die Container auch direkt über Ports erreichen:
|
||||
|
||||
1. Entfernen Sie die `labels` Sektion aus `docker-compose.yml`
|
||||
2. Aktivieren Sie den Port-Mapping für Laravel:
|
||||
```yaml
|
||||
ports:
|
||||
- "${APP_PORT:-80}:80"
|
||||
- "${VITE_PORT:-5173}:5173"
|
||||
```
|
||||
3. Zugriff dann über:
|
||||
- Laravel: http://localhost
|
||||
- Vite: http://localhost:5173
|
||||
- Quasar: http://localhost:9000
|
||||
|
||||
## Nützliche Befehle
|
||||
|
||||
```bash
|
||||
# Container Status
|
||||
docker-compose ps
|
||||
|
||||
# Container neu starten
|
||||
docker-compose restart
|
||||
|
||||
# Bestimmten Service neu starten
|
||||
docker-compose restart laravel.test
|
||||
|
||||
# Container und Volumes löschen
|
||||
docker-compose down -v
|
||||
|
||||
# Logs von heute
|
||||
docker-compose logs --since 24h
|
||||
|
||||
# Ressourcen-Nutzung
|
||||
docker stats
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue