Deployment - Blazor Blueprint Docker, CI/CD & Production Guide
Login Register

๐Ÿ”จ Building

Local Build

# Build the entire solution
dotnet build BlazorBlueprint.sln --configuration Release

# Run tests
dotnet test BlazorBlueprint.sln --configuration Release

# Publish for deployment
dotnet publish Web/BlazorBlueprint.Web/BlazorBlueprint.Web.csproj --configuration Release --output ./publish/web

Docker Build

# Build all services with Docker Compose (GitHub Actions)
docker-compose -f .github/workflows/docker-compose.yml build

# Build all services with Docker Compose (Azure DevOps)
docker-compose -f .azure/devops/docker-compose.yml build

# Or build individual images
docker build -f Web/BlazorBlueprint.Web/Dockerfile -t blazor-blueprint-web .
docker build -f Services/BlazorBlueprint.ApplicationService/Dockerfile -t blazor-blueprint-api .

๐Ÿ“ฆ Deployment

Quick Deployment (Docker Compose)

# Deploy all services (GitHub Actions)
docker-compose -f .github/workflows/docker-compose.yml up -d

# Deploy all services (Azure DevOps)
docker-compose -f .azure/devops/docker-compose.yml up -d

# View logs
docker-compose -f .azure/devops/docker-compose.yml logs -f

# Stop services
docker-compose -f .azure/devops/docker-compose.yml down

โœ… What CI/CD Deployment Includes: Complete production stack with MongoDB, Redis, Web App, API Service - all with persistent data volumes and proper networking. This is different from Aspire development which requires you to provide MongoDB separately.

Manual Deployment Scripts

Use the included deployment scripts for manual deployments:

Windows (PowerShell)
# Azure DevOps script
.\\.azure\\devops\\deploy-container.ps1 -webImage "your-web-image:latest" -appImage "your-api-image:latest"

# GitHub Actions script
.\\.github\\workflows\\deploy-container.ps1 -WebImage "your-web-image:latest" -AppImage "your-api-image:latest"
Linux/macOS (Shell)
# Set environment variables
export WEB_IMAGE="your-web-image:latest"
export APP_IMAGE="your-api-image:latest"

# Run deployment script
chmod +x .github/workflows/deploy-container.sh
./.github/workflows/deploy-container.sh

Production Considerations

  • Persistent Storage: Docker volumes preserve data across deployments
  • Environment Variables: Configure production settings via environment
  • SSL/TLS: Add reverse proxy (nginx/Apache) for HTTPS
  • Monitoring: Use built-in health checks and infrastructure monitor
  • Backups: Regular MongoDB backups and configuration backups
  • Scaling: Kubernetes deployment for automatic scaling and high availability
  • Background Processing: .NET Worker Service handles background tasks including push notifications, data cleanup, and AI workflows

๐Ÿ”„ CI/CD Setup

Quick Setup

Choose your preferred platform and follow the simple setup steps:

๐Ÿ“‹ What You Need: A container registry (GitHub Container Registry or Docker Hub) and a server with Docker installed.

GitHub Actions Setup

1. Configure Variables and Secrets

Go to your repository โ†’ Settings โ†’ Secrets and variables โ†’ Actions

Variables (Repository Settings โ†’ Actions โ†’ Variables)
# Required Variables
DOCKER_REGISTRY: 'ghcr.io'
WEB_IMAGE_REPOSITORY: 'ghcr.io/yourusername/your-web-app'
APP_IMAGE_REPOSITORY: 'ghcr.io/yourusername/your-api-service'
Secrets (Repository Settings โ†’ Actions โ†’ Secrets)
# Required Secrets
GITHUB_TOKEN: 'ghp_xxxxxxxxxxxxxxxxxxxx'
2. Setup Self-Hosted Runner
  1. Install Docker on your server
  2. Go to Repository โ†’ Settings โ†’ Actions โ†’ Runners โ†’ New self-hosted runner
  3. Follow GitHub's setup instructions
  4. Open ports 8080 (Web) and 8081 (API)
3. Deploy

Push to main branch or trigger manual deployment from Actions tab.

Azure DevOps Setup

1. Create Pipeline
  1. Go to Azure DevOps โ†’ Pipelines โ†’ New Pipeline
  2. Select your repository
  3. Choose "Existing Azure Pipelines YAML file"
  4. Select .azure/devops/build-pipeline.yml
