Deployment Guide
Comprehensive deployment strategies for JAngular applications across development, staging, and production environments with cloud platform integration.
JAngular applications can be deployed across various environments and platforms using multiple strategies. This guide covers everything from local development to enterprise cloud deployments with comprehensive configuration management and best practices.
Development Deployment
Development deployments focus on rapid iteration, debugging capabilities, and ease of testing:
Local Development Setup
# Install all project dependencies npm run install:all # Start backend with hot reload (Terminal 1) npm run start:backend # Start frontend with hot reload (Terminal 2) npm run start:frontend # Access application # Frontend: http://localhost:4200 # Backend API: http://localhost:8080 # Database: See docker-compose.yml for ports
Docker Development Environment
# Start complete development stack docker-compose up -d # View aggregated logs docker-compose logs -f # View specific service logs docker-compose logs -f backend docker-compose logs -f frontend docker-compose logs -f mysql # Stop development environment docker-compose down # Clean restart (removes volumes) docker-compose down -v && docker-compose up -d
Development Features
- Hot Reload - Automatic application restart on code changes
- Debug Configuration - Enhanced logging and error reporting
- Database Seeding - Automatic test data population
- Live API Documentation - Swagger UI for API testing
- Development Tools - Angular DevTools and Spring Boot DevTools integration
Staging Deployment
Staging environments replicate production conditions for thorough testing:
Staging Build Process
# Build applications for staging jangular build --all # Deploy to staging with environment-specific configuration docker-compose -f docker-compose.staging.yml up -d # Run staging health checks docker-compose -f docker-compose.staging.yml ps curl -f http://staging.yourapp.com/actuator/health
Staging Configuration
- Production-like Data - Realistic dataset for comprehensive testing
- Performance Monitoring - Metrics collection and analysis
- Security Testing - Vulnerability scanning and penetration testing
- Load Testing - Performance validation under simulated load
- Integration Testing - End-to-end workflow validation
Production Deployment
Production deployments prioritize performance, security, and reliability:
Production Build Optimization
# Build optimized production artifacts jangular build --all --prod # Build specific components with production optimizations jangular build --backend --prod jangular build --frontend --prod # Verify build artifacts ls -la backend/target/ ls -la frontend/dist/
Production Docker Deployment
# Deploy production environment docker-compose -f docker-compose.prod.yml up -d # Scale backend services for high availability docker-compose -f docker-compose.prod.yml up -d --scale backend=3 # Monitor production services docker-compose -f docker-compose.prod.yml ps docker-compose -f docker-compose.prod.yml top # Production health monitoring docker-compose -f docker-compose.prod.yml exec backend curl http://localhost:8080/actuator/health docker-compose -f docker-compose.prod.yml logs --tail=100 -f
Production Features
- SSL/TLS Termination - Automatic HTTPS with Let's Encrypt integration
- Load Balancing - Multi-instance deployment with health checks
- Resource Optimization - Memory and CPU limits for optimal performance
- Caching Strategy - Redis integration for session and data caching
- Database Optimization - Connection pooling and query optimization
Environment Configuration
Comprehensive configuration management across all deployment environments:
Backend Environment Configuration
# application.properties (Base configuration) spring.application.name=jangular-backend spring.profiles.active=@spring.profiles.active@ logging.level.com.example=INFO # application-dev.properties (Development) spring.datasource.url=jdbc:mysql://localhost:3306/jangular_dev spring.jpa.hibernate.ddl-auto=update logging.level.com.example=DEBUG cors.allowed-origins=http://localhost:4200 # application-prod.properties (Production) spring.datasource.url=jdbc:mysql://prod-db:3306/jangular_prod spring.jpa.hibernate.ddl-auto=validate logging.level.com.example=WARN cors.allowed-origins=https://yourapp.com
Frontend Environment Configuration
# environment.ts (Development) export const environment = { production: false, apiUrl: 'http://localhost:8080/api', authUrl: 'http://localhost:8080/auth', enableDebugTools: true, logLevel: 'debug' }; # environment.prod.ts (Production) export const environment = { production: true, apiUrl: 'https://api.yourapp.com/api', authUrl: 'https://api.yourapp.com/auth', enableDebugTools: false, logLevel: 'error' };
Docker Environment Variables
# .env.prod (Production Environment Variables) SPRING_PROFILES_ACTIVE=prod MYSQL_ROOT_PASSWORD=secure_root_password MYSQL_DATABASE=jangular_prod MYSQL_USER=jangular_prod_user MYSQL_PASSWORD=secure_database_password JWT_SECRET=your-256-bit-production-secret CORS_ALLOWED_ORIGINS=https://yourapp.com SSL_CERTIFICATE_PATH=/etc/ssl/certs/yourapp.com.crt SSL_PRIVATE_KEY_PATH=/etc/ssl/private/yourapp.com.key
Container Registry & Image Management
Professional container image management for deployment pipelines:
Image Building & Tagging
# Build production images docker-compose -f docker-compose.prod.yml build # Tag images with version and registry information docker tag jangular-backend:latest registry.yourcompany.com/jangular/backend:v1.2.0 docker tag jangular-frontend:latest registry.yourcompany.com/jangular/frontend:v1.2.0 # Tag with latest for rolling deployments docker tag jangular-backend:latest registry.yourcompany.com/jangular/backend:latest docker tag jangular-frontend:latest registry.yourcompany.com/jangular/frontend:latest
Registry Operations
# Login to container registry docker login registry.yourcompany.com # Push versioned images docker push registry.yourcompany.com/jangular/backend:v1.2.0 docker push registry.yourcompany.com/jangular/frontend:v1.2.0 # Push latest tags docker push registry.yourcompany.com/jangular/backend:latest docker push registry.yourcompany.com/jangular/frontend:latest # Pull images for deployment docker pull registry.yourcompany.com/jangular/backend:v1.2.0 docker pull registry.yourcompany.com/jangular/frontend:v1.2.0
Image Security & Optimization
- Vulnerability Scanning - Automated security scanning with tools like Clair or Snyk
- Image Signing - Docker Content Trust for image authenticity verification
- Multi-Architecture - Support for AMD64 and ARM64 architectures
- Layer Optimization - Minimized layers and optimized caching strategies
Advanced Deployment Strategies
Enterprise-grade deployment patterns for zero-downtime and risk mitigation:
Blue-Green Deployment
- Preparation - Maintain two identical production environments (Blue and Green)
- Deployment - Deploy new version to the inactive environment (Green)
- Testing - Perform comprehensive testing in Green environment
- Traffic Switch - Route production traffic from Blue to Green
- Monitoring - Monitor Green environment for issues
- Rollback - Switch back to Blue if issues are detected
- Cleanup - Prepare Blue environment for next deployment
# Blue-Green deployment with Docker # Deploy to Green environment docker-compose -f docker-compose.green.yml up -d # Test Green environment curl -f https://green.yourapp.com/actuator/health # Switch traffic to Green (load balancer configuration) # Update DNS or load balancer to point to Green # Monitor and validate docker-compose -f docker-compose.green.yml logs -f
Canary Deployment
- Initial Deployment - Deploy new version alongside current version
- Traffic Splitting - Route small percentage (5-10%) to new version
- Monitoring - Monitor error rates, performance metrics, and user feedback
- Gradual Rollout - Increase traffic percentage gradually (25%, 50%, 75%)
- Full Deployment - Route all traffic to new version once validated
- Rollback Plan - Immediate rollback if metrics indicate issues
Rolling Deployment
- Sequential Updates - Update instances one at a time
- Health Checks - Verify each instance before proceeding
- Automatic Rollback - Stop deployment if health checks fail
- Zero Downtime - Maintain service availability throughout deployment
Cloud Platform Deployment
Platform-specific deployment guides for major cloud providers:
Amazon Web Services (AWS)
ECS (Elastic Container Service) Deployment
# AWS CLI deployment to ECS aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-west-2.amazonaws.com # Tag and push to ECR docker tag jangular-backend:latest 123456789012.dkr.ecr.us-west-2.amazonaws.com/jangular-backend:latest docker push 123456789012.dkr.ecr.us-west-2.amazonaws.com/jangular-backend:latest # Update ECS service aws ecs update-service --cluster jangular-cluster --service jangular-backend-service --force-new-deployment
EKS (Elastic Kubernetes Service) Deployment
# Kubernetes deployment manifest apiVersion: apps/v1 kind: Deployment metadata: name: jangular-backend spec: replicas: 3 selector: matchLabels: app: jangular-backend template: metadata: labels: app: jangular-backend spec: containers: - name: backend image: 123456789012.dkr.ecr.us-west-2.amazonaws.com/jangular-backend:latest ports: - containerPort: 8080
Google Cloud Platform (GCP)
Cloud Run Deployment
# Deploy to Cloud Run gcloud builds submit --tag gcr.io/PROJECT_ID/jangular-backend gcloud run deploy jangular-backend \ --image gcr.io/PROJECT_ID/jangular-backend \ --platform managed \ --region us-central1 \ --allow-unauthenticated
GKE (Google Kubernetes Engine) Deployment
# Configure kubectl for GKE gcloud container clusters get-credentials jangular-cluster --zone us-central1-a --project PROJECT_ID # Deploy to GKE kubectl apply -f k8s-deployment.yaml kubectl expose deployment jangular-backend --type=LoadBalancer --port=80 --target-port=8080
Microsoft Azure
Azure Container Instances (ACI)
# Deploy to Azure Container Instances az container create \ --resource-group jangular-rg \ --name jangular-backend \ --image jangularregistry.azurecr.io/jangular-backend:latest \ --ports 8080 \ --environment-variables SPRING_PROFILES_ACTIVE=prod
Azure Kubernetes Service (AKS)
# Get AKS credentials az aks get-credentials --resource-group jangular-rg --name jangular-cluster # Deploy to AKS kubectl apply -f azure-deployment.yaml kubectl get services
CI/CD Pipeline Integration
Automated deployment pipelines for consistent and reliable releases:
GitHub Actions Pipeline
# .github/workflows/deploy.yml name: Deploy to Production on: push: branches: [main] jobs: build-and-deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Build and test run: | jangular build --all --prod jangular test --all - name: Build Docker images run: docker-compose -f docker-compose.prod.yml build - name: Deploy to production run: | docker-compose -f docker-compose.prod.yml up -d docker-compose -f docker-compose.prod.yml exec backend curl -f http://localhost:8080/actuator/health
GitLab CI/CD Pipeline
# .gitlab-ci.yml stages: - build - test - deploy build: stage: build script: - jangular build --all --prod - docker-compose -f docker-compose.prod.yml build test: stage: test script: - jangular test --all deploy: stage: deploy script: - docker-compose -f docker-compose.prod.yml up -d only: - main
Pipeline Best Practices
- Automated Testing - Unit, integration, and end-to-end tests in pipeline
- Security Scanning - Vulnerability assessment and dependency checks
- Quality Gates - Code quality thresholds and approval processes
- Rollback Automation - Automatic rollback on deployment failures
- Notification Integration - Slack, email, or webhook notifications
Monitoring & Observability
Comprehensive monitoring strategy for production deployments:
Application Monitoring
- Health Endpoints - Spring Boot Actuator for application health
- Metrics Collection - Prometheus integration for performance metrics
- Distributed Tracing - Request tracing across microservices
- Error Tracking - Centralized error logging and alerting
Infrastructure Monitoring
- Container Metrics - Docker container resource usage
- Database Performance - Query performance and connection monitoring
- Network Monitoring - Inter-service communication analysis
- Storage Monitoring - Disk usage and I/O performance
Alerting Strategy
# Example Prometheus alerting rules groups: - name: jangular-alerts rules: - alert: HighErrorRate expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.1 for: 5m labels: severity: critical annotations: summary: High error rate detected - alert: DatabaseConnectionFailure expr: mysql_up == 0 for: 1m labels: severity: critical annotations: summary: Database connection failed
Security & Compliance
Production security requirements and best practices:
Network Security
- HTTPS Enforcement - SSL/TLS certificates with automatic renewal
- Firewall Configuration - Restrictive inbound and outbound rules
- VPC/VNET Setup - Private network isolation
- API Gateway - Centralized API security and rate limiting
Application Security
- Secret Management - Secure storage of credentials and API keys
- JWT Security - Strong secret keys and proper token validation
- Database Security - Encrypted connections and least-privilege access
- Container Security - Non-root users and minimal attack surface
Compliance Requirements
- Data Encryption - Encryption at rest and in transit
- Audit Logging - Comprehensive activity logging
- Access Controls - Role-based access and authentication
- Regular Updates - Security patch management
Production Readiness: This deployment guide covers enterprise-grade deployment practices suitable for high-availability production environments with comprehensive security, monitoring, and compliance considerations.