diff --git a/backend/data/~$BIA.xlsx b/backend/data/~$BIA.xlsx deleted file mode 100644 index e6681ab..0000000 Binary files a/backend/data/~$BIA.xlsx and /dev/null differ diff --git a/docker-compose.prod.acr.yml b/docker-compose.prod.acr.yml new file mode 100644 index 0000000..527bfad --- /dev/null +++ b/docker-compose.prod.acr.yml @@ -0,0 +1,58 @@ +version: '3.8' + +services: + backend: + image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest + environment: + - NODE_ENV=production + - PORT=3001 + env_file: + - .env.production + volumes: + - backend_data:/app/data + restart: unless-stopped + networks: + - internal + healthcheck: + test: ["CMD", "node", "-e", "require('http').get('http://localhost:3001/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + frontend: + image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/frontend:latest + depends_on: + - backend + restart: unless-stopped + networks: + - internal + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"] + interval: 30s + timeout: 10s + retries: 3 + + nginx: + image: nginx:alpine + ports: + - "80:80" + - "443:443" + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./nginx/ssl:/etc/nginx/ssl:ro + - nginx_cache:/var/cache/nginx + depends_on: + - frontend + - backend + restart: unless-stopped + networks: + - internal + +volumes: + backend_data: + nginx_cache: + +networks: + internal: + driver: bridge diff --git a/docs/AZURE-ACR-DNL-SCOPE.md b/docs/AZURE-ACR-DNL-SCOPE.md new file mode 100644 index 0000000..e3870a4 --- /dev/null +++ b/docs/AZURE-ACR-DNL-SCOPE.md @@ -0,0 +1,207 @@ +# Azure Container Registry - Domain Name Label Scope + +## Wat is Domain Name Label Scope? + +**Domain Name Label (DNL) Scope** is een security feature van Azure Container Registry die voorkomt dat iemand anders dezelfde DNS naam kan gebruiken als je registry wordt verwijderd (subdomain takeover prevention). + +## Opties + +### 1. **Unsecure** (Aanbevolen voor simpele setup) ⭐ + +**DNS Format:** `registryname.azurecr.io` + +**Voorbeeld:** +- Registry naam: `zuyderlandcmdbacr` +- DNS naam: `zuyderlandcmdbacr.azurecr.io` + +**Voordelen:** +- ✅ Eenvoudig en voorspelbaar +- ✅ Geen hash in de naam +- ✅ Makkelijk te onthouden en configureren + +**Nadelen:** +- ❌ Minder security (maar meestal voldoende voor interne tools) + +**Wanneer gebruiken:** +- ✅ Simpele setup +- ✅ Interne/corporate omgeving +- ✅ Je wilt een voorspelbare DNS naam + +--- + +### 2. **Resource Group Reuse** (Aanbevolen voor security) 🔒 + +**DNS Format:** `registryname-hash.azurecr.io` + +**Voorbeeld:** +- Registry naam: `zuyderlandcmdbacr` +- DNS naam: `zuyderlandcmdbacr-abc123.azurecr.io` (met unieke hash) + +**Voordelen:** +- ✅ Extra security layer +- ✅ Consistent binnen resource group +- ✅ Voorkomt subdomain takeover + +**Nadelen:** +- ❌ Hash in de naam (minder voorspelbaar) +- ❌ Moet alle configuraties aanpassen met volledige DNS naam + +**Wanneer gebruiken:** +- ✅ Productie omgevingen +- ✅ Security is belangrijk +- ✅ Je wilt extra bescherming + +--- + +### 3. **Subscription Reuse** + +**DNS Format:** `registryname-hash.azurecr.io` (hash gebaseerd op subscription) + +**Wanneer gebruiken:** +- Als je meerdere resource groups hebt binnen dezelfde subscription +- Je wilt consistentie binnen de subscription + +--- + +### 4. **Tenant Reuse** + +**DNS Format:** `registryname-hash.azurecr.io` (hash gebaseerd op tenant) + +**Wanneer gebruiken:** +- Als je meerdere subscriptions hebt binnen dezelfde tenant +- Je wilt consistentie binnen de tenant + +--- + +### 5. **No Reuse** + +**DNS Format:** `registryname-uniquehash.azurecr.io` (altijd unieke hash) + +**Wanneer gebruiken:** +- Maximale security vereist +- Je wilt absoluut geen risico op DNS conflicts + +--- + +## 🎯 Aanbeveling voor Jouw Situatie + +**Voor Zuyderland CMDB GUI (20 gebruikers, corporate omgeving):** + +### Optie A: **"Unsecure"** (Aanbevolen) ⭐ + +**Waarom:** +- ✅ Eenvoudigste setup +- ✅ Voorspelbare DNS naam +- ✅ Geen configuratie wijzigingen nodig +- ✅ Voldoende voor interne corporate tool + +**DNS naam wordt:** `zuyderlandcmdbacr.azurecr.io` + +**Configuratie:** +```yaml +# azure-pipelines.yml +acrName: 'zuyderlandcmdbacr' # Simpel, zonder hash +``` + +--- + +### Optie B: **"Resource Group Reuse"** (Als je extra security wilt) 🔒 + +**Waarom:** +- ✅ Extra security layer +- ✅ Voorkomt subdomain takeover +- ✅ Consistent binnen resource group + +**DNS naam wordt:** `zuyderlandcmdbacr-abc123.azurecr.io` (met hash) + +**⚠️ Belangrijk:** Je moet dan alle configuraties aanpassen! + +**Configuratie wijzigingen nodig:** +```yaml +# azure-pipelines.yml +acrName: 'zuyderlandcmdbacr-abc123' # Met hash! +``` + +```yaml +# docker-compose.prod.acr.yml +image: zuyderlandcmdbacr-abc123.azurecr.io/zuyderland-cmdb-gui/backend:latest +``` + +```bash +# scripts/build-and-push-azure.sh +REGISTRY="zuyderlandcmdbacr-abc123.azurecr.io" # Met hash! +``` + +--- + +## ⚠️ Belangrijke Waarschuwingen + +### 1. **Permanente Keuze** +De DNL Scope keuze is **permanent** en kan **niet meer worden gewijzigd** na aanmaken van de registry! + +### 2. **Geen Streepjes in Registry Naam** +Als je een DNL Scope met hash gebruikt, mag je **geen streepjes (`-`)** gebruiken in de registry naam, omdat de hash zelf al een streepje gebruikt als scheidingsteken. + +**Goed:** `zuyderlandcmdbacr` +**Fout:** `zuyderland-cmdb-acr` (streepje conflict met hash) + +### 3. **Configuratie Aanpassingen** +Als je een hash gebruikt, moet je **alle configuraties aanpassen** met de volledige DNS naam (inclusief hash). + +--- + +## 📋 Checklist + +### Als je "Unsecure" kiest: +- [ ] Registry naam zonder streepjes (bijv. `zuyderlandcmdbacr`) +- [ ] DNS naam wordt: `zuyderlandcmdbacr.azurecr.io` +- [ ] Geen configuratie wijzigingen nodig +- [ ] Gebruik `acrName: 'zuyderlandcmdbacr'` in pipeline + +### Als je "Resource Group Reuse" kiest: +- [ ] Registry naam zonder streepjes (bijv. `zuyderlandcmdbacr`) +- [ ] Noteer de volledige DNS naam na aanmaken (met hash) +- [ ] Pas `azure-pipelines.yml` aan met volledige DNS naam +- [ ] Pas `docker-compose.prod.acr.yml` aan met volledige DNS naam +- [ ] Pas `scripts/build-and-push-azure.sh` aan met volledige DNS naam + +--- + +## 🔍 DNS Naam Vinden + +Na het aanmaken van de ACR, vind je de DNS naam: + +**Via Azure Portal:** +1. Ga naar je Container Registry +2. Klik op **"Overview"** +3. De **"Login server"** is je DNS naam + +**Via Azure CLI:** +```bash +az acr show --name zuyderlandcmdbacr --query loginServer -o tsv +``` + +**Output voorbeelden:** +- Unsecure: `zuyderlandcmdbacr.azurecr.io` +- Met hash: `zuyderlandcmdbacr-abc123.azurecr.io` + +--- + +## 💡 Mijn Aanbeveling + +**Voor jouw situatie (corporate tool, 20 gebruikers):** + +Kies **"Unsecure"** omdat: +1. ✅ Eenvoudigste setup +2. ✅ Geen configuratie wijzigingen nodig +3. ✅ Voldoende security voor interne tool +4. ✅ Voorspelbare DNS naam + +Als je later meer security nodig hebt, kun je altijd een nieuwe registry aanmaken met een andere scope (maar dan moet je wel alles migreren). + +--- + +## 📚 Meer Informatie + +- [Azure Container Registry DNL Scope Documentation](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal) +- [Subdomain Takeover Prevention](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-security) diff --git a/docs/AZURE-ACR-PERMISSIONS.md b/docs/AZURE-ACR-PERMISSIONS.md new file mode 100644 index 0000000..68dc134 --- /dev/null +++ b/docs/AZURE-ACR-PERMISSIONS.md @@ -0,0 +1,205 @@ +# Azure Container Registry - Role Assignment Permissions Mode + +## 🎯 Aanbeveling voor Jouw Situatie + +**Voor Zuyderland CMDB GUI (20 gebruikers, corporate tool, productie):** + +### ✅ **RBAC Registry Permissions** (Aanbevolen) ⭐ + +**Waarom:** +- ✅ Eenvoudiger te beheren +- ✅ Voldoende voor jouw use case +- ✅ Minder complexiteit +- ✅ Standaard keuze voor de meeste scenario's + +--- + +## 📊 Opties Vergelijking + +### Optie 1: **RBAC Registry Permissions** ⭐ **AANBEVOLEN** + +**Hoe het werkt:** +- Permissions worden ingesteld op **registry niveau** +- Alle repositories binnen de registry delen dezelfde permissions +- Gebruikers hebben toegang tot alle repositories of geen + +**Voordelen:** +- ✅ **Eenvoudig** - Minder complexiteit +- ✅ **Makkelijk te beheren** - Eén set permissions voor de hele registry +- ✅ **Voldoende voor de meeste scenario's** - Perfect voor jouw situatie +- ✅ **Standaard keuze** - Meest gebruikte optie + +**Nadelen:** +- ❌ Minder flexibel - Kan niet per repository permissions instellen +- ❌ Alle repositories hebben dezelfde toegang + +**Wanneer gebruiken:** +- ✅ **Jouw situatie** - 20 gebruikers, corporate tool +- ✅ Kleine tot middelgrote teams +- ✅ Alle repositories hebben dezelfde toegangsvereisten +- ✅ Eenvoudige permission structuur gewenst + +**Voorbeeld:** +- Alle developers hebben toegang tot alle repositories +- Alle CI/CD pipelines hebben toegang tot alle repositories +- Geen per-repository verschillen nodig + +--- + +### Optie 2: **RBAC Registry + ABAC Repository Permissions** + +**Hoe het werkt:** +- Permissions op **registry niveau** (RBAC) +- **Extra** permissions op **repository niveau** (ABAC - Attribute-Based Access Control) +- Kan per repository verschillende permissions instellen + +**Voordelen:** +- ✅ **Flexibeler** - Per repository permissions mogelijk +- ✅ **Granular control** - Verschillende teams kunnen verschillende repositories hebben +- ✅ **Enterprise features** - Voor complexe organisaties + +**Nadelen:** +- ❌ **Complexer** - Meer configuratie nodig +- ❌ **Moeilijker te beheren** - Meerdere permission levels +- ❌ **Meer overhead** - Meer tijd nodig voor setup en onderhoud + +**Wanneer gebruiken:** +- ✅ Grote organisaties met meerdere teams +- ✅ Verschillende repositories hebben verschillende toegangsvereisten +- ✅ Compliance requirements die granular control vereisen +- ✅ Multi-tenant scenarios + +**Voorbeeld:** +- Team A heeft alleen toegang tot repository A +- Team B heeft alleen toegang tot repository B +- CI/CD pipeline heeft toegang tot alle repositories +- Externe partners hebben alleen toegang tot specifieke repositories + +--- + +## 🔍 Jouw Situatie Analyse + +**Jouw setup:** +- 2 repositories: `zuyderland-cmdb-gui/backend` en `zuyderland-cmdb-gui/frontend` +- 20 gebruikers (klein team) +- Corporate tool (interne gebruikers) +- Productie omgeving + +**Permission vereisten:** +- ✅ Alle teamleden hebben toegang tot beide repositories +- ✅ CI/CD pipeline heeft toegang tot beide repositories +- ✅ Geen per-repository verschillen nodig +- ✅ Eenvoudige beheer gewenst + +**Conclusie:** ✅ **RBAC Registry Permissions is perfect!** + +--- + +## 📋 Checklist: Welke Keuze? + +### Kies **RBAC Registry Permissions** als: +- [x] Je <50 gebruikers hebt ✅ +- [x] Alle repositories dezelfde toegang hebben ✅ +- [x] Je eenvoudige beheer wilt ✅ +- [x] Je geen per-repository verschillen nodig hebt ✅ +- [x] Je een klein tot middelgroot team hebt ✅ + +**→ Jouw situatie: ✅ Kies RBAC Registry Permissions!** + +### Kies **RBAC Registry + ABAC Repository Permissions** als: +- [ ] Je >100 gebruikers hebt +- [ ] Verschillende repositories verschillende toegang nodig hebben +- [ ] Je granular control nodig hebt +- [ ] Je multi-tenant scenario hebt +- [ ] Je compliance requirements hebt die granular control vereisen + +--- + +## 🔄 Kan Ik Later Wisselen? + +**⚠️ Belangrijk:** +- Deze keuze is **permanent** en kan **niet meer worden gewijzigd** na aanmaken van de registry! +- Als je later ABAC nodig hebt, moet je een nieuwe registry aanmaken + +**Aanbeveling:** +- Start met **RBAC Registry Permissions** (eenvoudigst) +- Als je later granular control nodig hebt, overweeg dan een nieuwe registry met ABAC +- Voor jouw situatie is RBAC Registry Permissions voldoende + +--- + +## 💡 Permission Rollen (RBAC Registry Permissions) + +Met RBAC Registry Permissions kun je deze rollen toewijzen: + +### **AcrPull** (Lezen) +- Images pullen +- Voor: Developers, CI/CD pipelines + +### **AcrPush** (Schrijven) +- Images pushen +- Voor: CI/CD pipelines, build servers + +### **AcrDelete** (Verwijderen) +- Images verwijderen +- Voor: Administrators, cleanup scripts + +### **Owner** (Volledig beheer) +- Alles + registry beheer +- Voor: Administrators + +**Voor jouw situatie:** +- **Developers**: `AcrPull` (images pullen) +- **CI/CD Pipeline**: `AcrPush` (images pushen) +- **Administrators**: `Owner` (volledig beheer) + +--- + +## 🎯 Mijn Aanbeveling + +**Voor Zuyderland CMDB GUI:** + +### ✅ **Kies RBAC Registry Permissions** ⭐ + +**Waarom:** +1. ✅ **Eenvoudig** - Minder complexiteit, makkelijker te beheren +2. ✅ **Voldoende** - Alle repositories hebben dezelfde toegang (wat je nodig hebt) +3. ✅ **Standaard** - Meest gebruikte optie, goed gedocumenteerd +4. ✅ **Perfect voor jouw situatie** - 20 gebruikers, 2 repositories, corporate tool + +**Je hebt niet nodig:** +- ❌ Per-repository permissions (alle repositories hebben dezelfde toegang) +- ❌ Complexe permission structuur (klein team) +- ❌ Multi-tenant scenarios (corporate tool) + +**Setup:** +1. Kies **RBAC Registry Permissions** +2. Wijs rollen toe aan gebruikers/groepen: + - Developers → `AcrPull` + - CI/CD → `AcrPush` + - Admins → `Owner` + +**Klaar!** ✅ + +--- + +## 📚 Meer Informatie + +- [Azure Container Registry RBAC](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-roles) +- [ACR Permissions Best Practices](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-best-practices) +- [ABAC Repository Permissions](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-repository-scoped-permissions) + +--- + +## 🎯 Conclusie + +**Kies: RBAC Registry Permissions** ⭐ + +Dit is de beste keuze voor: +- ✅ 20 gebruikers +- ✅ Corporate tool +- ✅ 2 repositories (backend + frontend) +- ✅ Eenvoudige beheer gewenst +- ✅ Alle repositories hebben dezelfde toegang + +Je kunt altijd later een nieuwe registry aanmaken met ABAC als je granular control nodig hebt, maar voor jouw situatie is dat niet nodig. diff --git a/docs/AZURE-ACR-PRICING.md b/docs/AZURE-ACR-PRICING.md new file mode 100644 index 0000000..212f2bd --- /dev/null +++ b/docs/AZURE-ACR-PRICING.md @@ -0,0 +1,246 @@ +# Azure Container Registry - Pricing Plan Keuze + +## 🎯 Aanbeveling voor Jouw Situatie + +**Voor Zuyderland CMDB GUI (20 gebruikers, corporate tool, productie):** + +### ✅ **Basic SKU** (Aanbevolen) ⭐ + +**Waarom:** +- ✅ Voldoende storage (10GB) voor meerdere versies +- ✅ Goedkoop (~€5/maand) +- ✅ Alle features die je nodig hebt +- ✅ Perfect voor kleine tot middelgrote teams + +--- + +## 📊 SKU Vergelijking + +### Basic SKU (~€5/maand) ⭐ **AANBEVOLEN** + +**Inclusief:** +- ✅ **10GB storage** - Ruim voldoende voor backend + frontend images met meerdere versies +- ✅ **1GB/day webhook throughput** - Voldoende voor CI/CD +- ✅ **Unlimited pulls** - Geen extra kosten voor image pulls +- ✅ **Admin user enabled** - Voor development/productie +- ✅ **RBAC support** - Role-based access control +- ✅ **Content trust** - Image signing support + +**Limitaties:** +- ❌ Geen geo-replicatie +- ❌ Geen security scanning (vulnerability scanning) +- ❌ Geen content trust storage + +**Wanneer gebruiken:** +- ✅ **Jouw situatie** - 20 gebruikers, corporate tool +- ✅ Development en productie omgevingen +- ✅ Kleine tot middelgrote teams +- ✅ Budget-conscious deployments + +**Voorbeeld kosten:** +- 2 images (backend + frontend) +- ~10 versies per image +- ~500MB per image = ~10GB totaal +- **Kosten: ~€5/maand** (alleen storage, geen extra pull kosten) + +--- + +### Standard SKU (~€20/maand) + +**Inclusief (alles van Basic +):** +- ✅ **100GB storage** - Voor grote deployments +- ✅ **10GB/day webhook throughput** - Voor hoge CI/CD volumes +- ✅ **Geo-replicatie** - Images repliceren naar meerdere regio's +- ✅ **Content trust storage** - Voor image signing + +**Extra features:** +- ✅ **Better performance** - Snellere pulls voor geo-replicated images +- ✅ **Disaster recovery** - Images beschikbaar in meerdere regio's + +**Wanneer gebruiken:** +- ✅ Grote deployments (>50GB images) +- ✅ Multi-region deployments nodig +- ✅ Hoge CI/CD volumes (>1GB/day) +- ✅ Disaster recovery requirements + +**Voor jouw situatie:** ❌ **Niet nodig** - Basic is voldoende + +--- + +### Premium SKU (~€50/maand) + +**Inclusief (alles van Standard +):** +- ✅ **500GB storage** - Voor zeer grote deployments +- ✅ **50GB/day webhook throughput** - Voor enterprise CI/CD +- ✅ **Security scanning** - Automatische vulnerability scanning +- ✅ **Advanced security features** - Firewall rules, private endpoints +- ✅ **Dedicated throughput** - Garantie op performance + +**Extra features:** +- ✅ **Image vulnerability scanning** - Automatisch scannen op security issues +- ✅ **Private endpoints** - Volledig private connectivity +- ✅ **Firewall rules** - Network-level security + +**Wanneer gebruiken:** +- ✅ Enterprise deployments +- ✅ Security compliance requirements (ISO 27001, etc.) +- ✅ Zeer grote deployments (>100GB) +- ✅ Multi-tenant scenarios + +**Voor jouw situatie:** ❌ **Niet nodig** - Overkill voor 20 gebruikers + +--- + +## 💰 Kosten Breakdown + +### Basic SKU (Aanbevolen) ⭐ + +**Maandelijkse kosten:** +- **Storage**: €0.167 per GB/maand +- **10GB storage**: ~€1.67/maand +- **Base fee**: ~€3-4/maand +- **Totaal**: ~€5/maand + +**Voorbeeld voor jouw situatie:** +- Backend image: ~200MB +- Frontend image: ~50MB +- 10 versies per image: ~2.5GB +- **Ruim binnen 10GB limit** ✅ + +**Jaarlijkse kosten:** ~€60/jaar + +--- + +### Standard SKU + +**Maandelijkse kosten:** +- **Storage**: €0.167 per GB/maand (eerste 100GB) +- **100GB storage**: ~€16.70/maand +- **Base fee**: ~€3-4/maand +- **Totaal**: ~€20/maand + +**Jaarlijkse kosten:** ~€240/jaar + +**Voor jouw situatie:** ❌ **Te duur** - Je gebruikt maar ~2.5GB + +--- + +### Premium SKU + +**Maandelijkse kosten:** +- **Storage**: €0.167 per GB/maand (eerste 500GB) +- **500GB storage**: ~€83.50/maand +- **Base fee**: ~€16.50/maand +- **Totaal**: ~€50-100/maand (afhankelijk van storage) + +**Jaarlijkse kosten:** ~€600-1200/jaar + +**Voor jouw situatie:** ❌ **Veel te duur** - Niet nodig + +--- + +## 📈 Wanneer Upgrade naar Standard/Premium? + +### Upgrade naar Standard als: +- ✅ Je >50GB images hebt +- ✅ Je multi-region deployment nodig hebt +- ✅ Je >1GB/day webhook throughput nodig hebt +- ✅ Je disaster recovery nodig hebt + +### Upgrade naar Premium als: +- ✅ Je security scanning nodig hebt (compliance) +- ✅ Je >100GB images hebt +- ✅ Je private endpoints nodig hebt +- ✅ Je enterprise security features nodig hebt + +**Voor jouw situatie:** Start met **Basic**, upgrade later als nodig. + +--- + +## 🔄 Upgrade/Downgrade + +**Goed nieuws:** +- ✅ Je kunt altijd upgraden (Basic → Standard → Premium) +- ✅ Je kunt downgraden (Premium → Standard → Basic) +- ⚠️ **Let op**: Bij downgrade verlies je mogelijk data als je over de storage limit gaat + +**Aanbeveling:** +- Start met **Basic** +- Monitor storage gebruik +- Upgrade alleen als je echt de extra features nodig hebt + +--- + +## 📋 Checklist: Welke SKU? + +### Kies Basic als: +- [x] Je <50GB images hebt ✅ +- [x] Je <20 gebruikers hebt ✅ +- [x] Je geen geo-replicatie nodig hebt ✅ +- [x] Je geen security scanning nodig hebt ✅ +- [x] Je budget-conscious bent ✅ + +**→ Jouw situatie: ✅ Kies Basic!** + +### Kies Standard als: +- [ ] Je >50GB images hebt +- [ ] Je multi-region deployment nodig hebt +- [ ] Je disaster recovery nodig hebt +- [ ] Je >1GB/day webhook throughput nodig hebt + +### Kies Premium als: +- [ ] Je security scanning nodig hebt (compliance) +- [ ] Je >100GB images hebt +- [ ] Je private endpoints nodig hebt +- [ ] Je enterprise security features nodig hebt + +--- + +## 💡 Mijn Aanbeveling + +**Voor Zuyderland CMDB GUI:** + +### ✅ **Kies Basic SKU** ⭐ + +**Waarom:** +1. ✅ **Voldoende storage** - 10GB is ruim voldoende voor jouw 2 images met meerdere versies +2. ✅ **Kosteneffectief** - ~€5/maand vs €20-50/maand +3. ✅ **Alle features die je nodig hebt** - RBAC, content trust, unlimited pulls +4. ✅ **Eenvoudig** - Geen complexe configuratie nodig +5. ✅ **Upgrade mogelijk** - Je kunt altijd later upgraden als nodig + +**Geschatte storage gebruik:** +- Backend: ~200MB × 10 versies = ~2GB +- Frontend: ~50MB × 10 versies = ~0.5GB +- **Totaal: ~2.5GB** (ruim binnen 10GB limit) + +**Kosten:** +- **Maandelijks**: ~€5 +- **Jaarlijks**: ~€60 +- **Kosteneffectief** voor jouw use case + +--- + +## 🎯 Conclusie + +**Kies: Basic SKU** ⭐ + +Dit is de beste keuze voor: +- ✅ 20 gebruikers +- ✅ Corporate tool +- ✅ Productie omgeving +- ✅ Budget-conscious +- ✅ Eenvoudige setup + +Je kunt altijd later upgraden naar Standard of Premium als je: +- Meer storage nodig hebt +- Geo-replicatie nodig hebt +- Security scanning nodig hebt + +--- + +## 📚 Meer Informatie + +- [Azure Container Registry Pricing](https://azure.microsoft.com/en-us/pricing/details/container-registry/) +- [ACR SKU Comparison](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-skus) +- [ACR Storage Limits](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-skus#sku-features-and-limits) diff --git a/docs/AZURE-ACR-QUICKSTART.md b/docs/AZURE-ACR-QUICKSTART.md new file mode 100644 index 0000000..5006582 --- /dev/null +++ b/docs/AZURE-ACR-QUICKSTART.md @@ -0,0 +1,287 @@ +# Azure Container Registry - Quick Start Guide + +Snelstart guide om zelf Azure Container Registry aan te maken en te configureren voor productie. + +## 🚀 Stap 1: Azure Container Registry Aanmaken + +### Optie A: Met Script (Aanbevolen) + +```bash +# Run het script +./scripts/create-acr.sh + +# Of met custom parameters: +./scripts/create-acr.sh rg-cmdb-gui zuyderlandcmdbacr westeurope Basic +``` + +Het script doet automatisch: +- ✅ Checkt of je ingelogd bent bij Azure +- ✅ Maakt resource group aan (als nodig) +- ✅ Controleert of ACR naam beschikbaar is +- ✅ Maakt ACR aan met Basic SKU +- ✅ Toont credentials +- ✅ Test Docker login + +### Optie B: Handmatig via Azure CLI + +```bash +# Login bij Azure +az login + +# Resource group aanmaken +az group create --name rg-cmdb-gui --location westeurope + +# Check of naam beschikbaar is +az acr check-name --name zuyderlandcmdbacr + +# ACR aanmaken (Basic SKU - ~€5/maand) +az acr create \ + --resource-group rg-cmdb-gui \ + --name zuyderlandcmdbacr \ + --sku Basic \ + --admin-enabled true + +# Credentials ophalen +az acr credential show --name zuyderlandcmdbacr +``` + +### Optie C: Via Azure Portal + +1. Ga naar [Azure Portal](https://portal.azure.com) +2. Klik **"Create a resource"** +3. Zoek **"Container Registry"** +4. Klik **"Create"** +5. Vul in: + - **Resource group**: `rg-cmdb-gui` (of maak nieuwe) + - **Registry name**: `zuyderlandcmdbacr` (moet uniek zijn, alleen kleine letters en cijfers, **geen streepjes**) + - **Location**: `West Europe` + - **SKU**: `Basic` ⭐ (aanbevolen - ~€5/maand) + - **Domain name label scope**: + - **"Unsecure"** ⭐ (aanbevolen) - DNS naam wordt: `zuyderlandcmdbacr.azurecr.io` + - **"Resource Group Reuse"** (voor extra security) - DNS naam wordt: `zuyderlandcmdbacr-abc123.azurecr.io` (met hash) + - ⚠️ **Let op**: Als je een hash gebruikt, moet je alle configuraties aanpassen met de volledige DNS naam! + - **Role assignment permissions mode**: + - **"RBAC Registry Permissions"** ⭐ (aanbevolen - eenvoudigst) + - **"RBAC Registry + ABAC Repository Permissions"** (alleen als je per-repository permissions nodig hebt) +6. Klik **"Review + create"** → **"Create"** + +**💡 Aanbeveling:** Kies **"Unsecure"** voor de eenvoudigste setup. Zie `docs/AZURE-ACR-DNL-SCOPE.md` voor details. + +**Noteer je ACR naam!** Je hebt deze nodig voor de volgende stappen. + +--- + +## 🔧 Stap 2: Pipeline Variabelen Aanpassen + +Pas `azure-pipelines.yml` aan met jouw ACR naam: + +```yaml +variables: + # Pas deze aan naar jouw ACR naam + acrName: 'zuyderlandcmdbacr' # ← Jouw ACR naam hier + + repositoryName: 'zuyderland-cmdb-gui' + + # Service connection naam (maak je in volgende stap) + dockerRegistryServiceConnection: 'zuyderland-cmdb-acr-connection' + + imageTag: '$(Build.BuildId)' +``` + +**Commit en push:** +```bash +git add azure-pipelines.yml +git commit -m "Configure ACR in pipeline" +git push origin main +``` + +--- + +## 🔗 Stap 3: Service Connection Aanmaken in Azure DevOps + +Deze connection geeft Azure DevOps toegang tot je ACR. + +1. **Ga naar je Azure DevOps project** +2. Klik op **⚙️ Project Settings** (onderaan links) +3. Ga naar **Service connections** (onder Pipelines) +4. Klik op **"New service connection"** +5. Kies **"Docker Registry"** +6. Kies **"Azure Container Registry"** +7. Vul in: + - **Azure subscription**: Selecteer je Azure subscription + - **Azure container registry**: Selecteer je ACR (bijv. `zuyderlandcmdbacr`) + - **Service connection name**: `zuyderland-cmdb-acr-connection` + - **Description**: Optioneel (bijv. "ACR for CMDB GUI") +8. Klik **"Save"** + +**✅ Noteer de service connection naam!** Deze moet overeenkomen met `dockerRegistryServiceConnection` in `azure-pipelines.yml`. + +--- + +## 🎯 Stap 4: Pipeline Aanmaken en Run + +1. **Ga naar je Azure DevOps project** +2. Klik op **Pipelines** (links in het menu) +3. Klik op **"New pipeline"** of **"Create Pipeline"** +4. Kies **"Azure Repos Git"** (of waar je code staat) +5. Selecteer je repository: **"Zuyderland CMDB GUI"** +6. Kies **"Existing Azure Pipelines YAML file"** +7. Selecteer: + - **Branch**: `main` + - **Path**: `/azure-pipelines.yml` +8. Klik **"Continue"** +9. **Review** de pipeline configuratie +10. Klik **"Run"** om de pipeline te starten + +--- + +## ✅ Stap 5: Verifiëren + +### In Azure Portal: +1. Ga naar je **Container Registry** (`zuyderlandcmdbacr`) +2. Klik op **"Repositories"** +3. Je zou moeten zien: + - `zuyderland-cmdb-gui/backend` + - `zuyderland-cmdb-gui/frontend` +4. Klik op een repository om de tags te zien (bijv. `latest`, `123`) + +### Via Azure CLI: +```bash +# Lijst repositories +az acr repository list --name zuyderlandcmdbacr + +# Lijst tags voor backend +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/backend + +# Lijst tags voor frontend +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/frontend +``` + +--- + +## 🐳 Stap 6: Images Lokaal Testen (Optioneel) + +```bash +# Login bij ACR +az acr login --name zuyderlandcmdbacr + +# Pull images +docker pull zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest +docker pull zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/frontend:latest + +# Test run (met docker-compose) +docker-compose -f docker-compose.prod.acr.yml pull +docker-compose -f docker-compose.prod.acr.yml up -d +``` + +--- + +## 📋 Checklist + +- [ ] Azure Container Registry aangemaakt +- [ ] ACR naam genoteerd +- [ ] `azure-pipelines.yml` variabelen aangepast +- [ ] Service Connection aangemaakt in Azure DevOps +- [ ] Pipeline aangemaakt en gerund +- [ ] Images succesvol gebouwd en gepusht +- [ ] Images geverifieerd in Azure Portal + +--- + +## 🔄 Automatische Triggers + +De pipeline triggert automatisch bij: + +1. **Push naar `main` branch** → Bouwt `latest` tag +2. **Git tags die beginnen met `v*`** → Bouwt versie tag (bijv. `v1.0.0`) + +**Voorbeeld:** +```bash +# Tag aanmaken en pushen +git tag v1.0.0 +git push origin v1.0.0 +# → Pipeline triggert automatisch en bouwt versie 1.0.0 +``` + +--- + +## 🚨 Troubleshooting + +### Pipeline Fails: "Service connection not found" + +**Oplossing:** +- Controleer of de service connection naam in `azure-pipelines.yml` overeenkomt met de naam in Azure DevOps +- Ga naar Project Settings → Service connections en verifieer de naam + +### Pipeline Fails: "ACR not found" + +**Oplossing:** +- Controleer of de `acrName` variabele correct is in `azure-pipelines.yml` +- Verifieer dat de ACR bestaat: `az acr list` + +### Pipeline Fails: "Permission denied" + +**Oplossing:** +- Controleer of de service connection de juiste permissions heeft +- Verifieer dat je Azure subscription toegang heeft tot de ACR +- Probeer de service connection opnieuw aan te maken + +### ACR Naam Niet Beschikbaar + +**Oplossing:** +- ACR namen moeten uniek zijn wereldwijd +- Probeer een andere naam: + - `zuyderlandcmdbacr1` + - `zuyderlandcmdbprod` + - `cmdbzuyderlandacr` + - `zuyderlandcmdbgui` + +--- + +## 💰 Kosten & SKU Keuze + +**Aanbeveling: Basic SKU** ⭐ (~€5/maand) + +**Basic SKU** (Aanbevolen voor jouw situatie): +- ✅ 10GB storage - Ruim voldoende voor backend + frontend met meerdere versies +- ✅ 1GB/day webhook throughput - Voldoende voor CI/CD +- ✅ Unlimited pulls - Geen extra kosten +- ✅ RBAC support - Role-based access control +- ✅ **Kosten: ~€5/maand** + +**Standard SKU** (~€20/maand): +- 100GB storage +- 10GB/day webhook throughput +- Geo-replicatie +- **Niet nodig voor jouw situatie** + +**Premium SKU** (~€50/maand): +- 500GB storage +- Security scanning +- Private endpoints +- **Overkill voor 20 gebruikers** + +**Voor jouw situatie (20 gebruikers): Basic is perfect!** ✅ + +📚 Zie `docs/AZURE-ACR-PRICING.md` voor volledige vergelijking. + +--- + +## 📚 Meer Informatie + +- **Volledige ACR Guide**: `docs/AZURE-CONTAINER-REGISTRY.md` +- **Azure DevOps Setup**: `docs/AZURE-DEVOPS-SETUP.md` +- **Deployment Guide**: `docs/PRODUCTION-DEPLOYMENT.md` + +--- + +## 🎯 Volgende Stappen + +Nu je images in ACR staan, kun je ze deployen naar: + +1. **Azure Container Instances (ACI)** - Eenvoudig, snel +2. **Azure App Service (Container)** - Managed service +3. **Azure Kubernetes Service (AKS)** - Voor complexere setups +4. **VM met Docker Compose** - Volledige controle + +Zie `docs/AZURE-DEPLOYMENT-SUMMARY.md` voor deployment opties. diff --git a/docs/AZURE-CONTAINER-REGISTRY.md b/docs/AZURE-CONTAINER-REGISTRY.md new file mode 100644 index 0000000..087868f --- /dev/null +++ b/docs/AZURE-CONTAINER-REGISTRY.md @@ -0,0 +1,451 @@ +# Azure Container Registry - Docker Images Build & Push Guide + +Deze guide beschrijft hoe je Docker images bouwt en naar Azure Container Registry (ACR) pusht voor de Zuyderland CMDB GUI applicatie. + +## 📋 Inhoudsopgave + +1. [Azure Container Registry Setup](#azure-container-registry-setup) +2. [Lokale Build & Push](#lokale-build--push) +3. [Azure DevOps Pipeline](#azure-devops-pipeline) +4. [Docker Compose Configuration](#docker-compose-configuration) +5. [Best Practices](#best-practices) + +--- + +## 🔧 Azure Container Registry Setup + +### 1. Azure Container Registry Aanmaken + +Als je nog geen ACR hebt, maak er een aan via Azure Portal of Azure CLI: + +```bash +# Resource group (als nog niet bestaat) +az group create --name rg-cmdb-gui --location westeurope + +# Azure Container Registry aanmaken +az acr create \ + --resource-group rg-cmdb-gui \ + --name zuyderlandcmdbacr \ + --sku Basic \ + --admin-enabled true +``` + +**ACR SKU Opties:** +- **Basic**: Geschikt voor development/test (~€5/maand) +- **Standard**: Voor productie met geo-replicatie (~€20/maand) +- **Premium**: Voor enterprise met security features (~€50/maand) + +### 2. Registry URL + +Na aanmaken is je registry beschikbaar op: +``` +.azurecr.io +``` + +Bijvoorbeeld: `zuyderlandcmdbacr.azurecr.io` + +### 3. Authentication + +ACR ondersteunt meerdere authenticatiemethoden: + +**A) Admin Credentials (Eenvoudig, voor development)** +```bash +# Admin credentials ophalen +az acr credential show --name zuyderlandcmdbacr + +# Login met Docker +az acr login --name zuyderlandcmdbacr +# OF +docker login zuyderlandcmdbacr.azurecr.io -u -p +``` + +**B) Azure Service Principal (Aanbevolen voor CI/CD)** +```bash +# Service Principal aanmaken +az ad sp create-for-rbac --name "zuyderland-cmdb-acr-sp" --role acrpull --scopes /subscriptions//resourceGroups/rg-cmdb-gui/providers/Microsoft.ContainerRegistry/registries/zuyderlandcmdbacr + +# Gebruik de output credentials in CI/CD +``` + +**C) Managed Identity (Best voor Azure services)** +- Gebruik Managed Identity voor Azure DevOps, App Service, etc. +- Configureer via Azure Portal → ACR → Access Control (IAM) + +--- + +## 🐳 Lokale Build & Push + +### Optie 1: Met Script (Aanbevolen) + +Gebruik het `build-and-push-azure.sh` script: + +```bash +# Maak script uitvoerbaar +chmod +x scripts/build-and-push-azure.sh + +# Build en push (gebruikt 'latest' als versie) +./scripts/build-and-push-azure.sh + +# Build en push met specifieke versie +./scripts/build-and-push-azure.sh 1.0.0 +``` + +**Environment Variables:** +```bash +export ACR_NAME="zuyderlandcmdbacr" +export REPO_NAME="zuyderland-cmdb-gui" +./scripts/build-and-push-azure.sh 1.0.0 +``` + +### Optie 2: Handmatig met Docker Commands + +```bash +# Login +az acr login --name zuyderlandcmdbacr + +# Set variabelen +ACR_NAME="zuyderlandcmdbacr" +REGISTRY="${ACR_NAME}.azurecr.io" +REPO_NAME="zuyderland-cmdb-gui" +VERSION="1.0.0" + +# Build backend +docker build -t ${REGISTRY}/${REPO_NAME}/backend:${VERSION} \ + -t ${REGISTRY}/${REPO_NAME}/backend:latest \ + -f backend/Dockerfile.prod ./backend + +# Build frontend +docker build -t ${REGISTRY}/${REPO_NAME}/frontend:${VERSION} \ + -t ${REGISTRY}/${REPO_NAME}/frontend:latest \ + -f frontend/Dockerfile.prod ./frontend + +# Push images +docker push ${REGISTRY}/${REPO_NAME}/backend:${VERSION} +docker push ${REGISTRY}/${REPO_NAME}/backend:latest +docker push ${REGISTRY}/${REPO_NAME}/frontend:${VERSION} +docker push ${REGISTRY}/${REPO_NAME}/frontend:latest +``` + +--- + +## 🚀 Azure DevOps Pipeline + +### 1. Service Connection Aanmaken + +In Azure DevOps: + +1. **Project Settings** → **Service connections** → **New service connection** +2. Kies **Docker Registry** +3. Kies **Azure Container Registry** +4. Selecteer je Azure subscription en ACR +5. Geef een naam: `zuyderland-cmdb-acr-connection` + +### 2. Pipeline Configuratie + +Het project bevat al een `azure-pipelines.yml` bestand. Configureer deze in Azure DevOps: + +1. **Pipelines** → **New pipeline** +2. Kies je repository (Azure Repos) +3. Kies **Existing Azure Pipelines YAML file** +4. Selecteer `azure-pipelines.yml` +5. Review en run + +### 3. Pipeline Variabelen Aanpassen + +Pas de variabelen in `azure-pipelines.yml` aan naar jouw instellingen: + +```yaml +variables: + acrName: 'zuyderlandcmdbacr' # Jouw ACR naam + repositoryName: 'zuyderland-cmdb-gui' + dockerRegistryServiceConnection: 'zuyderland-cmdb-acr-connection' +``` + +### 4. Automatische Triggers + +De pipeline triggert automatisch bij: +- Push naar `main` branch +- Tags die beginnen met `v*` (bijv. `v1.0.0`) + +**Handmatig Triggeren:** +```bash +# Tag aanmaken en pushen +git tag v1.0.0 +git push origin v1.0.0 +``` + +--- + +## 📦 Docker Compose Configuration + +### Productie Docker Compose met ACR + +Maak `docker-compose.prod.acr.yml`: + +```yaml +version: '3.8' + +services: + backend: + image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest + environment: + - NODE_ENV=production + - PORT=3001 + env_file: + - .env.production + volumes: + - backend_data:/app/data + restart: unless-stopped + networks: + - internal + healthcheck: + test: ["CMD", "node", "-e", "require('http').get('http://localhost:3001/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + + frontend: + image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/frontend:latest + depends_on: + - backend + restart: unless-stopped + networks: + - internal + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"] + interval: 30s + timeout: 10s + retries: 3 + + nginx: + image: nginx:alpine + ports: + - "80:80" + - "443:443" + volumes: + - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro + - ./nginx/ssl:/etc/nginx/ssl:ro + - nginx_cache:/var/cache/nginx + depends_on: + - frontend + - backend + restart: unless-stopped + networks: + - internal + +volumes: + backend_data: + nginx_cache: + +networks: + internal: + driver: bridge +``` + +### Gebruik Specifieke Versies + +Voor productie deployments, gebruik specifieke versies: + +```yaml +backend: + image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:v1.0.0 + +frontend: + image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/frontend:v1.0.0 +``` + +### Pull en Deploy + +```bash +# Login (als nodig) +az acr login --name zuyderlandcmdbacr + +# Pull images +docker-compose -f docker-compose.prod.acr.yml pull + +# Deploy +docker-compose -f docker-compose.prod.acr.yml up -d + +# Status checken +docker-compose -f docker-compose.prod.acr.yml ps + +# Logs bekijken +docker-compose -f docker-compose.prod.acr.yml logs -f +``` + +--- + +## 🎯 Best Practices + +### 1. Versioning + +- **Gebruik semantic versioning**: `v1.0.0`, `v1.0.1`, etc. +- **Tag altijd als `latest`**: Voor development/CI/CD +- **Productie**: Gebruik specifieke versies, nooit `latest` + +```bash +# Tag met versie +git tag v1.0.0 +git push origin v1.0.0 + +# Build met versie +./scripts/build-and-push-azure.sh 1.0.0 +``` + +### 2. Security + +- **Admin credentials uitschakelen** in productie (gebruik Service Principal) +- **Enable Content Trust** voor image signing (optioneel) +- **Scan images** voor vulnerabilities (Azure Security Center) + +```bash +# Admin uitschakelen +az acr update --name zuyderlandcmdbacr --admin-enabled false +``` + +### 3. Image Cleanup + +ACR heeft een retention policy voor oude images: + +```bash +# Retention policy instellen (bijv. laatste 10 tags behouden) +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/backend --orderby time_desc --top 10 + +# Oude tags verwijderen (handmatig of via policy) +az acr repository delete --name zuyderlandcmdbacr --image zuyderland-cmdb-gui/backend:old-tag +``` + +### 4. Multi-Stage Builds + +De `Dockerfile.prod` bestanden gebruiken al multi-stage builds voor kleinere images. + +### 5. Build Cache + +Voor snellere builds, gebruik build cache: + +```bash +# Build met cache +docker build --cache-from zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest \ + -t zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:new-tag \ + -f backend/Dockerfile.prod ./backend +``` + +--- + +## 🔍 Troubleshooting + +### Authentication Issues + +```bash +# Check Azure login +az account show + +# Re-login +az login +az acr login --name zuyderlandcmdbacr + +# Check Docker login +cat ~/.docker/config.json +``` + +### Build Errors + +```bash +# Build met verbose output +docker build --progress=plain -t test-image -f backend/Dockerfile.prod ./backend + +# Check lokale images +docker images | grep zuyderland-cmdb-gui +``` + +### Push Errors + +```bash +# Check ACR connectivity +az acr check-health --name zuyderlandcmdbacr + +# Check repository exists +az acr repository list --name zuyderlandcmdbacr + +# View repository tags +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/backend +``` + +### Azure DevOps Pipeline Errors + +- Check **Service Connection** permissions +- Verify **ACR naam** in pipeline variables +- Check **Dockerfile paths** zijn correct +- Review pipeline logs in Azure DevOps + +--- + +## 📝 Usage Examples + +### Eenvoudige Workflow + +```bash +# 1. Code aanpassen en committen +git add . +git commit -m "Update feature" +git push origin main + +# 2. Build en push naar ACR +./scripts/build-and-push-azure.sh + +# 3. Deploy (op productie server) +az acr login --name zuyderlandcmdbacr +docker-compose -f docker-compose.prod.acr.yml pull +docker-compose -f docker-compose.prod.acr.yml up -d +``` + +### Versioned Release + +```bash +# 1. Tag release +git tag v1.0.0 +git push origin v1.0.0 + +# 2. Build en push met versie +./scripts/build-and-push-azure.sh 1.0.0 + +# 3. Update docker-compose met versie +# Edit docker-compose.prod.acr.yml: image: ...backend:v1.0.0 + +# 4. Deploy +docker-compose -f docker-compose.prod.acr.yml pull +docker-compose -f docker-compose.prod.acr.yml up -d +``` + +### Azure DevOps Automated + +1. Push code naar `main` → Pipeline triggert automatisch +2. Pipeline bouwt images en pusht naar ACR +3. Deploy handmatig of via release pipeline + +--- + +## 📚 Additional Resources + +- [Azure Container Registry Documentation](https://docs.microsoft.com/en-us/azure/container-registry/) +- [Azure DevOps Docker Task](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker) +- [ACR Best Practices](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-best-practices) +- [Docker Compose Production Guide](./PRODUCTION-DEPLOYMENT.md) + +--- + +## 🔄 Vergelijking: Gitea vs Azure Container Registry + +| Feature | Gitea Registry | Azure Container Registry | +|---------|---------------|-------------------------| +| **Kosten** | Gratis (met Gitea) | €5-50/maand (afhankelijk van SKU) | +| **Security** | Basic | Enterprise-grade (RBAC, scanning) | +| **CI/CD** | Gitea Actions | Azure DevOps, GitHub Actions | +| **Geo-replicatie** | Nee | Ja (Standard/Premium) | +| **Image Scanning** | Nee | Ja (Azure Security Center) | +| **Integratie** | Gitea ecosystem | Azure ecosystem (App Service, AKS, etc.) | + +**Aanbeveling:** +- **Development/Test**: Gitea Registry (gratis, eenvoudig) +- **Productie**: Azure Container Registry (security, enterprise features) diff --git a/docs/AZURE-DEVOPS-SETUP.md b/docs/AZURE-DEVOPS-SETUP.md new file mode 100644 index 0000000..194da53 --- /dev/null +++ b/docs/AZURE-DEVOPS-SETUP.md @@ -0,0 +1,310 @@ +# Azure DevOps Setup - Stap voor Stap Guide + +Nu je code in Azure DevOps staat, volg deze stappen om Docker images automatisch te bouwen en naar Azure Container Registry te pushen. + +## 📋 Stappenplan + +### Stap 1: Azure Container Registry Aanmaken + +Als je nog geen Azure Container Registry hebt: + +**Optie A: Met Script (Aanbevolen) 🚀** +```bash +# Run het script (interactief) +./scripts/create-acr.sh + +# Of met custom parameters: +./scripts/create-acr.sh rg-cmdb-gui zuyderlandcmdbacr westeurope Basic +``` + +Het script doet automatisch: +- ✅ Checkt of je ingelogd bent bij Azure +- ✅ Maakt resource group aan (als nodig) +- ✅ Controleert of ACR naam beschikbaar is +- ✅ Maakt ACR aan met Basic SKU +- ✅ Toont credentials +- ✅ Test Docker login + +**Optie B: Via Azure CLI (Handmatig)** +```bash +# Login bij Azure +az login + +# Resource group aanmaken (als nog niet bestaat) +az group create --name rg-cmdb-gui --location westeurope + +# Container Registry aanmaken +az acr create \ + --resource-group rg-cmdb-gui \ + --name zuyderlandcmdbacr \ + --sku Basic \ + --admin-enabled true +``` + +**Optie C: Via Azure Portal** +1. Ga naar [Azure Portal](https://portal.azure.com) +2. Klik op **"Create a resource"** +3. Zoek naar **"Container Registry"** +4. Klik **"Create"** +5. Vul in: + - **Resource group**: Kies bestaande of maak nieuwe (bijv. `rg-cmdb-gui`) + - **Registry name**: Bijv. `zuyderlandcmdbacr` (moet uniek zijn, alleen kleine letters en cijfers) + - **Location**: `West Europe` (of gewenste regio) + - **SKU**: `Basic` (voor development/test) of `Standard` (voor productie) +6. Klik **"Review + create"** → **"Create"** + +**Noteer je ACR naam!** Je hebt deze nodig in de volgende stappen. + +**📚 Zie `docs/AZURE-ACR-QUICKSTART.md` voor een complete quick-start guide.** + +--- + +### Stap 2: Service Connection Aanmaken in Azure DevOps + +Deze connection geeft Azure DevOps toegang tot je Azure Container Registry. + +1. **Ga naar je Azure DevOps project** +2. Klik op **⚙️ Project Settings** (onderaan links) +3. Ga naar **Service connections** (onder Pipelines) +4. Klik op **"New service connection"** +5. Kies **"Docker Registry"** +6. Kies **"Azure Container Registry"** +7. Vul in: + - **Azure subscription**: Selecteer je Azure subscription + - **Azure container registry**: Selecteer je ACR (bijv. `zuyderlandcmdbacr`) + - **Service connection name**: Bijv. `zuyderland-cmdb-acr-connection` + - **Description**: Optioneel +8. Klik **"Save"** + +**✅ Noteer de service connection naam!** Je hebt deze nodig voor de pipeline. + +--- + +### Stap 3: Pipeline Variabelen Aanpassen + +Pas de `azure-pipelines.yml` aan naar jouw instellingen: + +1. **Open** `azure-pipelines.yml` in je repository +2. **Pas de variabelen aan** (regel 15-20): + +```yaml +variables: + # Pas deze aan naar jouw ACR naam + acrName: 'zuyderlandcmdbacr' # ← Jouw ACR naam hier + + repositoryName: 'zuyderland-cmdb-gui' + + # Pas deze aan naar de service connection naam die je net hebt gemaakt + dockerRegistryServiceConnection: 'zuyderland-cmdb-acr-connection' # ← Jouw service connection naam + + imageTag: '$(Build.BuildId)' +``` + +3. **Commit en push** de wijzigingen: +```bash +git add azure-pipelines.yml +git commit -m "Configure Azure DevOps pipeline" +git push origin main +``` + +--- + +### Stap 4: Pipeline Aanmaken in Azure DevOps + +1. **Ga naar je Azure DevOps project** +2. Klik op **Pipelines** (links in het menu) +3. Klik op **"New pipeline"** of **"Create Pipeline"** +4. Kies **"Azure Repos Git"** (of waar je code staat) +5. Selecteer je repository: **"Zuyderland CMDB GUI"** (of jouw repo naam) +6. Kies **"Existing Azure Pipelines YAML file"** +7. Selecteer: + - **Branch**: `main` + - **Path**: `/azure-pipelines.yml` +8. Klik **"Continue"** +9. **Review** de pipeline configuratie +10. Klik **"Run"** om de pipeline te starten + +--- + +### Stap 5: Pipeline Uitvoeren + +De pipeline start automatisch en zal: + +1. ✅ Code uitchecken +2. ✅ Backend Docker image bouwen +3. ✅ Frontend Docker image bouwen +4. ✅ Images naar Azure Container Registry pushen + +**Je kunt de voortgang volgen:** +- Klik op de running pipeline +- Bekijk de logs per stap +- Bij success zie je de image URLs + +**Verwachte output:** +``` +Backend Image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:123 +Frontend Image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/frontend:123 +``` + +--- + +### Stap 6: Images Verifiëren + +**In Azure Portal:** +1. Ga naar je **Container Registry** (`zuyderlandcmdbacr`) +2. Klik op **"Repositories"** +3. Je zou moeten zien: + - `zuyderland-cmdb-gui/backend` + - `zuyderland-cmdb-gui/frontend` +4. Klik op een repository om de tags te zien (bijv. `latest`, `123`) + +**Via Azure CLI:** +```bash +# Lijst repositories +az acr repository list --name zuyderlandcmdbacr + +# Lijst tags voor backend +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/backend + +# Lijst tags voor frontend +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/frontend +``` + +--- + +## 🚀 Automatische Triggers + +De pipeline triggert automatisch bij: + +1. **Push naar `main` branch** → Bouwt `latest` tag +2. **Git tags die beginnen met `v*`** → Bouwt versie tag (bijv. `v1.0.0`) + +**Voorbeeld:** +```bash +# Tag aanmaken en pushen +git tag v1.0.0 +git push origin v1.0.0 +# → Pipeline triggert automatisch en bouwt versie 1.0.0 +``` + +--- + +## 🔧 Troubleshooting + +### Pipeline Fails: "Service connection not found" + +**Oplossing:** +- Controleer of de service connection naam in `azure-pipelines.yml` overeenkomt met de naam in Azure DevOps +- Ga naar Project Settings → Service connections en verifieer de naam + +### Pipeline Fails: "ACR not found" + +**Oplossing:** +- Controleer of de `acrName` variabele correct is in `azure-pipelines.yml` +- Verifieer dat de ACR bestaat: `az acr list` + +### Pipeline Fails: "Permission denied" + +**Oplossing:** +- Controleer of de service connection de juiste permissions heeft +- Verifieer dat je Azure subscription toegang heeft tot de ACR +- Probeer de service connection opnieuw aan te maken + +### Images worden niet gepusht + +**Oplossing:** +- Check de pipeline logs voor specifieke errors +- Verifieer dat de Docker build succesvol is +- Controleer of de ACR admin-enabled is (voor development) + +--- + +## 📦 Volgende Stappen: Deployment + +Nu je images in Azure Container Registry staan, kun je ze deployen: + +### Optie 1: Azure App Service + +```bash +# Web App aanmaken en configureren +az webapp create --name cmdb-backend --resource-group rg-cmdb-gui --plan plan-cmdb-gui +az webapp config container set --name cmdb-backend --resource-group rg-cmdb-gui \ + --docker-custom-image-name zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest \ + --docker-registry-server-url https://zuyderlandcmdbacr.azurecr.io +``` + +### Optie 2: Docker Compose op VM + +```bash +# Login bij ACR +az acr login --name zuyderlandcmdbacr + +# Pull images +docker-compose -f docker-compose.prod.acr.yml pull + +# Deploy +docker-compose -f docker-compose.prod.acr.yml up -d +``` + +### Optie 3: Azure Container Instances (ACI) + +```bash +az container create \ + --resource-group rg-cmdb-gui \ + --name cmdb-backend \ + --image zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest \ + --registry-login-server zuyderlandcmdbacr.azurecr.io \ + --registry-username \ + --registry-password +``` + +--- + +## 📝 Checklist + +- [ ] Azure Container Registry aangemaakt +- [ ] Service Connection geconfigureerd in Azure DevOps +- [ ] `azure-pipelines.yml` variabelen aangepast +- [ ] Pipeline aangemaakt en gerund +- [ ] Images succesvol gebouwd en gepusht +- [ ] Images geverifieerd in Azure Portal +- [ ] Automatische triggers getest (push naar main) + +--- + +## 🎯 Quick Reference + +**ACR Login:** +```bash +az acr login --name zuyderlandcmdbacr +``` + +**Images Lijsten:** +```bash +az acr repository list --name zuyderlandcmdbacr +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/backend +``` + +**Pipeline Handmatig Triggeren:** +- Ga naar Pipelines → Selecteer pipeline → "Run pipeline" + +**Pipeline Logs Bekijken:** +- Ga naar Pipelines → Selecteer pipeline → Klik op de run → Bekijk logs per stap + +--- + +## 📚 Meer Informatie + +- [Azure Container Registry Docs](https://docs.microsoft.com/en-us/azure/container-registry/) +- [Azure DevOps Pipelines Docs](https://docs.microsoft.com/en-us/azure/devops/pipelines/) +- [Docker Task Reference](https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/docker) + +--- + +## 💡 Tips + +1. **Gebruik versie tags voor productie**: Tag releases met `v1.0.0`, `v1.0.1`, etc. +2. **Monitor pipeline costs**: Azure DevOps geeft gratis build minuten per maand +3. **Enable retention policies**: Configureer ACR om oude images automatisch te verwijderen +4. **Use build caching**: Voor snellere builds bij volgende runs +5. **Set up notifications**: Configureer email/Slack notificaties voor pipeline status diff --git a/docs/AZURE-REGISTRY-BESLISSING.md b/docs/AZURE-REGISTRY-BESLISSING.md new file mode 100644 index 0000000..190de58 --- /dev/null +++ b/docs/AZURE-REGISTRY-BESLISSING.md @@ -0,0 +1,283 @@ +# Azure Container Registry - Moet ik dit aanvragen? + +## 🤔 Korte Antwoord + +**Het hangt af van je deployment strategie:** + +1. **Azure App Service (zonder containers)** → ❌ **Geen ACR nodig** + - Direct deployment van code + - Eenvoudiger en goedkoper + - **Aanbevolen voor jouw situatie** (20 gebruikers) + +2. **Container-based deployment** → ✅ **ACR nodig** (of alternatief) + - Azure Container Instances (ACI) + - Azure Kubernetes Service (AKS) + - VM met Docker Compose + +--- + +## 📊 Deployment Opties Vergelijking + +### Optie 1: Azure App Service (Zonder Containers) ⭐ **AANBEVOLEN** + +**Wat je nodig hebt:** +- ✅ Azure App Service Plan (B1) - €15-25/maand +- ✅ Azure Key Vault - €1-2/maand +- ✅ Database (PostgreSQL of SQLite) - €1-30/maand +- ❌ **Geen Container Registry nodig!** + +**Hoe het werkt:** +- Azure DevOps bouwt je code direct +- Deployt naar App Service via ZIP deploy of Git +- Geen Docker images nodig + +**Voordelen:** +- ✅ Eenvoudiger setup +- ✅ Goedkoper (geen ACR kosten) +- ✅ Snellere deployments +- ✅ Managed service (minder onderhoud) + +**Nadelen:** +- ❌ Minder flexibel dan containers +- ❌ Platform-specifiek (Azure only) + +**Voor jouw situatie:** ✅ **Dit is de beste optie!** + +--- + +### Optie 2: Container Registry (Als je containers wilt gebruiken) + +**Je hebt 3 keuzes voor een registry:** + +#### A) Azure Container Registry (ACR) 💰 + +**Kosten:** +- Basic: ~€5/maand +- Standard: ~€20/maand +- Premium: ~€50/maand + +**Voordelen:** +- ✅ Integratie met Azure services +- ✅ Security scanning (Premium) +- ✅ Geo-replicatie (Standard/Premium) +- ✅ RBAC integratie + +**Nadelen:** +- ❌ Extra kosten +- ❌ Moet aangevraagd worden bij IT + +**Wanneer aanvragen:** +- Als je containers gebruikt in productie +- Als je Azure-native deployment wilt +- Als je security scanning nodig hebt + +--- + +#### B) Gitea Container Registry (Gratis) 🆓 + +**Kosten:** Gratis (als je al Gitea hebt) + +**Voordelen:** +- ✅ Geen extra kosten +- ✅ Al beschikbaar (als Gitea dit ondersteunt) +- ✅ Eenvoudig te gebruiken + +**Nadelen:** +- ❌ Minder features dan ACR +- ❌ Geen security scanning +- ❌ Geen geo-replicatie + +**Je hebt al:** +- ✅ Script: `scripts/build-and-push.sh` +- ✅ Config: `docker-compose.prod.registry.yml` +- ✅ Documentatie: `docs/GITEA-DOCKER-REGISTRY.md` + +**Wanneer gebruiken:** +- ✅ Development/test omgevingen +- ✅ Als je al Gitea hebt met registry enabled +- ✅ Kleine projecten zonder enterprise requirements + +--- + +#### C) Docker Hub (Gratis/Paid) + +**Kosten:** +- Free: 1 private repo, unlimited public +- Pro: $5/maand voor unlimited private repos + +**Voordelen:** +- ✅ Eenvoudig te gebruiken +- ✅ Gratis voor public images +- ✅ Wereldwijd beschikbaar + +**Nadelen:** +- ❌ Rate limits op free tier +- ❌ Minder integratie met Azure +- ❌ Security concerns (voor private data) + +**Wanneer gebruiken:** +- Development/test +- Public images +- Als je geen Azure-native oplossing nodig hebt + +--- + +## 🎯 Aanbeveling voor Jouw Situatie + +### Scenario 1: Eenvoudige Productie Deployment (Aanbevolen) ⭐ + +**Gebruik: Azure App Service zonder containers** + +**Waarom:** +- ✅ Geen ACR nodig +- ✅ Eenvoudiger en goedkoper +- ✅ Voldoende voor 20 gebruikers +- ✅ Minder complexiteit + +**Stappen:** +1. **Niet nodig:** ACR aanvragen +2. **Wel nodig:** Azure App Service Plan aanvragen +3. **Pipeline aanpassen:** Gebruik Azure App Service deployment task in plaats van Docker + +**Pipeline aanpassing:** +```yaml +# In plaats van Docker build/push: +- task: AzureWebApp@1 + inputs: + azureSubscription: 'your-subscription' + appName: 'cmdb-backend' + package: '$(System.DefaultWorkingDirectory)' +``` + +--- + +### Scenario 2: Container-based Deployment + +**Als je toch containers wilt gebruiken:** + +**Optie A: Gebruik Gitea Registry (als beschikbaar)** +- ✅ Geen aanvraag nodig +- ✅ Gratis +- ✅ Al geconfigureerd in je project + +**Optie B: Vraag ACR aan bij IT** +- 📧 Stuur een request naar IT/Infrastructure team +- 📋 Vermeld: "Azure Container Registry - Basic tier voor CMDB GUI project" +- 💰 Budget: ~€5-20/maand (afhankelijk van tier) + +**Request Template:** +``` +Onderwerp: Azure Container Registry aanvraag - CMDB GUI Project + +Beste IT Team, + +Voor het Zuyderland CMDB GUI project hebben we een Azure Container Registry nodig +voor het hosten van Docker images. + +Details: +- Project: Zuyderland CMDB GUI +- Registry naam: zuyderlandcmdbacr (of zoals jullie naming convention) +- SKU: Basic (voor development/productie) +- Resource Group: rg-cmdb-gui +- Location: West Europe +- Doel: Hosten van backend en frontend Docker images voor productie deployment + +Geschatte kosten: €5-20/maand (Basic tier) + +Alvast bedankt! +``` + +--- + +## 📋 Beslissingsmatrix + +| Situatie | Registry Nodig? | Welke? | Kosten | +|----------|----------------|--------|--------| +| **Azure App Service (code deploy)** | ❌ Nee | - | €0 | +| **Gitea Registry beschikbaar** | ✅ Ja | Gitea | €0 | +| **Containers + Azure native** | ✅ Ja | ACR Basic | €5/maand | +| **Containers + Security scanning** | ✅ Ja | ACR Standard | €20/maand | +| **Development/test only** | ✅ Ja | Docker Hub (free) | €0 | + +--- + +## 🚀 Quick Start: Wat Moet Je Nu Doen? + +### Als je Azure App Service gebruikt (Aanbevolen): + +1. ✅ **Geen ACR nodig** - Skip deze stap +2. ✅ Vraag **Azure App Service Plan** aan bij IT +3. ✅ Configureer pipeline voor App Service deployment +4. ✅ Gebruik bestaande `azure-pipelines.yml` maar pas aan voor App Service + +### Als je containers gebruikt: + +1. ✅ **Check eerst:** Is Gitea Container Registry beschikbaar? + - Zo ja → Gebruik Gitea (gratis, al geconfigureerd) + - Zo nee → Vraag ACR Basic aan bij IT + +2. ✅ Als je ACR aanvraagt: + - Stuur request naar IT team + - Gebruik request template hierboven + - Wacht op goedkeuring + +3. ✅ Configureer pipeline: + - Pas `azure-pipelines.yml` aan met ACR naam + - Maak service connection in Azure DevOps + - Test pipeline + +--- + +## 💡 Mijn Aanbeveling + +**Voor jouw situatie (20 gebruikers, interne tool):** + +1. **Start met Azure App Service** (zonder containers) + - Eenvoudiger + - Goedkoper + - Voldoende functionaliteit + +2. **Als je later containers nodig hebt:** + - Gebruik eerst Gitea Registry (als beschikbaar) + - Vraag ACR aan als Gitea niet voldoet + +3. **Vraag ACR alleen aan als:** + - Je security scanning nodig hebt + - Je geo-replicatie nodig hebt + - Je Azure-native container deployment wilt + +--- + +## ❓ Vragen voor IT Team + +Als je ACR wilt aanvragen, vraag dan: + +1. **Hebben we al een ACR?** (misschien kunnen we die delen) +2. **Wat is de naming convention?** (voor registry naam) +3. **Welke SKU is aanbevolen?** (Basic/Standard/Premium) +4. **Welke resource group gebruiken we?** (best practices) +5. **Zijn er compliance requirements?** (security scanning, etc.) +6. **Heeft Gitea Container Registry?** (gratis alternatief) + +--- + +## 📚 Meer Informatie + +- **Azure App Service Deployment**: `docs/AZURE-DEPLOYMENT-SUMMARY.md` +- **Gitea Registry**: `docs/GITEA-DOCKER-REGISTRY.md` +- **Azure Container Registry**: `docs/AZURE-CONTAINER-REGISTRY.md` +- **Azure DevOps Setup**: `docs/AZURE-DEVOPS-SETUP.md` + +--- + +## 🎯 Conclusie + +**Kort antwoord:** +- **Azure App Service?** → ❌ Geen ACR nodig +- **Containers?** → ✅ ACR nodig (of Gitea/Docker Hub) +- **Aanbeveling:** Start met App Service, vraag ACR later aan als nodig + +**Actie:** +1. Beslis: App Service of Containers? +2. Als Containers: Check Gitea Registry eerst +3. Als ACR nodig: Vraag aan bij IT met request template diff --git a/docs/NEXT-STEPS-ACR-CREATED.md b/docs/NEXT-STEPS-ACR-CREATED.md new file mode 100644 index 0000000..482312f --- /dev/null +++ b/docs/NEXT-STEPS-ACR-CREATED.md @@ -0,0 +1,285 @@ +# Next Steps - ACR Created! 🎉 + +Je Azure Container Registry is aangemaakt! Volg deze stappen om Docker images automatisch te bouwen en te pushen. + +## 📋 Checklist + +- [ ] Stap 1: Verifieer ACR naam +- [ ] Stap 2: Update pipeline variabelen (als nodig) +- [ ] Stap 3: Service Connection aanmaken in Azure DevOps +- [ ] Stap 4: Pipeline aanmaken en runnen +- [ ] Stap 5: Verifieer images in ACR + +--- + +## 🔍 Stap 1: Verifieer ACR Naam + +**Vind je ACR naam:** + +**Via Azure Portal:** +1. Ga naar je Container Registry +2. Klik op **"Overview"** +3. Noteer de **"Login server"** (bijv. `zuyderlandcmdbacr.azurecr.io`) +4. De naam vóór `.azurecr.io` is je ACR naam (bijv. `zuyderlandcmdbacr`) + +**Via Azure CLI:** +```bash +az acr list --query "[].{Name:name, LoginServer:loginServer}" -o table +``` + +**Noteer je ACR naam!** (bijv. `zuyderlandcmdbacr`) + +--- + +## 🔧 Stap 2: Update Pipeline Variabelen + +**Check of `azure-pipelines.yml` de juiste ACR naam heeft:** + +1. **Open** `azure-pipelines.yml` +2. **Controleer regel 17:** + ```yaml + acrName: 'zuyderlandcmdbacr' # ← Pas aan naar jouw ACR naam + ``` + +3. **Als je ACR naam anders is**, pas het aan: + ```yaml + acrName: 'jouw-acr-naam-hier' + ``` + +4. **Commit en push** (als je het hebt aangepast): + ```bash + git add azure-pipelines.yml + git commit -m "Update ACR name in pipeline" + git push origin main + ``` + +**✅ Als de naam al klopt, ga door naar Stap 3!** + +--- + +## 🔗 Stap 3: Service Connection Aanmaken in Azure DevOps + +Deze connection geeft Azure DevOps toegang tot je ACR. + +### Stappen: + +1. **Ga naar je Azure DevOps project** + - Open je project in Azure DevOps + +2. **Ga naar Project Settings** + - Klik op **⚙️ Project Settings** (onderaan links in het menu) + +3. **Open Service Connections** + - Scroll naar **"Pipelines"** sectie + - Klik op **"Service connections"** + +4. **Maak nieuwe connection** + - Klik op **"New service connection"** (of **"Create service connection"**) + - Kies **"Docker Registry"** + - Klik **"Next"** + +5. **Selecteer Azure Container Registry** + - Kies **"Azure Container Registry"** + - Klik **"Next"** + +6. **Configureer connection** + - **Azure subscription**: Selecteer je Azure subscription + - **Azure container registry**: Selecteer je ACR uit de dropdown (bijv. `zuyderlandcmdbacr`) + - **Service connection name**: `zuyderland-cmdb-acr-connection` + - ⚠️ **Belangrijk**: Deze naam moet overeenkomen met `dockerRegistryServiceConnection` in `azure-pipelines.yml`! + - **Description**: Optioneel (bijv. "ACR for CMDB GUI production") + +7. **Save** + - Klik **"Save"** (of **"Verify and save"**) + - Azure DevOps test automatisch de connection + +**✅ Service connection is aangemaakt!** + +**Troubleshooting:** +- Als je ACR niet ziet in de dropdown, check of je de juiste subscription hebt geselecteerd +- Als verificatie faalt, check of je toegang hebt tot de ACR in Azure Portal + +--- + +## 🎯 Stap 4: Pipeline Aanmaken en Run + +### Stappen: + +1. **Ga naar Pipelines** + - Klik op **"Pipelines"** (links in het menu) + +2. **Create New Pipeline** + - Klik op **"New pipeline"** of **"Create Pipeline"** + +3. **Selecteer Repository** + - Kies **"Azure Repos Git"** (of waar je code staat) + - Selecteer je repository: **"Zuyderland CMDB GUI"** (of jouw repo naam) + +4. **Kies YAML File** + - Kies **"Existing Azure Pipelines YAML file"** + - Selecteer: + - **Branch**: `main` (of jouw default branch) + - **Path**: `/azure-pipelines.yml` + +5. **Review Configuration** + - Azure DevOps toont de pipeline configuratie + - Controleer of alles klopt + +6. **Run Pipeline** + - Klik **"Run"** om de pipeline te starten + - De pipeline start automatisch met het bouwen van de images + +**✅ Pipeline is gestart!** + +### Wat gebeurt er nu? + +De pipeline zal: +1. ✅ Code uitchecken +2. ✅ Backend Docker image bouwen +3. ✅ Frontend Docker image bouwen +4. ✅ Images naar Azure Container Registry pushen + +**Verwachte tijd:** ~5-10 minuten (afhankelijk van build tijd) + +--- + +## ✅ Stap 5: Verifieer Images in ACR + +### In Azure Portal: + +1. **Ga naar je Container Registry** + - Open Azure Portal + - Ga naar je Container Registry (`zuyderlandcmdbacr`) + +2. **Bekijk Repositories** + - Klik op **"Repositories"** (links in het menu) + - Je zou moeten zien: + - `zuyderland-cmdb-gui/backend` + - `zuyderland-cmdb-gui/frontend` + +3. **Bekijk Tags** + - Klik op een repository (bijv. `zuyderland-cmdb-gui/backend`) + - Je zou tags moeten zien: + - `latest` + - `123` (of build ID nummer) + +**✅ Images zijn succesvol gebouwd en gepusht!** + +### Via Azure CLI: + +```bash +# Lijst repositories +az acr repository list --name zuyderlandcmdbacr + +# Lijst tags voor backend +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/backend --orderby time_desc + +# Lijst tags voor frontend +az acr repository show-tags --name zuyderlandcmdbacr --repository zuyderland-cmdb-gui/frontend --orderby time_desc +``` + +### In Azure DevOps: + +1. **Ga naar je Pipeline** + - Klik op **"Pipelines"** + - Klik op je pipeline run + +2. **Bekijk Logs** + - Klik op een job (bijv. "Build Docker Images") + - Bekijk de logs per stap + - Bij success zie je: + ``` + Backend Image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:123 + Frontend Image: zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/frontend:123 + ``` + +--- + +## 🚨 Troubleshooting + +### Pipeline Fails: "Service connection not found" + +**Oplossing:** +- Controleer of de service connection naam in `azure-pipelines.yml` (regel 19) overeenkomt met de naam in Azure DevOps +- Ga naar Project Settings → Service connections en verifieer de naam +- Pas `dockerRegistryServiceConnection` aan in `azure-pipelines.yml` als nodig + +### Pipeline Fails: "ACR not found" + +**Oplossing:** +- Controleer of de `acrName` variabele correct is in `azure-pipelines.yml` (regel 17) +- Verifieer dat de ACR bestaat: `az acr list` +- Check of je de juiste subscription hebt geselecteerd in de service connection + +### Pipeline Fails: "Permission denied" + +**Oplossing:** +- Controleer of de service connection de juiste permissions heeft +- Verifieer dat je Azure subscription toegang heeft tot de ACR +- Check of de service connection is geverifieerd (groen vinkje in Azure DevOps) +- Probeer de service connection opnieuw aan te maken + +### Images worden niet gepusht + +**Oplossing:** +- Check de pipeline logs voor specifieke errors +- Verifieer dat de Docker build succesvol is +- Controleer of de ACR admin-enabled is (voor development) +- Check of de service connection correct is geconfigureerd + +### Build Fails: "Dockerfile not found" + +**Oplossing:** +- Verifieer dat `backend/Dockerfile.prod` en `frontend/Dockerfile.prod` bestaan +- Check of de paths correct zijn in `azure-pipelines.yml` +- Controleer of de files zijn gecommit en gepusht naar de repository + +--- + +## 🎉 Success! + +Als alles goed is gegaan, heb je nu: + +- ✅ Azure Container Registry aangemaakt +- ✅ Service Connection geconfigureerd +- ✅ Pipeline aangemaakt en gerund +- ✅ Docker images gebouwd en gepusht naar ACR + +**Je images zijn nu beschikbaar op:** +- Backend: `zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/backend:latest` +- Frontend: `zuyderlandcmdbacr.azurecr.io/zuyderland-cmdb-gui/frontend:latest` + +--- + +## 🚀 Volgende Stappen + +Nu je images in ACR staan, kun je ze deployen naar: + +1. **Azure Container Instances (ACI)** - Eenvoudig, snel +2. **Azure App Service (Container)** - Managed service +3. **Azure Kubernetes Service (AKS)** - Voor complexere setups +4. **VM met Docker Compose** - Volledige controle + +Zie `docs/AZURE-DEPLOYMENT-SUMMARY.md` voor deployment opties. + +--- + +## 📚 Meer Informatie + +- **Quick Start Guide**: `docs/AZURE-ACR-QUICKSTART.md` +- **Azure DevOps Setup**: `docs/AZURE-DEVOPS-SETUP.md` +- **Container Registry Guide**: `docs/AZURE-CONTAINER-REGISTRY.md` +- **Deployment Options**: `docs/AZURE-DEPLOYMENT-SUMMARY.md` + +--- + +## 💡 Tips + +1. **Automatische Triggers**: De pipeline triggert automatisch bij elke push naar `main` branch +2. **Version Tags**: Gebruik git tags (bijv. `v1.0.0`) voor versie-specifieke builds +3. **Monitor Costs**: Check Azure Portal regelmatig voor storage gebruik +4. **Cleanup**: Overweeg oude images te verwijderen om kosten te besparen + +--- + +**Veel succes! 🚀** diff --git a/scripts/build-and-push-azure.sh b/scripts/build-and-push-azure.sh new file mode 100755 index 0000000..287ecdf --- /dev/null +++ b/scripts/build-and-push-azure.sh @@ -0,0 +1,95 @@ +#!/bin/bash +set -e + +# Configuration - Azure Container Registry +ACR_NAME="${ACR_NAME:-zuyderlandcmdbacr}" # Pas aan naar jouw ACR naam +REGISTRY="${REGISTRY:-${ACR_NAME}.azurecr.io}" +REPO_NAME="${REPO_NAME:-zuyderland-cmdb-gui}" +VERSION="${1:-latest}" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +echo -e "${BLUE}════════════════════════════════════════${NC}" +echo -e "${GREEN}🐳 Azure Container Registry Build & Push${NC}" +echo -e "${BLUE}════════════════════════════════════════${NC}" +echo "Registry: ${REGISTRY}" +echo "Repository: ${REPO_NAME}" +echo "Version: ${VERSION}" +echo "" + +# Check if Azure CLI is installed +if ! command -v az &> /dev/null; then + echo -e "${RED}❌ Azure CLI is not installed${NC}" + echo "Install: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli" + exit 1 +fi + +# Check if logged in to Azure +if ! az account show &> /dev/null; then + echo -e "${YELLOW}⚠️ Not logged in to Azure${NC}" + echo "Please login first:" + echo " az login" + exit 1 +fi + +# Login to ACR (if not already logged in) +echo -e "${GREEN}🔐 Logging in to Azure Container Registry...${NC}" +az acr login --name ${ACR_NAME} || { + echo -e "${YELLOW}⚠️ Could not login to ACR. Trying docker login...${NC}" + # Alternative: use Azure credentials + az acr credential show --name ${ACR_NAME} --query username -o tsv > /tmp/acr_username.txt 2>/dev/null || true + if [ -s /tmp/acr_username.txt ]; then + ACR_USERNAME=$(cat /tmp/acr_username.txt) + ACR_PASSWORD=$(az acr credential show --name ${ACR_NAME} --query passwords[0].value -o tsv) + echo ${ACR_PASSWORD} | docker login ${REGISTRY} -u ${ACR_USERNAME} --password-stdin + rm /tmp/acr_username.txt + else + echo -e "${RED}❌ Could not authenticate with ACR${NC}" + exit 1 + fi +} + +# Build backend +echo "" +echo -e "${GREEN}📦 Building backend image...${NC}" +docker build -t ${REGISTRY}/${REPO_NAME}/backend:${VERSION} \ + -t ${REGISTRY}/${REPO_NAME}/backend:latest \ + -f backend/Dockerfile.prod ./backend + +# Build frontend +echo "" +echo -e "${GREEN}📦 Building frontend image...${NC}" +docker build -t ${REGISTRY}/${REPO_NAME}/frontend:${VERSION} \ + -t ${REGISTRY}/${REPO_NAME}/frontend:latest \ + -f frontend/Dockerfile.prod ./frontend + +# Push images +echo "" +echo -e "${GREEN}📤 Pushing images to Azure Container Registry...${NC}" +docker push ${REGISTRY}/${REPO_NAME}/backend:${VERSION} +docker push ${REGISTRY}/${REPO_NAME}/backend:latest +docker push ${REGISTRY}/${REPO_NAME}/frontend:${VERSION} +docker push ${REGISTRY}/${REPO_NAME}/frontend:latest + +echo "" +echo -e "${BLUE}════════════════════════════════════════${NC}" +echo -e "${GREEN}✅ Build and push complete!${NC}" +echo -e "${BLUE}════════════════════════════════════════${NC}" +echo "" +echo "Images available at:" +echo " Backend: ${REGISTRY}/${REPO_NAME}/backend:${VERSION}" +echo " Frontend: ${REGISTRY}/${REPO_NAME}/frontend:${VERSION}" +echo "" +echo "To view images in Azure Portal:" +echo " https://portal.azure.com -> Container registries -> ${ACR_NAME} -> Repositories" +echo "" +echo "To deploy with docker-compose, update docker-compose.prod.yml with:" +echo " backend:" +echo " image: ${REGISTRY}/${REPO_NAME}/backend:${VERSION}" +echo " frontend:" +echo " image: ${REGISTRY}/${REPO_NAME}/frontend:${VERSION}" diff --git a/scripts/create-acr.sh b/scripts/create-acr.sh new file mode 100755 index 0000000..ecc80af --- /dev/null +++ b/scripts/create-acr.sh @@ -0,0 +1,132 @@ +#!/bin/bash +set -e + +# Script om Azure Container Registry aan te maken +# Gebruik: ./scripts/create-acr.sh [resource-group] [acr-name] [location] + +# Colors +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Default values +RESOURCE_GROUP="${1:-rg-cmdb-gui}" +ACR_NAME="${2:-zuyderlandcmdbacr}" +LOCATION="${3:-westeurope}" +SKU="${4:-Basic}" # Basic, Standard, of Premium + +echo -e "${BLUE}════════════════════════════════════════${NC}" +echo -e "${GREEN}🐳 Azure Container Registry Aanmaken${NC}" +echo -e "${BLUE}════════════════════════════════════════${NC}" +echo "" +echo "Configuratie:" +echo " Resource Group: ${RESOURCE_GROUP}" +echo " ACR Naam: ${ACR_NAME}" +echo " Location: ${LOCATION}" +echo " SKU: ${SKU}" +echo "" + +# Check if Azure CLI is installed +if ! command -v az &> /dev/null; then + echo -e "${YELLOW}❌ Azure CLI is not installed${NC}" + echo "Install: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli" + exit 1 +fi + +# Check if logged in +if ! az account show &> /dev/null; then + echo -e "${YELLOW}⚠️ Not logged in to Azure${NC}" + echo "Logging in..." + az login +fi + +# Show current subscription +echo -e "${GREEN}📋 Huidige Azure Subscription:${NC}" +az account show --query "{Name:name, SubscriptionId:id}" -o table +echo "" + +# Confirm +read -p "Doorgaan met deze configuratie? (y/n) " -n 1 -r +echo +if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo "Geannuleerd." + exit 1 +fi + +# Create resource group (if not exists) +echo "" +echo -e "${GREEN}📦 Resource Group aanmaken...${NC}" +if az group show --name ${RESOURCE_GROUP} &> /dev/null; then + echo " Resource group '${RESOURCE_GROUP}' bestaat al" +else + az group create --name ${RESOURCE_GROUP} --location ${LOCATION} + echo " ✅ Resource group aangemaakt" +fi + +# Check if ACR name is available +echo "" +echo -e "${GREEN}🔍 Controleren of ACR naam beschikbaar is...${NC}" +if az acr check-name --name ${ACR_NAME} --query nameAvailable -o tsv | grep -q "true"; then + echo " ✅ Naam '${ACR_NAME}' is beschikbaar" +else + echo -e "${YELLOW} ⚠️ Naam '${ACR_NAME}' is niet beschikbaar${NC}" + echo " Probeer een andere naam, bijvoorbeeld:" + echo " ${ACR_NAME}1" + echo " ${ACR_NAME}prod" + echo " cmdb${ACR_NAME}" + exit 1 +fi + +# Create ACR +echo "" +echo -e "${GREEN}🐳 Azure Container Registry aanmaken...${NC}" +az acr create \ + --resource-group ${RESOURCE_GROUP} \ + --name ${ACR_NAME} \ + --sku ${SKU} \ + --admin-enabled true + +echo "" +echo -e "${GREEN}✅ Azure Container Registry aangemaakt!${NC}" +echo "" + +# Get credentials +echo -e "${GREEN}🔐 Registry credentials:${NC}" +ACR_USERNAME=$(az acr credential show --name ${ACR_NAME} --query username -o tsv) +ACR_PASSWORD=$(az acr credential show --name ${ACR_NAME} --query passwords[0].value -o tsv) + +echo " Registry URL: ${ACR_NAME}.azurecr.io" +echo " Username: ${ACR_USERNAME}" +echo " Password: ${ACR_PASSWORD}" +echo "" + +# Test login +echo -e "${GREEN}🔍 Test login...${NC}" +echo ${ACR_PASSWORD} | docker login ${ACR_NAME}.azurecr.io -u ${ACR_USERNAME} --password-stdin + +if [ $? -eq 0 ]; then + echo " ✅ Login succesvol!" +else + echo -e "${YELLOW} ⚠️ Docker login mislukt (Docker moet geïnstalleerd zijn)${NC}" +fi + +echo "" +echo -e "${BLUE}════════════════════════════════════════${NC}" +echo -e "${GREEN}📝 Volgende stappen:${NC}" +echo -e "${BLUE}════════════════════════════════════════${NC}" +echo "" +echo "1. Pas azure-pipelines.yml aan:" +echo " acrName: '${ACR_NAME}'" +echo "" +echo "2. Maak Service Connection in Azure DevOps:" +echo " - Project Settings → Service connections → New" +echo " - Docker Registry → Azure Container Registry" +echo " - Selecteer: ${ACR_NAME}" +echo " - Naam: zuyderland-cmdb-acr-connection" +echo "" +echo "3. Update azure-pipelines.yml service connection naam" +echo "" +echo "4. Run de pipeline!" +echo "" +echo "📚 Zie docs/AZURE-DEVOPS-SETUP.md voor volledige instructies"