2. Configure Variables

Go to Pipelines โ†’ Library โ†’ Variable Groups

# Required Variables
DOCKER_REGISTRY_SERVICE_CONNECTION: 'docker-hub-connection'
DOCKER_REGISTRY: 'docker.io/'
WEB_IMAGE_REPOSITORY: 'yourusername/your-web-app'
APP_IMAGE_REPOSITORY: 'yourusername/your-api-service'
Service Connection Authentication
# Docker Hub Credentials (configured in Service Connection)
Username: 'your-dockerhub-username'
Password: 'your-dockerhub-token'
3. Create Service Connection

Go to Project Settings โ†’ Service connections โ†’ New service connection โ†’ Docker Registry

  • Registry type: Docker Hub
  • Connection name: docker-hub-connection
  • Username: Your Docker Hub username
  • Password: Your Docker Hub access token (not password)

๐Ÿ’ก Note: Use a Docker Hub access token, not your account password, for better security.

4. Deploy

Run the pipeline manually or set up triggers for automatic deployment.

Manual Deployment

For manual deployments, use the included scripts:

Linux/macOS
# Set required environment variables
export WEB_IMAGE="your-registry/your-web-app:latest"
export APP_IMAGE="your-registry/your-api-service:latest"

# Run deployment script
chmod +x .github/workflows/deploy-container.sh
./.github/workflows/deploy-container.sh
Windows
# Run deployment script with required parameters
.\\.github\\workflows\\deploy-container.ps1 -WebImage "your-registry/your-web-app:latest" -AppImage "your-registry/your-api-service:latest"

What Gets Deployed (CI/CD Production)

  • Web Application: Blazor Server app on port 8080
  • API Service: Application service on port 8081
  • .NET Worker Service: Background processing service for handling async tasks and queue processing
  • Kafka: Message queue for background job processing
  • MongoDB: Database on port 27018 with persistent storage
  • Redis: Cache on port 6379 with persistent storage
  • Persistent Storage: Data volumes for MongoDB and Redis
  • Networking: Isolated Docker network for service communication
  • Kubernetes: Container orchestration for scaling and high availability

๐Ÿ’ก Note: This is the complete production stack. For development with .NET Aspire, MongoDB is not included and must be provided separately. The .NET Worker Service handles background tasks (push notifications, data cleanup, AI workflows) through queue processing, enabling scalable and resilient background processing.

๐Ÿญ Production Environment

Infrastructure Requirements

  • Server: 4+ CPU cores, 8GB+ RAM, 20GB+ storage
  • Docker: Docker Engine 20.10+ or Docker Desktop
  • Network: Ports 8080 (Web), 8081 (API), 80/443 (HTTP/HTTPS)
  • SSL Certificate: For HTTPS (Let's Encrypt recommended)

Security Configuration

  • Environment Variables: Store secrets in environment, not appsettings.json
  • Database Security: Enable MongoDB authentication and encryption
  • Redis Security: Configure Redis AUTH and disable dangerous commands
  • HTTPS Only: Force HTTPS redirects and secure cookies
  • CORS: Configure appropriate CORS policies

Monitoring & Maintenance

  • Health Checks: Monitor /health endpoint
  • Infrastructure Monitor: Use built-in dashboard
  • Logging: Configure structured logging and log aggregation
  • Backups: Automated MongoDB backups and disaster recovery
  • Updates: Regular security updates and dependency updates

Performance Optimization

  • Caching: Redis distributed caching is enabled by default
  • CDN: Use CDN for static assets and images
  • Database: Create appropriate MongoDB indexes
  • Scaling: Kubernetes horizontal pod autoscaling for automatic scaling based on load
  • Background Processing: Queue-based background processing enables horizontal scaling of worker services
  • Compression: Enable gzip compression in reverse proxy

๐Ÿ“ฆ Ready to Download?

Deploy your SaaS application with confidence. Download the free Developer version or get Enterprise with premium plugins, commercial licensing, and production support.

๐Ÿ”“ Open Source on GitHub โ€ข Free for personal/non-commercial use โ€ข Enterprise license (ยฃ399) required for commercial use โ€ข Full source code included

Welcome! How can we help you today?
An unhandled error has occurred. Reload ??