dev-resources.site
for different kinds of informations.
A Step-by-Step Guide to CI/CD Pipeline for Angular App with Azure Container Apps
Published at
12/10/2024
Categories
devops
azure
containerapps
cicd
Author
hassan_aftab
Author
12 person written this
hassan_aftab
open
Table of Contents
- Prerequisites
- Step 1: Dockerfile
- Step 2: Azure Pipelines Configuration
- Step 3: Additional Azure CLI Configuration
- Best Practices
- Troubleshooting
- Conclusion
- Resources
- Dockerizing Other Technology Stacks
Prerequisites
- Azure DevOps account
- Azure Subscription
- Angular project
- Azure CLI installed
- Docker installed
- Azure Container Registry
- Azure Container Apps environment
Step 1: Dockerfile
# Stage 1: Build Angular application
FROM node:16-alpine AS build
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
RUN npm run build --configuration=production
# Stage 2: Serve with Nginx
FROM nginx:alpine
COPY --from=build /usr/src/app/dist/your-angular-app /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Step 2: Azure Pipelines Configuration
trigger:
- main
variables:
# Azure Container Registry details
acrName: 'yourcontainerregistry'
imageRepository: 'angular-app'
dockerfilePath: 'Dockerfile'
tag: '$(Build.BuildId)'
# Azure Container Apps details
containerAppName: 'your-container-app-name'
resourceGroup: 'your-resource-group'
stages:
- stage: Build
displayName: Build and Test
jobs:
- job: BuildAndTest
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
- script: |
npm ci
npm run lint
npm run test -- --watch=false --browsers=ChromeHeadless
displayName: 'npm install, lint, and test'
- task: Docker@2
displayName: 'Build Docker Image'
inputs:
command: build
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
tags:
- $(tag)
- latest
- task: Docker@2
displayName: 'Push to Azure Container Registry'
inputs:
command: push
repository: $(imageRepository)
containerRegistry: $(acrServiceConnection)
tags:
- $(tag)
- latest
- stage: Approval
displayName: Deployment Approval
jobs:
- job: ApprovalJob
pool: server
steps:
- task: ManualValidation@0
inputs:
instructions: 'Please review and approve the deployment'
onTimeout: 'reject'
timeoutInMinutes: 120
- stage: Deploy
displayName: Deploy to Azure Container Apps
dependsOn:
- Build
- Approval
condition: succeeded()
jobs:
- deployment: DeployToContainerApp
pool:
vmImage: 'ubuntu-latest'
environment: 'production'
strategy:
runOnce:
deploy:
steps:
- task: AzureCLI@2
displayName: 'Deploy to Azure Container Apps'
inputs:
azureSubscription: 'Your-Azure-Subscription'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
# Login to Azure Container Registry
az acr login --name $(acrName)
# Update Container App with new image
az containerapp update \
--name $(containerAppName) \
--resource-group $(resourceGroup) \
--image $(acrName).azurecr.io/$(imageRepository):$(tag)
Step 3: Additional Azure CLI Configuration
Before running the pipeline, set up your Azure Container Apps:
# Create Container Registry
az acr create --resource-group your-resource-group \
--name yourcontainerregistry \
--sku Basic
# Create Container Apps Environment
az containerapp env create \
--name your-container-app-environment \
--resource-group your-resource-group \
--location eastus
# Create Container App
az containerapp create \
--name your-container-app-name \
--resource-group your-resource-group \
--environment your-container-app-environment \
--image yourcontainerregistry.azurecr.io/angular-app:latest \
--target-port 80 \
--ingress external
Best Practices
- Use Azure Key Vault for sensitive configurations
- Implement comprehensive testing before deployment
- Use managed identities for secure access
- Set up proper RBAC for deployment
- Configure health checks in Container Apps
- Use staging slots for zero-downtime deployments
Troubleshooting
- Verify network configurations
- Check container logs in Azure Portal
- Ensure proper IAM roles are assigned
- Validate ACR permissions
- Check Container Apps network settings
Conclusion
This pipeline provides a robust CI/CD workflow for deploying an Angular application to Azure Container Apps with a manual approval stage.
Resources
so in summary, The pipeline includes:
- Build and test stage
- Manual approval stage
- Deployment to Azure Container Apps
- Azure Container Registry integration
Dockerizing Other Technology Stacks
The Dockerfile approach demonstrated for the Angular application can be easily adapted to other popular technology stacks as well
containerapps Article's
30 articles in total
Tackling CPU Throttling in Kubernetes for Better Application Performance
read article
What the Heck is Docker?
read article
A Step-by-Step Guide to CI/CD Pipeline for Angular App with Azure Container Apps
currently reading
Cool SHIT you can do with docker
read article
Deploying a stateless container on cloud run
read article
Dockerize Your Development: Build Reusable Features, Faster
read article
Docker For Beginners
read article
Preventing Out-of-Memory (OOM) Kills in Kubernetes: Tips for Optimizing Container Memory Management
read article
How and why did we improve our API hosting?
read article
Deploying a Java Azure Function on Azure Container Apps
read article
AWS App Runner: A quick start deploying Docker Container to AppRunner
read article
Deploying a Static Website with Docker: A Comprehensive Guide
read article
Day 12 of my 90-Devops Journey: CI/CD for Containerized Applications: A GitLab Guide
read article
How to containerize your web app- a beginner-friendly tutorial for Dockerfile
read article
Use LLMs in Java. An example with Merlinite, Quarkus, and Podman Desktop AI Lab
read article
How to Build a Container Image Running on Docker Hub.
read article
Android Encrypted Shared Preference access issue from new container
read article
What is Docker ?: Understanding the Concept of Containerization.
read article
How Azure Container Apps Simplify the Cloud Deployment Process
read article
docker compose : top level object must be mapping
read article
Deploying Containers with Security in mind (Beginner)
read article
Containerizing your Go application by using Docker
read article
Containerizing your Go application using Docker
read article
Revolutionize Your Dev Workflow: Containerization and Linux VPS Hosting for Streamlined Software Development
read article
Java application latency reduction and pitfalls
read article
A Beginner's Tour of NodePort, LoadBalancer, and Ingress Services
read article
Azure Container Apps: Zero to Hero
read article
Dev Container for React Native with Expo
read article
How to authenticate and register GitHub Runners hosted in Azure Container Apps with GitHub App via Azure Key Vault
read article
The Orchestration of The Ring
read article
Featured ones: