Consolidate documentation and update backend services
- Reorganize docs into 'Core deployment guides' and 'Setup and configuration' subdirectories - Consolidate redundant documentation files (ACR, pipelines, deployment guides) - Add documentation consolidation plan - Update backend database factory and logger services - Update migration script and docker-compose configurations - Add PostgreSQL setup script
This commit is contained in:
270
docs/Setup and configuration/AZURE-CLI-QUICKSTART.md
Normal file
270
docs/Setup and configuration/AZURE-CLI-QUICKSTART.md
Normal file
@@ -0,0 +1,270 @@
|
||||
# Azure CLI - Quick Start Guide
|
||||
|
||||
## 📍 Waar voer je deze commando's uit?
|
||||
|
||||
Je voert deze commando's uit in de **Terminal** (command line) op je computer.
|
||||
|
||||
---
|
||||
|
||||
## 🖥️ Terminal Openen
|
||||
|
||||
### Op macOS (jouw situatie):
|
||||
1. **Open Terminal:**
|
||||
- Druk op `Cmd + Space` (Spotlight)
|
||||
- Typ "Terminal"
|
||||
- Druk Enter
|
||||
- Of: Applications → Utilities → Terminal
|
||||
|
||||
2. **Of gebruik iTerm2** (als je die hebt geïnstalleerd)
|
||||
|
||||
### Op Windows:
|
||||
- **PowerShell** of **Command Prompt**
|
||||
- Druk `Win + R`, typ `powershell`, Enter
|
||||
|
||||
### Op Linux:
|
||||
- Open je terminal emulator (bijv. GNOME Terminal, Konsole)
|
||||
|
||||
---
|
||||
|
||||
## ✅ Stap 1: Check of Azure CLI Geïnstalleerd is
|
||||
|
||||
**Voer dit commando uit in de terminal:**
|
||||
|
||||
```bash
|
||||
az --version
|
||||
```
|
||||
|
||||
**Als je een versie ziet** (bijv. `azure-cli 2.50.0`): ✅ Azure CLI is geïnstalleerd, ga door naar Stap 2.
|
||||
|
||||
**Als je een foutmelding krijgt** (bijv. `command not found`): ❌ Azure CLI is niet geïnstalleerd, zie installatie hieronder.
|
||||
|
||||
---
|
||||
|
||||
## 📥 Stap 2: Azure CLI Installeren (als nodig)
|
||||
|
||||
### Op macOS:
|
||||
|
||||
**Optie A: Met Homebrew (Aanbevolen)**
|
||||
```bash
|
||||
# Installeer Homebrew (als je die nog niet hebt)
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
|
||||
# Installeer Azure CLI
|
||||
brew install azure-cli
|
||||
```
|
||||
|
||||
**Optie B: Met Installer**
|
||||
1. Download: https://aka.ms/installazureclimac
|
||||
2. Open het `.pkg` bestand
|
||||
3. Volg de installatie wizard
|
||||
|
||||
**Optie C: Met pip (Python)**
|
||||
```bash
|
||||
pip3 install azure-cli
|
||||
```
|
||||
|
||||
### Op Windows:
|
||||
1. Download: https://aka.ms/installazurecliwindows
|
||||
2. Run de `.msi` installer
|
||||
3. Volg de installatie wizard
|
||||
|
||||
### Op Linux:
|
||||
```bash
|
||||
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
|
||||
```
|
||||
|
||||
**Na installatie, check opnieuw:**
|
||||
```bash
|
||||
az --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Stap 3: Login bij Azure
|
||||
|
||||
**Voer dit commando uit:**
|
||||
|
||||
```bash
|
||||
az login
|
||||
```
|
||||
|
||||
**Wat gebeurt er:**
|
||||
1. Je browser opent automatisch
|
||||
2. Log in met je Azure account (hetzelfde account dat je gebruikt voor Azure Portal)
|
||||
3. Na succesvol inloggen, sluit je de browser
|
||||
4. De terminal toont je subscriptions
|
||||
|
||||
**Als browser niet opent automatisch:**
|
||||
- Je krijgt een code en URL in de terminal
|
||||
- Kopieer de code
|
||||
- Open de URL in je browser
|
||||
- Voer de code in
|
||||
|
||||
**Verwachte output:**
|
||||
```
|
||||
[
|
||||
{
|
||||
"cloudName": "AzureCloud",
|
||||
"id": "12345678-1234-1234-1234-123456789012",
|
||||
"name": "Subscription Name",
|
||||
"state": "Enabled",
|
||||
...
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
**✅ Je bent nu ingelogd!**
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Stap 4: Haal ACR Credentials Op
|
||||
|
||||
**Voer dit commando uit:**
|
||||
|
||||
```bash
|
||||
az acr credential show --name zdlas
|
||||
```
|
||||
|
||||
**Verwachte output:**
|
||||
```json
|
||||
{
|
||||
"passwords": [
|
||||
{
|
||||
"name": "password",
|
||||
"value": "abc123xyz..."
|
||||
},
|
||||
{
|
||||
"name": "password2",
|
||||
"value": "def456uvw..."
|
||||
}
|
||||
],
|
||||
"username": "zdlas"
|
||||
}
|
||||
```
|
||||
|
||||
**Noteer:**
|
||||
- **Username**: `zdlas` (of wat er staat)
|
||||
- **Password**: Gebruik `passwords[0].value` (de eerste password)
|
||||
|
||||
**⚠️ Belangrijk:** Deze credentials zijn gevoelig! Deel ze niet en gebruik ze alleen voor de service connection.
|
||||
|
||||
---
|
||||
|
||||
## 📋 Complete Stappen in Terminal
|
||||
|
||||
**Hier is de complete reeks commando's:**
|
||||
|
||||
```bash
|
||||
# 1. Check of Azure CLI geïnstalleerd is
|
||||
az --version
|
||||
|
||||
# 2. Login bij Azure (opent browser)
|
||||
az login
|
||||
|
||||
# 3. Haal ACR credentials op
|
||||
az acr credential show --name zdlas
|
||||
```
|
||||
|
||||
**Kopieer de output** en gebruik de `username` en `passwords[0].value` in Azure DevOps.
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Alternatief: Via Azure Portal (Zonder Azure CLI)
|
||||
|
||||
**Als je Azure CLI niet wilt installeren, kun je credentials ook via Azure Portal ophalen:**
|
||||
|
||||
1. **Ga naar Azure Portal**: https://portal.azure.com
|
||||
2. **Ga naar je Container Registry**: Zoek naar `zdlas`
|
||||
3. **Klik op "Access keys"** (links in het menu)
|
||||
4. **Je ziet:**
|
||||
- **Login server**: `zdlas.azurecr.io`
|
||||
- **Username**: `zdlas` (of admin username)
|
||||
- **Password**: Klik op "Show" naast password om het te zien
|
||||
- **Password2**: Alternatieve password
|
||||
|
||||
5. **Kopieer de username en password**
|
||||
|
||||
**✅ Dit is hetzelfde als `az acr credential show`!**
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Voor Jouw Situatie (Service Connection)
|
||||
|
||||
**Gebruik deze credentials in Azure DevOps:**
|
||||
|
||||
1. **In de service connection wizard:**
|
||||
- Kies "Docker Registry" → "Others"
|
||||
- **Docker Registry**: `zdlas.azurecr.io`
|
||||
- **Docker ID**: `zdlas` (of de username uit de output)
|
||||
- **Docker Password**: `passwords[0].value` (uit de output)
|
||||
- **Service connection name**: `zuyderland-cmdb-acr-connection`
|
||||
|
||||
2. **Save**
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Troubleshooting
|
||||
|
||||
### "az: command not found"
|
||||
|
||||
**Oplossing:** Azure CLI is niet geïnstalleerd
|
||||
- Installeer Azure CLI (zie Stap 2 hierboven)
|
||||
- Of gebruik Azure Portal alternatief (zie hierboven)
|
||||
|
||||
### "az login" opent geen browser
|
||||
|
||||
**Oplossing:**
|
||||
- Kopieer de code en URL uit de terminal
|
||||
- Open de URL handmatig in je browser
|
||||
- Voer de code in
|
||||
|
||||
### "Subscription not found" of "Access denied"
|
||||
|
||||
**Oplossing:**
|
||||
- Check of je ingelogd bent met het juiste Azure account
|
||||
- Check of je toegang hebt tot de subscription waar de ACR staat
|
||||
- Probeer: `az account list` om je subscriptions te zien
|
||||
- Selecteer de juiste subscription: `az account set --subscription "Subscription Name"`
|
||||
|
||||
### "ACR not found"
|
||||
|
||||
**Oplossing:**
|
||||
- Check of de ACR naam correct is: `zdlas`
|
||||
- Check of je toegang hebt tot de ACR
|
||||
- Probeer: `az acr list` om alle ACR's te zien
|
||||
|
||||
---
|
||||
|
||||
## 💡 Tips
|
||||
|
||||
1. **Azure CLI blijft ingelogd** - Je hoeft niet elke keer `az login` te doen
|
||||
2. **Check je subscription** - Als je meerdere subscriptions hebt: `az account show`
|
||||
3. **Wissel subscription** - `az account set --subscription "Subscription Name"`
|
||||
4. **Logout** - `az logout` (als je klaar bent)
|
||||
|
||||
---
|
||||
|
||||
## 📚 Meer Informatie
|
||||
|
||||
- [Azure CLI Installatie](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli)
|
||||
- [Azure CLI Login](https://learn.microsoft.com/en-us/cli/azure/authenticate-azure-cli)
|
||||
- [ACR Credentials](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication)
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Quick Reference
|
||||
|
||||
**Terminal openen:**
|
||||
- macOS: `Cmd + Space` → "Terminal"
|
||||
|
||||
**Azure CLI commando's:**
|
||||
```bash
|
||||
az --version # Check installatie
|
||||
az login # Login bij Azure
|
||||
az acr credential show --name zdlas # Haal credentials op
|
||||
```
|
||||
|
||||
**Azure Portal alternatief:**
|
||||
- Portal → Container Registry → Access keys
|
||||
|
||||
**Klaar!** 🚀
|
||||
310
docs/Setup and configuration/AZURE-DEVOPS-SETUP.md
Normal file
310
docs/Setup and configuration/AZURE-DEVOPS-SETUP.md
Normal file
@@ -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-SETUP.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: 'cmdb-insight'
|
||||
|
||||
# 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: **"CMDB Insight"** (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/cmdb-insight/backend:123
|
||||
Frontend Image: zuyderlandcmdbacr.azurecr.io/cmdb-insight/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:
|
||||
- `cmdb-insight/backend`
|
||||
- `cmdb-insight/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 cmdb-insight/backend
|
||||
|
||||
# Lijst tags voor frontend
|
||||
az acr repository show-tags --name zuyderlandcmdbacr --repository cmdb-insight/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/cmdb-insight/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/cmdb-insight/backend:latest \
|
||||
--registry-login-server zuyderlandcmdbacr.azurecr.io \
|
||||
--registry-username <acr-username> \
|
||||
--registry-password <acr-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 cmdb-insight/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
|
||||
943
docs/Setup and configuration/AZURE-NEW-SUBSCRIPTION-SETUP.md
Normal file
943
docs/Setup and configuration/AZURE-NEW-SUBSCRIPTION-SETUP.md
Normal file
@@ -0,0 +1,943 @@
|
||||
# Azure New Subscription Setup Guide
|
||||
|
||||
Complete guide for setting up all required Azure resources for CMDB Insight in a new Azure subscription.
|
||||
|
||||
## 📋 Overview
|
||||
|
||||
This guide will help you create and configure all necessary Azure resources to deploy the CMDB Insight application. The setup includes:
|
||||
|
||||
### Required Resources
|
||||
|
||||
1. **Resource Group** - Container for all resources
|
||||
2. **Azure Container Registry (ACR)** - Store Docker images
|
||||
3. **Azure Database for PostgreSQL** - Production database (recommended)
|
||||
4. **Azure Key Vault** - Secure storage for secrets
|
||||
5. **Azure App Service Plan** - Hosting plan for web apps
|
||||
6. **Azure App Service (Backend)** - Backend API service
|
||||
7. **Azure App Service (Frontend)** - Frontend web application
|
||||
8. **Application Insights** - Monitoring and logging
|
||||
9. **DNS & SSL** - Custom domain and HTTPS certificate
|
||||
|
||||
### Estimated Costs
|
||||
|
||||
- **Basic Setup (SQLite)**: €17-35/month
|
||||
- **Recommended Setup (PostgreSQL)**: €36-62/month
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Prerequisites
|
||||
|
||||
Before starting, ensure you have:
|
||||
|
||||
- [ ] Azure CLI installed (`az --version`)
|
||||
- [ ] Azure subscription with appropriate permissions
|
||||
- [ ] Docker installed (for local testing)
|
||||
- [ ] Access to Azure Portal
|
||||
- [ ] Jira credentials (OAuth client ID/secret or Personal Access Token)
|
||||
|
||||
### Install Azure CLI (if needed)
|
||||
|
||||
```bash
|
||||
# macOS
|
||||
brew install azure-cli
|
||||
|
||||
# Linux
|
||||
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
|
||||
|
||||
# Windows
|
||||
# Download from: https://aka.ms/installazurecliwindows
|
||||
```
|
||||
|
||||
### Login to Azure
|
||||
|
||||
```bash
|
||||
az login
|
||||
az account list --output table
|
||||
az account set --subscription "<subscription-id-or-name>"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📦 Step 1: Create Resource Group
|
||||
|
||||
Create a resource group to organize all resources:
|
||||
|
||||
```bash
|
||||
# Set variables (customize as needed)
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
LOCATION="westeurope" # or your preferred region
|
||||
|
||||
# Create resource group
|
||||
az group create \
|
||||
--name $RESOURCE_GROUP \
|
||||
--location $LOCATION
|
||||
|
||||
# Verify
|
||||
az group show --name $RESOURCE_GROUP
|
||||
```
|
||||
|
||||
**Note**: Choose a location close to your users. Common options:
|
||||
- `westeurope` (Netherlands, Germany)
|
||||
- `northeurope` (Ireland, UK)
|
||||
- `eastus` (US East)
|
||||
|
||||
---
|
||||
|
||||
## 🐳 Step 2: Create or Use Existing Azure Container Registry (ACR)
|
||||
|
||||
**Important**: Azure Container Registry can be **shared across multiple applications**. The repository name (`cmdb-insight`) is what separates this application from others in the same ACR.
|
||||
|
||||
### Option A: Use Existing ACR (Recommended if you have one)
|
||||
|
||||
If you already have an ACR for other applications, you can reuse it:
|
||||
|
||||
```bash
|
||||
# Set variables - use your existing ACR name
|
||||
ACR_NAME="your-existing-acr" # Your existing ACR name
|
||||
ACR_RESOURCE_GROUP="rg-shared-services" # Resource group where ACR exists
|
||||
|
||||
# Verify ACR exists
|
||||
az acr show --name $ACR_NAME --resource-group $ACR_RESOURCE_GROUP
|
||||
|
||||
# Get ACR login server
|
||||
ACR_LOGIN_SERVER=$(az acr show --name $ACR_NAME --resource-group $ACR_RESOURCE_GROUP --query loginServer --output tsv)
|
||||
echo "ACR Login Server: $ACR_LOGIN_SERVER"
|
||||
```
|
||||
|
||||
**Benefits of reusing ACR**:
|
||||
- ✅ Cost savings (one ACR for all apps)
|
||||
- ✅ Centralized image management
|
||||
- ✅ Easier to share images across teams
|
||||
- ✅ Better resource utilization
|
||||
|
||||
### Option B: Create New ACR
|
||||
|
||||
If you don't have an ACR yet, create one:
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
ACR_NAME="yourcompanyacr" # Must be globally unique, lowercase, 5-50 chars, alphanumeric only
|
||||
ACR_RESOURCE_GROUP="rg-shared-services" # Or use your app resource group
|
||||
SKU="Standard" # Options: Basic, Standard, Premium
|
||||
|
||||
# Create resource group for shared services (if needed)
|
||||
az group create --name $ACR_RESOURCE_GROUP --location westeurope
|
||||
|
||||
# Create ACR
|
||||
az acr create \
|
||||
--resource-group $ACR_RESOURCE_GROUP \
|
||||
--name $ACR_NAME \
|
||||
--sku $SKU \
|
||||
--admin-enabled true
|
||||
|
||||
# Get ACR login server
|
||||
ACR_LOGIN_SERVER=$(az acr show --name $ACR_NAME --resource-group $ACR_RESOURCE_GROUP --query loginServer --output tsv)
|
||||
echo "ACR Login Server: $ACR_LOGIN_SERVER"
|
||||
|
||||
# Get admin credentials (save these securely)
|
||||
az acr credential show --name $ACR_NAME
|
||||
```
|
||||
|
||||
**ACR SKU Comparison**:
|
||||
- **Basic**: €5/month - Development/test, 10GB storage
|
||||
- **Standard**: €20/month - Production, 100GB storage, geo-replication (recommended)
|
||||
- **Premium**: €50/month - Enterprise, 500GB storage, advanced security
|
||||
|
||||
**Repository Structure in ACR**:
|
||||
```
|
||||
yourcompanyacr.azurecr.io/
|
||||
├── cmdb-insight/ ← This application
|
||||
│ ├── backend:latest
|
||||
│ └── frontend:latest
|
||||
├── other-app/ ← Other applications
|
||||
│ ├── api:latest
|
||||
│ └── web:latest
|
||||
└── shared-services/ ← Shared images
|
||||
└── nginx:latest
|
||||
```
|
||||
|
||||
### Test ACR Connection
|
||||
|
||||
```bash
|
||||
# Login to ACR
|
||||
az acr login --name $ACR_NAME
|
||||
|
||||
# Verify
|
||||
az acr repository list --name $ACR_NAME
|
||||
|
||||
# List repositories (you'll see cmdb-insight after first push)
|
||||
az acr repository list --name $ACR_NAME --output table
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🗄️ Step 3: Create Azure Database for PostgreSQL
|
||||
|
||||
PostgreSQL is recommended for production. Alternatively, you can use SQLite with Azure Storage (see Step 3B).
|
||||
|
||||
### Step 3A: PostgreSQL (Recommended)
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
DB_SERVER_NAME="cmdb-postgres-prod" # Must be globally unique
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
DB_ADMIN_USER="cmdbadmin"
|
||||
DB_ADMIN_PASSWORD="<generate-secure-password>" # Use a strong password!
|
||||
DB_NAME="cmdb"
|
||||
SKU="Standard_B1ms" # Burstable tier, 1 vCore, 2GB RAM
|
||||
|
||||
# Generate secure password (save this!)
|
||||
DB_ADMIN_PASSWORD=$(openssl rand -base64 32)
|
||||
echo "Database Password: $DB_ADMIN_PASSWORD"
|
||||
|
||||
# Create PostgreSQL Flexible Server
|
||||
az postgres flexible-server create \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--name $DB_SERVER_NAME \
|
||||
--location westeurope \
|
||||
--admin-user $DB_ADMIN_USER \
|
||||
--admin-password $DB_ADMIN_PASSWORD \
|
||||
--sku-name $SKU \
|
||||
--tier Burstable \
|
||||
--storage-size 32 \
|
||||
--version 15 \
|
||||
--public-access 0.0.0.0 # Allow Azure services (restrict later if needed)
|
||||
|
||||
# Create database
|
||||
az postgres flexible-server db create \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--server-name $DB_SERVER_NAME \
|
||||
--database-name $DB_NAME
|
||||
|
||||
# Get connection string
|
||||
DB_CONNECTION_STRING="postgresql://${DB_ADMIN_USER}:${DB_ADMIN_PASSWORD}@${DB_SERVER_NAME}.postgres.database.azure.com:5432/${DB_NAME}?sslmode=require"
|
||||
echo "Database Connection String: $DB_CONNECTION_STRING"
|
||||
|
||||
# Save connection details securely
|
||||
echo "DB_HOST=${DB_SERVER_NAME}.postgres.database.azure.com" > .env.azure
|
||||
echo "DB_USER=${DB_ADMIN_USER}" >> .env.azure
|
||||
echo "DB_PASSWORD=${DB_ADMIN_PASSWORD}" >> .env.azure
|
||||
echo "DB_NAME=${DB_NAME}" >> .env.azure
|
||||
```
|
||||
|
||||
**PostgreSQL SKU Options**:
|
||||
- **Standard_B1ms**: €20-30/month - 1 vCore, 2GB RAM (recommended for 20 users)
|
||||
- **Standard_B2s**: €40-50/month - 2 vCores, 4GB RAM (for growth)
|
||||
- **Standard_D2s_v3**: €100+/month - 2 vCores, 8GB RAM (high performance)
|
||||
|
||||
### Step 3B: SQLite with Azure Storage (Alternative)
|
||||
|
||||
If you prefer to use SQLite (simpler, but less scalable):
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
STORAGE_ACCOUNT_NAME="cmdbstorage$(openssl rand -hex 4)" # Must be globally unique, lowercase
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
|
||||
# Create storage account
|
||||
az storage account create \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--name $STORAGE_ACCOUNT_NAME \
|
||||
--location westeurope \
|
||||
--sku Standard_LRS
|
||||
|
||||
# Get storage account key
|
||||
STORAGE_KEY=$(az storage account keys list \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--account-name $STORAGE_ACCOUNT_NAME \
|
||||
--query "[0].value" --output tsv)
|
||||
|
||||
echo "Storage Account: $STORAGE_ACCOUNT_NAME"
|
||||
echo "Storage Key: $STORAGE_KEY"
|
||||
```
|
||||
|
||||
**Note**: SQLite works but has limitations with concurrent users. PostgreSQL is recommended for production.
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Step 4: Create Azure Key Vault
|
||||
|
||||
Key Vault securely stores secrets like API keys, passwords, and tokens.
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
KEY_VAULT_NAME="kv-cmdb-insight-prod" # Must be globally unique
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
|
||||
# Create Key Vault
|
||||
az keyvault create \
|
||||
--name $KEY_VAULT_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--location westeurope \
|
||||
--sku standard
|
||||
|
||||
# Verify
|
||||
az keyvault show --name $KEY_VAULT_NAME --resource-group $RESOURCE_GROUP
|
||||
```
|
||||
|
||||
### Add Secrets to Key Vault
|
||||
|
||||
```bash
|
||||
# Set your actual values
|
||||
JIRA_PAT="your-jira-personal-access-token"
|
||||
SESSION_SECRET=$(openssl rand -hex 32)
|
||||
JIRA_OAUTH_CLIENT_ID="your-oauth-client-id"
|
||||
JIRA_OAUTH_CLIENT_SECRET="your-oauth-client-secret"
|
||||
JIRA_SCHEMA_ID="your-schema-id"
|
||||
|
||||
# Add secrets
|
||||
az keyvault secret set \
|
||||
--vault-name $KEY_VAULT_NAME \
|
||||
--name "JiraPat" \
|
||||
--value "$JIRA_PAT"
|
||||
|
||||
az keyvault secret set \
|
||||
--vault-name $KEY_VAULT_NAME \
|
||||
--name "SessionSecret" \
|
||||
--value "$SESSION_SECRET"
|
||||
|
||||
az keyvault secret set \
|
||||
--vault-name $KEY_VAULT_NAME \
|
||||
--name "JiraOAuthClientId" \
|
||||
--value "$JIRA_OAUTH_CLIENT_ID"
|
||||
|
||||
az keyvault secret set \
|
||||
--vault-name $KEY_VAULT_NAME \
|
||||
--name "JiraOAuthClientSecret" \
|
||||
--value "$JIRA_OAUTH_CLIENT_SECRET"
|
||||
|
||||
az keyvault secret set \
|
||||
--vault-name $KEY_VAULT_NAME \
|
||||
--name "JiraSchemaId" \
|
||||
--value "$JIRA_SCHEMA_ID"
|
||||
|
||||
# If using PostgreSQL, add database password
|
||||
az keyvault secret set \
|
||||
--vault-name $KEY_VAULT_NAME \
|
||||
--name "DatabasePassword" \
|
||||
--value "$DB_ADMIN_PASSWORD"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Step 5: Create Application Insights
|
||||
|
||||
Application Insights provides monitoring, logging, and performance metrics.
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
APP_INSIGHTS_NAME="appi-cmdb-insight-prod"
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
|
||||
# Create Application Insights
|
||||
az monitor app-insights component create \
|
||||
--app $APP_INSIGHTS_NAME \
|
||||
--location westeurope \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--application-type web
|
||||
|
||||
# Get Instrumentation Key
|
||||
INSTRUMENTATION_KEY=$(az monitor app-insights component show \
|
||||
--app $APP_INSIGHTS_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--query instrumentationKey --output tsv)
|
||||
|
||||
echo "Instrumentation Key: $INSTRUMENTATION_KEY"
|
||||
```
|
||||
|
||||
**Note**: Application Insights Basic tier is free up to 5GB/month, which is sufficient for most small applications.
|
||||
|
||||
---
|
||||
|
||||
## 🖥️ Step 6: Create App Service Plan
|
||||
|
||||
App Service Plan defines the compute resources for your web apps.
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
APP_SERVICE_PLAN_NAME="plan-cmdb-insight-prod"
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
SKU="B1" # Basic tier, 1 vCore, 1.75GB RAM
|
||||
|
||||
# Create App Service Plan (Linux)
|
||||
az appservice plan create \
|
||||
--name $APP_SERVICE_PLAN_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--sku $SKU \
|
||||
--is-linux
|
||||
|
||||
# Verify
|
||||
az appservice plan show --name $APP_SERVICE_PLAN_NAME --resource-group $RESOURCE_GROUP
|
||||
```
|
||||
|
||||
**App Service Plan SKU Options**:
|
||||
- **B1**: €15-25/month - 1 vCore, 1.75GB RAM (recommended for 20 users)
|
||||
- **B2**: €30-40/month - 2 vCores, 3.5GB RAM
|
||||
- **S1**: €50-70/month - 1 vCore, 1.75GB RAM (Standard tier, better performance)
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Step 7: Create App Services (Backend & Frontend)
|
||||
|
||||
Create two web apps: one for backend API and one for frontend.
|
||||
|
||||
### Step 7A: Create Backend App Service
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
BACKEND_APP_NAME="cmdb-backend-prod" # Must be globally unique
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
APP_SERVICE_PLAN_NAME="plan-cmdb-insight-prod"
|
||||
ACR_NAME="cmdbinsightacr" # From Step 2
|
||||
|
||||
# Create backend web app
|
||||
az webapp create \
|
||||
--name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--plan $APP_SERVICE_PLAN_NAME \
|
||||
--deployment-container-image-name "${ACR_NAME}.azurecr.io/cmdb-insight/backend:latest"
|
||||
|
||||
# Enable Managed Identity (for ACR access)
|
||||
az webapp identity assign \
|
||||
--name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP
|
||||
|
||||
# Get Managed Identity Principal ID
|
||||
BACKEND_PRINCIPAL_ID=$(az webapp identity show \
|
||||
--name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--query principalId --output tsv)
|
||||
|
||||
# Grant ACR pull permissions
|
||||
ACR_ID=$(az acr show --name $ACR_NAME --resource-group $RESOURCE_GROUP --query id --output tsv)
|
||||
az role assignment create \
|
||||
--assignee $BACKEND_PRINCIPAL_ID \
|
||||
--role AcrPull \
|
||||
--scope $ACR_ID
|
||||
|
||||
# Configure container settings
|
||||
az webapp config container set \
|
||||
--name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--docker-custom-image-name "${ACR_NAME}.azurecr.io/cmdb-insight/backend:latest" \
|
||||
--docker-registry-server-url "https://${ACR_NAME}.azurecr.io"
|
||||
|
||||
# Set environment variables
|
||||
az webapp config appsettings set \
|
||||
--name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--settings \
|
||||
NODE_ENV=production \
|
||||
PORT=3001 \
|
||||
DATABASE_TYPE=postgres \
|
||||
DATABASE_URL="@Microsoft.KeyVault(SecretUri=https://${KEY_VAULT_NAME}.vault.azure.net/secrets/DatabasePassword/)" \
|
||||
JIRA_HOST=https://jira.zuyderland.nl \
|
||||
JIRA_AUTH_METHOD=oauth \
|
||||
JIRA_OAUTH_CLIENT_ID="@Microsoft.KeyVault(SecretUri=https://${KEY_VAULT_NAME}.vault.azure.net/secrets/JiraOAuthClientId/)" \
|
||||
JIRA_OAUTH_CLIENT_SECRET="@Microsoft.KeyVault(SecretUri=https://${KEY_VAULT_NAME}.vault.azure.net/secrets/JiraOAuthClientSecret/)" \
|
||||
JIRA_OAUTH_CALLBACK_URL="https://${BACKEND_APP_NAME}.azurewebsites.net/api/auth/callback" \
|
||||
JIRA_SCHEMA_ID="@Microsoft.KeyVault(SecretUri=https://${KEY_VAULT_NAME}.vault.azure.net/secrets/JiraSchemaId/)" \
|
||||
SESSION_SECRET="@Microsoft.KeyVault(SecretUri=https://${KEY_VAULT_NAME}.vault.azure.net/secrets/SessionSecret/)" \
|
||||
FRONTEND_URL="https://${FRONTEND_APP_NAME}.azurewebsites.net" \
|
||||
APPINSIGHTS_INSTRUMENTATIONKEY="${INSTRUMENTATION_KEY}"
|
||||
|
||||
# Grant Key Vault access to backend
|
||||
az keyvault set-policy \
|
||||
--name $KEY_VAULT_NAME \
|
||||
--object-id $BACKEND_PRINCIPAL_ID \
|
||||
--secret-permissions get list
|
||||
|
||||
# Enable HTTPS only
|
||||
az webapp update \
|
||||
--name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--https-only true
|
||||
```
|
||||
|
||||
### Step 7B: Create Frontend App Service
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
FRONTEND_APP_NAME="cmdb-frontend-prod" # Must be globally unique
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
APP_SERVICE_PLAN_NAME="plan-cmdb-insight-prod"
|
||||
ACR_NAME="cmdbinsightacr" # From Step 2
|
||||
|
||||
# Create frontend web app
|
||||
az webapp create \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--plan $APP_SERVICE_PLAN_NAME \
|
||||
--deployment-container-image-name "${ACR_NAME}.azurecr.io/cmdb-insight/frontend:latest"
|
||||
|
||||
# Enable Managed Identity
|
||||
az webapp identity assign \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP
|
||||
|
||||
# Get Managed Identity Principal ID
|
||||
FRONTEND_PRINCIPAL_ID=$(az webapp identity show \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--query principalId --output tsv)
|
||||
|
||||
# Grant ACR pull permissions
|
||||
az role assignment create \
|
||||
--assignee $FRONTEND_PRINCIPAL_ID \
|
||||
--role AcrPull \
|
||||
--scope $ACR_ID
|
||||
|
||||
# Configure container settings
|
||||
az webapp config container set \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--docker-custom-image-name "${ACR_NAME}.azurecr.io/cmdb-insight/frontend:latest" \
|
||||
--docker-registry-server-url "https://${ACR_NAME}.azurecr.io"
|
||||
|
||||
# Set environment variables
|
||||
az webapp config appsettings set \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--settings \
|
||||
VITE_API_URL="https://${BACKEND_APP_NAME}.azurewebsites.net/api"
|
||||
|
||||
# Enable HTTPS only
|
||||
az webapp update \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--https-only true
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Step 8: Build and Push Docker Images
|
||||
|
||||
Before the apps can run, you need to build and push Docker images to ACR.
|
||||
|
||||
### Option A: Using Script (Recommended)
|
||||
|
||||
```bash
|
||||
# Navigate to project root
|
||||
cd /path/to/cmdb-insight
|
||||
|
||||
# Set environment variables
|
||||
export ACR_NAME="cmdbinsightacr" # Your ACR name
|
||||
export REPO_NAME="cmdb-insight"
|
||||
|
||||
# Build and push
|
||||
./scripts/build-and-push-azure.sh
|
||||
```
|
||||
|
||||
### Option B: Manual Build and Push
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
ACR_NAME="cmdbinsightacr"
|
||||
REGISTRY="${ACR_NAME}.azurecr.io"
|
||||
REPO_NAME="cmdb-insight"
|
||||
|
||||
# Login to ACR
|
||||
az acr login --name $ACR_NAME
|
||||
|
||||
# Build backend
|
||||
docker build -t ${REGISTRY}/${REPO_NAME}/backend:latest \
|
||||
-f backend/Dockerfile.prod ./backend
|
||||
|
||||
# Build frontend
|
||||
docker build -t ${REGISTRY}/${REPO_NAME}/frontend:latest \
|
||||
-f frontend/Dockerfile.prod ./frontend
|
||||
|
||||
# Push images
|
||||
docker push ${REGISTRY}/${REPO_NAME}/backend:latest
|
||||
docker push ${REGISTRY}/${REPO_NAME}/frontend:latest
|
||||
|
||||
# Verify
|
||||
az acr repository list --name $ACR_NAME
|
||||
az acr repository show-tags --name $ACR_NAME --repository ${REPO_NAME}/backend
|
||||
az acr repository show-tags --name $ACR_NAME --repository ${REPO_NAME}/frontend
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Step 9: Configure Custom Domain and SSL (Optional)
|
||||
|
||||
If you have a custom domain (e.g., `cmdb.yourcompany.com`):
|
||||
|
||||
### Step 9A: Add Custom Domain
|
||||
|
||||
```bash
|
||||
# Set variables
|
||||
FRONTEND_APP_NAME="cmdb-frontend-prod"
|
||||
BACKEND_APP_NAME="cmdb-backend-prod"
|
||||
CUSTOM_DOMAIN="cmdb.yourcompany.com"
|
||||
RESOURCE_GROUP="rg-cmdb-insight-prod"
|
||||
|
||||
# Add custom domain to frontend
|
||||
az webapp config hostname add \
|
||||
--webapp-name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--hostname $CUSTOM_DOMAIN
|
||||
|
||||
# Add custom domain to backend (if needed)
|
||||
az webapp config hostname add \
|
||||
--webapp-name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--hostname "api.${CUSTOM_DOMAIN}"
|
||||
```
|
||||
|
||||
### Step 9B: Configure SSL Certificate
|
||||
|
||||
**Option 1: App Service Managed Certificate (Free, Recommended)**
|
||||
|
||||
```bash
|
||||
# Create managed certificate for frontend
|
||||
az webapp config ssl create \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--hostname $CUSTOM_DOMAIN
|
||||
|
||||
# Bind certificate
|
||||
az webapp config ssl bind \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--certificate-thumbprint <thumbprint> \
|
||||
--ssl-type SNI
|
||||
```
|
||||
|
||||
**Option 2: Import Existing Certificate**
|
||||
|
||||
```bash
|
||||
# Upload certificate
|
||||
az webapp config ssl upload \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--certificate-file /path/to/certificate.pfx \
|
||||
--certificate-password <password>
|
||||
```
|
||||
|
||||
**Note**: You'll need to update DNS records to point to your App Service. Get the IP address:
|
||||
|
||||
```bash
|
||||
az webapp show --name $FRONTEND_APP_NAME --resource-group $RESOURCE_GROUP --query defaultHostName
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ Step 10: Verify Deployment
|
||||
|
||||
### Check App Status
|
||||
|
||||
```bash
|
||||
# Check backend
|
||||
az webapp show --name $BACKEND_APP_NAME --resource-group $RESOURCE_GROUP --query state
|
||||
|
||||
# Check frontend
|
||||
az webapp show --name $FRONTEND_APP_NAME --resource-group $RESOURCE_GROUP --query state
|
||||
|
||||
# Start apps if needed
|
||||
az webapp start --name $BACKEND_APP_NAME --resource-group $RESOURCE_GROUP
|
||||
az webapp start --name $FRONTEND_APP_NAME --resource-group $RESOURCE_GROUP
|
||||
```
|
||||
|
||||
### Test Health Endpoints
|
||||
|
||||
```bash
|
||||
# Backend health check
|
||||
curl https://${BACKEND_APP_NAME}.azurewebsites.net/api/health
|
||||
|
||||
# Frontend
|
||||
curl https://${FRONTEND_APP_NAME}.azurewebsites.net
|
||||
```
|
||||
|
||||
### View Logs
|
||||
|
||||
```bash
|
||||
# Backend logs
|
||||
az webapp log tail --name $BACKEND_APP_NAME --resource-group $RESOURCE_GROUP
|
||||
|
||||
# Frontend logs
|
||||
az webapp log tail --name $FRONTEND_APP_NAME --resource-group $RESOURCE_GROUP
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Step 11: Configure Database Schema
|
||||
|
||||
If using PostgreSQL, you need to initialize the database schema:
|
||||
|
||||
```bash
|
||||
# Connect to database and run schema initialization
|
||||
# Option 1: Using psql
|
||||
psql "postgresql://${DB_ADMIN_USER}:${DB_ADMIN_PASSWORD}@${DB_SERVER_NAME}.postgres.database.azure.com:5432/${DB_NAME}?sslmode=require"
|
||||
|
||||
# Option 2: Using Azure Cloud Shell or local script
|
||||
# The application will create tables automatically on first run
|
||||
# Or use the migration scripts in backend/scripts/
|
||||
```
|
||||
|
||||
**Note**: The application will automatically create the required database schema on first startup if it doesn't exist.
|
||||
|
||||
---
|
||||
|
||||
## 📝 Step 12: Update Environment Variables (If Needed)
|
||||
|
||||
If you need to update any configuration:
|
||||
|
||||
```bash
|
||||
# Update backend settings
|
||||
az webapp config appsettings set \
|
||||
--name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--settings \
|
||||
NEW_SETTING=value
|
||||
|
||||
# Update frontend settings
|
||||
az webapp config appsettings set \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--settings \
|
||||
VITE_API_URL="https://${BACKEND_APP_NAME}.azurewebsites.net/api"
|
||||
|
||||
# Restart apps to apply changes
|
||||
az webapp restart --name $BACKEND_APP_NAME --resource-group $RESOURCE_GROUP
|
||||
az webapp restart --name $FRONTEND_APP_NAME --resource-group $RESOURCE_GROUP
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Step 13: Set Up CI/CD with Automated Deployment
|
||||
|
||||
### Azure DevOps Pipeline Setup
|
||||
|
||||
The project includes an automated pipeline that builds, pushes, and deploys your application.
|
||||
|
||||
1. **Create Service Connections**:
|
||||
|
||||
**A) Docker Registry Connection (for building images)**:
|
||||
- Go to Azure DevOps → Project Settings → Service connections
|
||||
- Create new **Docker Registry** connection
|
||||
- Select **Azure Container Registry**
|
||||
- Choose your subscription and ACR
|
||||
- Name: `zuyderland-cmdb-acr-connection` (or match your variable)
|
||||
|
||||
**B) Azure Resource Manager Connection (for deployment)**:
|
||||
- Create new **Azure Resource Manager** connection
|
||||
- Select your subscription
|
||||
- Name: `zuyderland-cmdb-subscription` (or match your variable)
|
||||
|
||||
2. **Configure Pipeline Variables**:
|
||||
|
||||
Update `azure-pipelines.yml` with your values:
|
||||
```yaml
|
||||
variables:
|
||||
acrName: 'cmdbinsightacr' # Your ACR name
|
||||
resourceGroup: 'rg-cmdb-insight-prod' # Your resource group
|
||||
backendAppName: 'cmdb-backend-prod' # Your backend app name
|
||||
frontendAppName: 'cmdb-frontend-prod' # Your frontend app name
|
||||
azureSubscription: 'zuyderland-cmdb-subscription' # Azure service connection
|
||||
dockerRegistryServiceConnection: 'zuyderland-cmdb-acr-connection'
|
||||
```
|
||||
|
||||
3. **Create Environment**:
|
||||
- Go to **Pipelines** → **Environments**
|
||||
- Create environment: `production`
|
||||
- (Optional) Add approvals for manual deployment control
|
||||
|
||||
4. **Run Pipeline**:
|
||||
- Push to `main` branch → **Automatically builds AND deploys**
|
||||
- Pipeline will:
|
||||
- Build Docker images
|
||||
- Push to ACR
|
||||
- Deploy to App Services
|
||||
- Verify deployment
|
||||
|
||||
### Zero-Downtime Deployment (Optional)
|
||||
|
||||
For production with zero downtime, use deployment slots:
|
||||
|
||||
1. **Create Staging Slots**:
|
||||
```bash
|
||||
az webapp deployment slot create \
|
||||
--name $BACKEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--slot staging
|
||||
|
||||
az webapp deployment slot create \
|
||||
--name $FRONTEND_APP_NAME \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--slot staging
|
||||
```
|
||||
|
||||
2. **Use Advanced Pipeline**:
|
||||
- Use `azure-pipelines-slots.yml` instead
|
||||
- Deploys to staging first
|
||||
- Swaps to production after verification
|
||||
|
||||
**See `docs/AZURE-PIPELINES.md` for complete setup guide.**
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Troubleshooting
|
||||
|
||||
### App Service Won't Start
|
||||
|
||||
```bash
|
||||
# Check logs
|
||||
az webapp log tail --name $BACKEND_APP_NAME --resource-group $RESOURCE_GROUP
|
||||
|
||||
# Check container logs
|
||||
az webapp log show --name $BACKEND_APP_NAME --resource-group $RESOURCE_GROUP
|
||||
|
||||
# Check app status
|
||||
az webapp show --name $BACKEND_APP_NAME --resource-group $RESOURCE_GROUP --query state
|
||||
```
|
||||
|
||||
### ACR Authentication Issues
|
||||
|
||||
```bash
|
||||
# Re-authenticate
|
||||
az acr login --name $ACR_NAME
|
||||
|
||||
# Check Managed Identity permissions
|
||||
az role assignment list --assignee $BACKEND_PRINCIPAL_ID --scope $ACR_ID
|
||||
```
|
||||
|
||||
### Database Connection Issues
|
||||
|
||||
```bash
|
||||
# Test database connection
|
||||
psql "postgresql://${DB_ADMIN_USER}:${DB_ADMIN_PASSWORD}@${DB_SERVER_NAME}.postgres.database.azure.com:5432/${DB_NAME}?sslmode=require"
|
||||
|
||||
# Check firewall rules
|
||||
az postgres flexible-server firewall-rule list \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--name $DB_SERVER_NAME
|
||||
```
|
||||
|
||||
### Key Vault Access Issues
|
||||
|
||||
```bash
|
||||
# Check Key Vault policies
|
||||
az keyvault show --name $KEY_VAULT_NAME --resource-group $RESOURCE_GROUP
|
||||
|
||||
# Verify Managed Identity has access
|
||||
az keyvault show-policy --name $KEY_VAULT_NAME
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Monitoring
|
||||
|
||||
### Application Insights
|
||||
|
||||
1. Go to Azure Portal → Application Insights → Your app
|
||||
2. View:
|
||||
- **Live Metrics**: Real-time performance
|
||||
- **Application Map**: Service dependencies
|
||||
- **Logs**: Query application logs
|
||||
- **Metrics**: Performance metrics
|
||||
|
||||
### Set Up Alerts
|
||||
|
||||
```bash
|
||||
# Create alert for app downtime
|
||||
az monitor metrics alert create \
|
||||
--name "Backend-Down" \
|
||||
--resource-group $RESOURCE_GROUP \
|
||||
--scopes "/subscriptions/<subscription-id>/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Web/sites/${BACKEND_APP_NAME}" \
|
||||
--condition "avg AvailabilityPercentage < 99" \
|
||||
--window-size 5m \
|
||||
--evaluation-frequency 1m
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💰 Cost Optimization
|
||||
|
||||
### Current Setup Costs
|
||||
|
||||
| Resource | SKU | Estimated Monthly Cost |
|
||||
|----------|-----|------------------------|
|
||||
| App Service Plan | B1 | €15-25 |
|
||||
| PostgreSQL | Standard_B1ms | €20-30 |
|
||||
| Container Registry | Basic | €5 |
|
||||
| Key Vault | Standard | €1-2 |
|
||||
| Application Insights | Basic | €0-5 (free tier) |
|
||||
| **Total** | | **€41-67/month** |
|
||||
|
||||
### Cost Saving Tips
|
||||
|
||||
1. **Use Basic tier ACR** for development (€5 vs €20)
|
||||
2. **Application Insights Basic** is free up to 5GB/month
|
||||
3. **Stop App Services** when not in use (dev/test environments)
|
||||
4. **Use SQLite** instead of PostgreSQL (saves €20-30/month, but less scalable)
|
||||
|
||||
---
|
||||
|
||||
## 📚 Next Steps
|
||||
|
||||
1. **Configure DNS**: Point your domain to App Service
|
||||
2. **Set up SSL**: Configure HTTPS certificate
|
||||
3. **Test Application**: Verify all features work
|
||||
4. **Set up Monitoring**: Configure alerts
|
||||
5. **Document Access**: Share URLs and credentials with team
|
||||
6. **Backup Strategy**: Plan for database backups (if needed)
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Useful Commands Reference
|
||||
|
||||
```bash
|
||||
# List all resources
|
||||
az resource list --resource-group $RESOURCE_GROUP --output table
|
||||
|
||||
# Get resource IDs
|
||||
az acr show --name $ACR_NAME --resource-group $RESOURCE_GROUP --query id
|
||||
az postgres flexible-server show --name $DB_SERVER_NAME --resource-group $RESOURCE_GROUP --query id
|
||||
|
||||
# Export resource configuration
|
||||
az group export --name $RESOURCE_GROUP --output-file resources.json
|
||||
|
||||
# Delete all resources (careful!)
|
||||
az group delete --name $RESOURCE_GROUP --yes --no-wait
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📖 Additional Resources
|
||||
|
||||
- [Azure App Service Documentation](https://docs.microsoft.com/azure/app-service/)
|
||||
- [Azure Container Registry Documentation](https://docs.microsoft.com/azure/container-registry/)
|
||||
- [Azure Database for PostgreSQL Documentation](https://docs.microsoft.com/azure/postgresql/)
|
||||
- [Azure Key Vault Documentation](https://docs.microsoft.com/azure/key-vault/)
|
||||
- [Application Insights Documentation](https://docs.microsoft.com/azure/azure-monitor/app/app-insights-overview)
|
||||
|
||||
---
|
||||
|
||||
## ✅ Deployment Checklist
|
||||
|
||||
- [ ] Resource Group created
|
||||
- [ ] Azure Container Registry created and accessible
|
||||
- [ ] PostgreSQL database created (or SQLite storage configured)
|
||||
- [ ] Key Vault created with all secrets
|
||||
- [ ] Application Insights created
|
||||
- [ ] App Service Plan created
|
||||
- [ ] Backend App Service created and configured
|
||||
- [ ] Frontend App Service created and configured
|
||||
- [ ] Docker images built and pushed to ACR
|
||||
- [ ] Apps started and running
|
||||
- [ ] Health checks passing
|
||||
- [ ] Custom domain configured (if applicable)
|
||||
- [ ] SSL certificate configured (if applicable)
|
||||
- [ ] Monitoring and alerts configured
|
||||
- [ ] Team access configured
|
||||
- [ ] Documentation updated
|
||||
|
||||
---
|
||||
|
||||
**🎉 Congratulations! Your CMDB Insight application is now deployed to Azure!**
|
||||
|
||||
For questions or issues, refer to:
|
||||
- `AZURE-APP-SERVICE-DEPLOYMENT.md` - Detailed App Service deployment guide
|
||||
- `AZURE-ACR-SETUP.md` - ACR setup and usage
|
||||
- `PRODUCTION-DEPLOYMENT.md` - General production deployment guide
|
||||
244
docs/Setup and configuration/LOCAL-DEVELOPMENT-SETUP.md
Normal file
244
docs/Setup and configuration/LOCAL-DEVELOPMENT-SETUP.md
Normal file
@@ -0,0 +1,244 @@
|
||||
# Local Development Setup
|
||||
|
||||
## PostgreSQL Only (Recommended for Local Development)
|
||||
|
||||
Voor lokale development heb je alleen PostgreSQL nodig. De backend en frontend draaien lokaal op je MacBook.
|
||||
|
||||
### Start PostgreSQL
|
||||
|
||||
```bash
|
||||
# Start alleen PostgreSQL
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
|
||||
# Check status
|
||||
docker-compose -f docker-compose.dev.yml ps
|
||||
|
||||
# Check logs
|
||||
docker-compose -f docker-compose.dev.yml logs -f postgres
|
||||
```
|
||||
|
||||
### Connection String
|
||||
|
||||
```env
|
||||
DATABASE_TYPE=postgres
|
||||
DATABASE_URL=postgresql://cmdb:cmdb-dev@localhost:5432/cmdb_insight
|
||||
```
|
||||
|
||||
Of individuele variabelen:
|
||||
|
||||
```env
|
||||
DATABASE_TYPE=postgres
|
||||
DATABASE_HOST=localhost
|
||||
DATABASE_PORT=5432
|
||||
DATABASE_NAME=cmdb_insight
|
||||
DATABASE_USER=cmdb
|
||||
DATABASE_PASSWORD=cmdb-dev
|
||||
```
|
||||
|
||||
### Stop PostgreSQL
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml down
|
||||
```
|
||||
|
||||
### Reset Database
|
||||
|
||||
```bash
|
||||
# Stop en verwijder volume
|
||||
docker-compose -f docker-compose.dev.yml down -v
|
||||
|
||||
# Start opnieuw
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
```
|
||||
|
||||
### Connect to Database
|
||||
|
||||
```bash
|
||||
# Via psql
|
||||
docker-compose -f docker-compose.dev.yml exec postgres psql -U cmdb -d cmdb_insight
|
||||
|
||||
# Of direct
|
||||
psql postgresql://cmdb:cmdb-dev@localhost:5432/cmdb_insight
|
||||
```
|
||||
|
||||
### Useful Commands
|
||||
|
||||
```bash
|
||||
# List databases
|
||||
docker-compose -f docker-compose.dev.yml exec postgres psql -U cmdb -c "\l"
|
||||
|
||||
# List tables
|
||||
docker-compose -f docker-compose.dev.yml exec postgres psql -U cmdb -d cmdb_insight -c "\dt"
|
||||
|
||||
# Check database size
|
||||
docker-compose -f docker-compose.dev.yml exec postgres psql -U cmdb -d cmdb_insight -c "
|
||||
SELECT pg_size_pretty(pg_database_size('cmdb_insight')) as size;
|
||||
"
|
||||
|
||||
# Count objects
|
||||
docker-compose -f docker-compose.dev.yml exec postgres psql -U cmdb -d cmdb_insight -c "
|
||||
SELECT object_type_name, COUNT(*)
|
||||
FROM objects
|
||||
GROUP BY object_type_name;
|
||||
"
|
||||
```
|
||||
|
||||
## Full Stack (Alternative)
|
||||
|
||||
Als je de hele stack in Docker wilt draaien:
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
Dit start:
|
||||
- PostgreSQL
|
||||
- Backend (in Docker)
|
||||
- Frontend (in Docker)
|
||||
|
||||
## Backend Development
|
||||
|
||||
Met alleen PostgreSQL draaiend:
|
||||
|
||||
```bash
|
||||
# In backend directory
|
||||
cd backend
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Backend draait op `http://localhost:3001`
|
||||
|
||||
## Frontend Development
|
||||
|
||||
```bash
|
||||
# In frontend directory
|
||||
cd frontend
|
||||
npm install
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Frontend draait op `http://localhost:5173`
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Maak een `.env` bestand in de root:
|
||||
|
||||
```env
|
||||
# Database (voor backend)
|
||||
DATABASE_TYPE=postgres
|
||||
DATABASE_URL=postgresql://cmdb:cmdb-dev@localhost:5432/cmdb_insight
|
||||
|
||||
# Jira (optioneel)
|
||||
JIRA_HOST=https://jira.zuyderland.nl
|
||||
JIRA_PAT=your_token
|
||||
JIRA_SCHEMA_ID=your_schema_id
|
||||
|
||||
# AI (optioneel)
|
||||
ANTHROPIC_API_KEY=your_key
|
||||
```
|
||||
|
||||
## Database Access
|
||||
|
||||
### Quick Access
|
||||
|
||||
**Using the script:**
|
||||
```bash
|
||||
# Connect using psql
|
||||
./scripts/open-database.sh psql
|
||||
|
||||
# Or via Docker
|
||||
./scripts/open-database.sh docker
|
||||
|
||||
# Or get connection string for GUI tools
|
||||
./scripts/open-database.sh url
|
||||
```
|
||||
|
||||
**Direct psql command:**
|
||||
```bash
|
||||
psql postgresql://cmdb:cmdb-dev@localhost:5432/cmdb_insight
|
||||
```
|
||||
|
||||
**Via Docker:**
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml exec postgres psql -U cmdb -d cmdb_insight
|
||||
```
|
||||
|
||||
### GUI Tools
|
||||
|
||||
**pgAdmin** (Free, Web-based):
|
||||
- Download: https://www.pgadmin.org/download/
|
||||
- Connection: `postgresql://cmdb:cmdb-dev@localhost:5432/cmdb_insight`
|
||||
|
||||
**DBeaver** (Free, Cross-platform):
|
||||
- Download: https://dbeaver.io/download/
|
||||
- Create new PostgreSQL connection with connection string above
|
||||
|
||||
**TablePlus** (macOS, Paid but has free tier):
|
||||
- Download: https://tableplus.com/
|
||||
- Create new PostgreSQL connection
|
||||
|
||||
### Useful SQL Commands
|
||||
|
||||
```sql
|
||||
-- List all tables
|
||||
\dt
|
||||
|
||||
-- Describe a table structure
|
||||
\d objects
|
||||
\d attribute_values
|
||||
\d classification_history
|
||||
|
||||
-- View object counts
|
||||
SELECT object_type_name, COUNT(*)
|
||||
FROM objects
|
||||
GROUP BY object_type_name;
|
||||
|
||||
-- View classification history
|
||||
SELECT * FROM classification_history
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT 10;
|
||||
|
||||
-- Check database size
|
||||
SELECT pg_size_pretty(pg_database_size('cmdb_insight')) as size;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Port Already in Use
|
||||
|
||||
Als poort 5432 al in gebruik is:
|
||||
|
||||
```yaml
|
||||
# In docker-compose.dev.yml, wijzig:
|
||||
ports:
|
||||
- "5433:5432" # Gebruik 5433 lokaal
|
||||
```
|
||||
|
||||
En update je `.env`:
|
||||
```env
|
||||
DATABASE_PORT=5433
|
||||
```
|
||||
|
||||
### Connection Refused
|
||||
|
||||
```bash
|
||||
# Check of container draait
|
||||
docker ps | grep postgres
|
||||
|
||||
# Check logs
|
||||
docker-compose -f docker-compose.dev.yml logs postgres
|
||||
|
||||
# Test connection
|
||||
docker-compose -f docker-compose.dev.yml exec postgres pg_isready -U cmdb
|
||||
```
|
||||
|
||||
### Database Not Found
|
||||
|
||||
De database wordt automatisch aangemaakt bij eerste start van de backend. Of maak handmatig:
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.dev.yml exec postgres psql -U cmdb -c "CREATE DATABASE cmdb_insight;"
|
||||
```
|
||||
Reference in New Issue
Block a user