Back to Documentation
Tutorial60 minutes

Deploying to the Cloud

Deploy your application to production using Munashe Tech Cloud infrastructure with automatic scaling and monitoring

Prerequisites
  • Completed Next.js application ready for production
  • Git repository (GitHub, GitLab, or Bitbucket)
  • Munashe Tech Cloud account with billing enabled
  • Custom domain name (optional but recommended)

Step-by-Step Guide

1
Prepare Your Application
10 min
  • Optimize your build configuration
  • Set up environment variables
  • Configure production settings
  • Run production build locally to test
Code
# Install Munashe Tech CLI
npm install -g @munashetech/cli

# Login to your account
mt login

# Initialize cloud configuration
mt cloud init

# Create production environment file
cat > .env.production << EOF
NODE_ENV=production
NEXT_PUBLIC_API_URL=https://api.munashetech.com
DATABASE_URL=your_production_db_url
EOF

# Test production build
npm run build
npm run start
2
Create Cloud Project
8 min
  • Set up a new project in Munashe Tech Cloud
  • Configure project settings and region
  • Link your Git repository
  • Set up automatic deployments
Code
# Create a new cloud project
mt cloud create my-app \
  --region us-east \
  --framework nextjs \
  --node-version 20

# Link Git repository
mt cloud link-repo \
  --provider github \
  --repo username/my-app \
  --branch main

# Configure auto-deploy on push
mt cloud auto-deploy enable \
  --branch main \
  --on push

# View project details
mt cloud info
3
Configure Database & Services
12 min
  • Provision a managed database
  • Set up Redis cache
  • Configure storage buckets
  • Add environment variables
Code
# Create PostgreSQL database
mt cloud db create my-app-db \
  --engine postgres \
  --version 15 \
  --size standard \
  --backup-retention 7

# Create Redis instance
mt cloud cache create my-app-cache \
  --engine redis \
  --size micro

# Create storage bucket
mt cloud storage create my-app-assets \
  --access public-read

# Add environment variables
mt cloud env set DATABASE_URL "$(mt cloud db url my-app-db)"
mt cloud env set REDIS_URL "$(mt cloud cache url my-app-cache)"
mt cloud env set STORAGE_BUCKET "my-app-assets"
mt cloud env set NEXTAUTH_SECRET "$(openssl rand -base64 32)"

# List all environment variables
mt cloud env list
4
Configure Domain & SSL
8 min
  • Add custom domain
  • Configure DNS records
  • Enable automatic SSL certificate
  • Set up www redirect
Code
# Add custom domain
mt cloud domain add myapp.com

# Get DNS configuration
mt cloud domain dns myapp.com

# Example DNS records to add at your registrar:
# A     @      76.76.21.21
# CNAME www    cname.munashetech.cloud

# Enable SSL (automatic with Let's Encrypt)
mt cloud ssl enable myapp.com --auto-renew

# Configure redirects
mt cloud redirect add \
  --from www.myapp.com \
  --to myapp.com \
  --permanent

# Verify SSL certificate
mt cloud ssl status myapp.com
5
Deploy Your Application
10 min
  • Build and deploy to production
  • Monitor deployment progress
  • Verify deployment health
  • Test production endpoints
Code
# Manual deployment
mt cloud deploy \
  --env production \
  --region us-east

# Or push to trigger auto-deploy
git add .
git commit -m "Deploy to production"
git push origin main

# Watch deployment logs
mt cloud logs --follow --tail 100

# Check deployment status
mt cloud status

# View application URL
mt cloud url

# Run health check
curl https://myapp.com/api/health
6
Set Up Monitoring & Scaling
12 min
  • Configure application metrics
  • Set up alerting rules
  • Enable auto-scaling
  • Configure logging
Code
# Enable application monitoring
mt cloud monitor enable \
  --metrics cpu,memory,requests,errors

# Set up alerts
mt cloud alert create high-cpu \
  --metric cpu \
  --threshold 80 \
  --duration 5m \
  --notify email:ops@myapp.com

mt cloud alert create error-rate \
  --metric error_rate \
  --threshold 5 \
  --duration 2m \
  --notify slack:webhook_url

# Configure auto-scaling
mt cloud scale auto \
  --min-instances 2 \
  --max-instances 10 \
  --target-cpu 70 \
  --target-memory 80

# Set up log streaming
mt cloud logs stream \
  --level info \
  --format json \
  --destination datadog

# View metrics dashboard
mt cloud dashboard open
Performance Optimization Tips
  • Enable CDN: Distribute static assets globally for faster load times
  • Edge Functions: Deploy serverless functions closer to users
  • Image Optimization: Use Munashe Tech's automatic image optimization
  • Caching Strategy: Implement proper cache headers and Redis for sessions
  • Database Connection Pooling: Optimize database connections for serverless
Post-Deployment Checklist

Verify your deployment is successful:

  1. Application loads successfully on production domain
  2. SSL certificate is active and valid
  3. Database connections working properly
  4. API endpoints responding correctly
  5. Monitoring and alerts configured
  6. Auto-scaling rules tested
  7. Backup strategy in place

Common Deployment Issues

  • Build failures: Check build logs for missing dependencies or environment variables
  • Database connection errors: Verify connection string and network access
  • 404 errors: Ensure routing configuration matches your framework
  • Performance issues: Enable caching and check database query optimization

Next Steps

Set Up CI/CD Pipeline
Automate testing and deployment workflows
Multi-Region Deployment
Deploy to multiple regions for better performance

Need Deployment Help?

Our cloud experts can help you with custom deployment configurations