Add Azure Container Registry setup and documentation

- Configure ACR name: zdlas in azure-pipelines.yml
- Add Azure Container Registry documentation and guides
- Add scripts for ACR creation and image building
- Add docker-compose config for ACR deployment
- Remove temporary Excel lock file
This commit is contained in:
2026-01-14 12:25:25 +01:00
parent 96ed8a9ecf
commit 55c8fee3b8
12 changed files with 2559 additions and 0 deletions

95
scripts/build-and-push-azure.sh Executable file
View File

@@ -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}"

132
scripts/create-acr.sh Executable file
View File

@@ -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"