docker-compose.dev.yml's mongodb service sets MONGO_INITDB_ROOT_USERNAME/ PASSWORD, which makes the official mongo image enable --auth — but the app service's MONGODB_URI was unauthenticated (mongodb://mongodb:27017/mozdit). Same bug class as MITHOME-32 (staging/production), but that ticket covers docker-compose.staging.yml /docker-compose.prod.yml specifically, not this dev file — hence the separate MITHOME-98. Why /api/health never caught it: that route is a pure liveness check and never touches MongoDB. Only an endpoint that actually performs a DB operation exercises the bug. Verified live (docker compose -f docker-compose.dev.yml up --build): - Reproduced the failure first: inside the running app container, a plain `mongodb://mongodb:27017/mozdit` connection's findOne() throws "Command find requires authentication" — confirms the hypothesis that the app fails only on a real query, not at startup. - With the fix in place: POST /api/contact returns 200 with a submissionId, and the document is actually present in contact_submissions (checked via mongosh) — a real, previously- broken write path now works end to end. - npm test: 58/58 passed (unaffected, as expected for a docker-compose/doc-only change). Also fixed the same stale unauthenticated example in DOCKER.md. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
147 lines
3.2 KiB
Markdown
Executable File
147 lines
3.2 KiB
Markdown
Executable File
# 🐳 Docker Fejlesztői Környezet
|
|
|
|
## Gyors Indítás
|
|
|
|
### Előfeltételek
|
|
- Docker és Docker Compose telepítve
|
|
- Git repository klónozva
|
|
|
|
### Teljes Stack Indítása
|
|
```bash
|
|
# Projekt gyökerében
|
|
docker-compose -f docker-compose.dev.yml up --build
|
|
|
|
# Vagy a proto könyvtárból
|
|
cd proto && npm run docker:dev
|
|
```
|
|
|
|
## 🚀 Szolgáltatások
|
|
|
|
A Docker stack a következő szolgáltatásokat indítja:
|
|
|
|
| Szolgáltatás | Port | URL | Leírás |
|
|
|--------------|------|-----|--------|
|
|
| **Next.js App** | 8080 | http://localhost:8080 | Fő alkalmazás |
|
|
| **MongoDB** | 27018 | mongodb://localhost:27018 | Adatbázis |
|
|
| **Mongo Express** | 8081 | http://localhost:8081 | MongoDB Web UI |
|
|
| **Loki** | 3100 | http://localhost:3100 | Log aggregátor |
|
|
| **Grafana** | 3001 | http://localhost:3001 | Monitoring dashboard |
|
|
|
|
### 🔐 Alapértelmezett Bejelentkezési Adatok
|
|
|
|
**MongoDB:**
|
|
- Username: `admin`
|
|
- Password: `password123`
|
|
|
|
**Grafana:**
|
|
- Username: `admin`
|
|
- Password: `admin123`
|
|
|
|
## 📊 MongoDB Hozzáférés
|
|
|
|
### 1. Mongo Express Web UI
|
|
- URL: http://localhost:8081
|
|
- Böngészőben egyszerűen elérhető
|
|
- Adatbázis: `mozdit`
|
|
|
|
### 2. MongoDB Shell (ha telepítve van)
|
|
```bash
|
|
# Kapcsolódás a containerhez
|
|
docker exec -it mozdit-mongodb-dev mongosh
|
|
|
|
# Vagy közvetlenül
|
|
mongosh "mongodb://admin:password123@localhost:27017/mozdit"
|
|
```
|
|
|
|
### 3. Alkalmazásból
|
|
Az alkalmazás automatikusan csatlakozik:
|
|
```
|
|
MONGODB_URI=mongodb://admin:password123@mongodb:27017/mozdit?authSource=admin
|
|
```
|
|
|
|
## 🛠️ Fejlesztési Parancsok
|
|
|
|
```bash
|
|
# Stack indítása (build-del)
|
|
npm run docker:dev
|
|
|
|
# Stack leállítása
|
|
npm run docker:dev:down
|
|
|
|
# Alkalmazás logok követése
|
|
npm run docker:dev:logs
|
|
|
|
# Egyedi Docker build
|
|
npm run docker:build
|
|
|
|
# Standalone container futtatása
|
|
npm run docker:run
|
|
```
|
|
|
|
## 📁 Adatok Perzisztencia
|
|
|
|
A következő Docker volume-ok tárolják az adatokat:
|
|
- `mongodb_data` - MongoDB adatok
|
|
- `loki_data` - Log adatok
|
|
- `grafana_data` - Grafana beállítások
|
|
|
|
Adatok törlése:
|
|
```bash
|
|
docker-compose -f docker-compose.dev.yml down -v
|
|
```
|
|
|
|
## 🔄 Hot Reload
|
|
|
|
A fejlesztői környezet támogatja a hot reload-ot:
|
|
- Kód változások automatikusan frissülnek
|
|
- MongoDB adatok megmaradnak restart után
|
|
- Volume mounting biztosítja a gyors fejlesztést
|
|
|
|
## 🚨 Hibaelhárítás
|
|
|
|
### Port foglaltság
|
|
Ha a 3000-es port foglalt:
|
|
```bash
|
|
# Meglévő process keresése
|
|
lsof -i :3000
|
|
|
|
# Vagy másik port használata
|
|
docker-compose -f docker-compose.dev.yml up --build -p 3002:3000
|
|
```
|
|
|
|
### MongoDB kapcsolat hiba
|
|
```bash
|
|
# Container logok ellenőrzése
|
|
docker logs mozdit-mongodb-dev
|
|
|
|
# Újraindítás
|
|
docker-compose -f docker-compose.dev.yml restart mongodb
|
|
```
|
|
|
|
### Teljes tisztítás
|
|
```bash
|
|
# Minden container és volume törlése
|
|
docker-compose -f docker-compose.dev.yml down -v --remove-orphans
|
|
docker system prune -a
|
|
```
|
|
|
|
## 🏗️ Production Build
|
|
|
|
```bash
|
|
# Production image build
|
|
docker build -t mozdit-app:latest ./proto
|
|
|
|
# Production futtatás
|
|
docker run -p 3000:3000 \
|
|
-e NODE_ENV=production \
|
|
-e MONGODB_URI=mongodb://your-prod-db:27017/mozdit \
|
|
mozdit-app:latest
|
|
```
|
|
|
|
## 📝 Megjegyzések
|
|
|
|
- A fejlesztői környezet **nem production-ready**
|
|
- Alapértelmezett jelszavak csak fejlesztésre
|
|
- SSL/TLS nincs konfigurálva
|
|
- Biztonsági headers minimálisak
|