# CI/CD Guide - Code & Deployment ## 🎯 **CĂ©l** A projekt CI/CD rendszere **Gitea Actions**-en fut (`git.mozdit.hu`), a deploy pedig **natĂ­v Docker Compose** (`deploy.sh`). Dokploy nem hasznĂĄlt. --- ## 🔄 **ArchitektĂșra** ### Pipeline Folyamat: ```mermaid graph TD A[Code Push] --> B[Gitea Actions] B --> C[Run Tests] B --> D[Build Docker Image] E[main push] --> F[ManuĂĄlis deploy a szerveren] F --> G[deploy.sh — docker compose up --build] H[Manual Trigger] --> B ``` ### Mit kezel a CI/CD: - ✅ **Test Execution** (unit, browser, docker integration) - ✅ **Docker Image** build ellenƑrzĂ©s (nincs registry push) - ✅ **Deployment** natĂ­v docker compose-szal (`deploy.sh`) - ✅ **Build Artifacts** Ă©s reporting --- ## 🐙 **Gitea Actions Workflow (`.gitea/workflows/ci.yml`)** ### Trigger Events: ```yaml on: push: branches: [main, develop] pull_request: branches: [main] ``` ### Job Sequence: - **đŸ§Ș Test Phase** — lint + unit + browser tesztek - **đŸ—ïž Build Phase** — production Docker image build (verifikĂĄciĂł, nem push) A `.github/workflows/ci.yml` (GitHub) hasonlĂł teszteket futtat, de **nincs deploy** lĂ©pĂ©se — a deploy mindig a szerveren törtĂ©nik. --- ## 🚀 **Deployment (natĂ­v docker compose)** ### Deploy a szerveren: ```bash # Staging ./deploy.sh staging # Production ./deploy.sh production ``` ### Mit csinĂĄl a `deploy.sh`: 1. `git pull origin main` 2. `.env.` fĂĄjl betöltĂ©se (kötelezƑ) 3. `docker compose --env-file .env. -f docker-compose.prod.yml up --build -d` 4. Healthcheck a `/api/health` endpointon (60s timeout, hiba esetĂ©n log dump) ### SzĂŒksĂ©ges fĂĄjlok a szerveren: ```bash # .env.production — production környezeti vĂĄltozĂłk MONGODB_URI=mongodb://admin:XXX@mongodb:27017/mozdit?authSource=admin MONGODB_DB=mozdit NEXT_PUBLIC_SITE_URL=https://mozdit.hu NEXT_PUBLIC_CONTACT_EMAIL=info@mozdit.hu LOKI_HOST=http://loki:3100 APP_PORT=8080 # .env.staging — staging vĂĄltozĂłk (hasonlĂłan) ``` > ⚠ A `.env.*` fĂĄjlok sosem kerĂŒlnek git-be — a szerveren kell lĂ©trehozni Ƒket. ### Reverse proxy / SSL: A `docker-compose.prod.yml` csak az app + MongoDB-t futtatja. A TLS/SSL Ă©s rate limit az infra szintƱ Nginx/caddy reverse proxy feladata (nem rĂ©sze a repĂłnak). --- ## 📊 **Monitoring** - **Logok**: `docker compose -f docker-compose.prod.yml logs -f app` - **Health**: `GET /api/health` → `{ success: true, data: {...} }` - **Winston + Loki**: alkalmazĂĄs logok (ha Loki elĂ©rhetƑ a stackben) --- ## 🔧 **KonfigurĂĄciĂł** ### Környezeti vĂĄltozĂłk (CI): ```yaml env: NODE_VERSION: '20' ``` ### Branch stratĂ©gia: - `main` → production (deploy: `./deploy.sh production`) - `develop` → staging (deploy: `./deploy.sh staging`) - `feature/*` → fejlesztƑi branch-ek --- ## đŸ› ïž **Local Development** ```bash # Tesztek futtatĂĄsa (ugyanaz, mint CI-ben) cd proto && npm run test:all # Docker build tesztelĂ©se lokĂĄlisan cd proto && npm run docker:build ``` --- ## 🔍 **Troubleshooting** #### 1. Deploy hiba — healthcheck nem OK ```bash ./deploy.sh production # hibaĂŒzenet + app logok dump docker compose -f docker-compose.prod.yml logs -f app ``` - EllenƑrizd a `.env.production` tartalmĂĄt - EllenƑrizd, hogy a MongoDB kontĂ©ner elĂ©rhetƑ-e - EllenƑrizd a lokĂĄlis teszteket: `cd proto && npm run test:all` #### 2. CI hiba - NĂ©zd meg a futĂĄst a Gitea Actions fĂŒlön: `https://git.mozdit.hu/si/websitedev/actions` - Helyi reprodukciĂł: `cd proto && npm run lint && npm run test:all` --- ## 🔗 **KapcsolĂłdĂł Dokumentumok** - [Plane Sync Guide](./PLANE-SYNC-GUIDE.md) - [Docker Setup](./DOCKER.md) - [Test Management](./TEST-MANAGEMENT.md) --- **UtolsĂł frissĂ­tĂ©s:** 2026-08-17 **StĂĄtusz:** Dokploy eltĂĄvolĂ­tva, natĂ­v docker compose + Gitea Actions