Skip to content

Latest commit

 

History

History
360 lines (275 loc) · 9.08 KB

File metadata and controls

360 lines (275 loc) · 9.08 KB

Deployment Guide: Job Application Tracker API on Render.com

This guide provides comprehensive instructions for deploying the Job Application Tracker API to Render.com, a modern cloud platform that offers seamless deployment for web applications and databases.

📋 Prerequisites

Before you begin, ensure you have:

  1. GitHub Repository: Your code must be pushed to GitHub, GitLab, or Bitbucket
  2. Render.com Account: Sign up at render.com
  3. All Deployment Files: Ensure all files from this setup are in your repository:
    • render.yaml - Render deployment configuration
    • requirements.txt - Python dependencies
    • start.sh - Production startup script
    • Procfile - Backup process definition
    • .env.production - Environment variables template

🚀 Quick Deployment (Recommended)

Option 1: Deploy with render.yaml (Infrastructure as Code)

  1. Connect Repository to Render

    # 1. Push all deployment files to your Git repository
    git add .
    git commit -m "Add Render deployment configuration"
    git push origin main
  2. Create New Render Service

    • Go to Render Dashboard
    • Click "New" → "Blueprint"
    • Connect your GitHub repository
    • Select the repository containing your render.yaml
    • Click "Apply"
  3. Render Will Automatically:

    • Create PostgreSQL database (job-tracker-db)
    • Deploy web service (job-tracker-api)
    • Set up environment variables
    • Configure health checks
    • Start the application
  4. Monitor Deployment

    • Watch the build logs in the Render dashboard
    • Verify database initialization completes successfully
    • Check the health endpoint once deployed

Option 2: Manual Deployment

If you prefer manual setup or need custom configurations:

Step 1: Create PostgreSQL Database

  1. In Render Dashboard, click "New" → "PostgreSQL"
  2. Configure the database:
    • Name: job-tracker-db
    • Database Name: job_tracker_production
    • User: job_tracker_user
    • Region: Choose closest to your users
    • Plan: Start with "Starter" (free)
  3. Click "Create Database"
  4. Wait for database to initialize
  5. Note the connection string (you'll need this later)

Step 2: Create Web Service

  1. In Render Dashboard, click "New" → "Web Service"
  2. Connect your repository
  3. Configure the service:
    • Name: job-tracker-api
    • Region: Same as your database
    • Branch: main (or your production branch)
    • Runtime: Python 3
    • Build Command:
      pip install --upgrade pip && pip install -r requirements.txt
    • Start Command: ./start.sh

Step 3: Configure Environment Variables

Add the following environment variables in the Render dashboard:

Required Variables:

# Database (use connection string from Step 1)
DATABASE_URL=postgresql://user:password@hostname/database

# Server Configuration
HOST=0.0.0.0
PORT=10000
ENVIRONMENT=production
DEBUG=false

# CORS (update with your domains)
CORS_ORIGINS=*
CORS_METHODS=GET,POST,PUT,DELETE,OPTIONS
CORS_HEADERS=*

Optional Variables:

# API Authentication
API_KEY_REQUIRED=false
API_KEY=your-secure-api-key

# Rate Limiting
RATE_LIMIT_REQUESTS=1000
RATE_LIMIT_WINDOW=60

# Logging
LOG_LEVEL=INFO

🔧 Configuration Details

Database Configuration

The PostgreSQL database will be automatically configured with:

  • Automated backups (daily)
  • Point-in-time recovery (7-day retention on free plan)
  • SSL connections (enforced)
  • Connection pooling
  • High availability (on paid plans)

Web Service Configuration

The web service includes:

  • Auto-scaling based on CPU/memory usage
  • Zero-downtime deployments
  • Health checks at /health endpoint
  • HTTPS automatically configured
  • Custom domain support
  • Environment variable management

Security Features

  • TLS/SSL encryption for all connections
  • Environment variable encryption at rest
  • Network isolation between services
  • DDoS protection
  • Regular security updates

🔒 Production Security Checklist

Before Going Live:

  1. Update CORS Origins

    CORS_ORIGINS=https://your-frontend.com,https://your-admin.com
  2. Enable API Key Authentication (if needed)

    API_KEY_REQUIRED=true
    API_KEY=your-secure-random-api-key
  3. Configure Rate Limiting

    RATE_LIMIT_REQUESTS=100  # Adjust based on your needs
    RATE_LIMIT_WINDOW=60
  4. Set Up Custom Domain

    • Add your domain in Render dashboard
    • Configure DNS records
    • SSL certificates are automatically managed
  5. Monitor and Alerts

    • Enable Render's monitoring features
    • Set up alerts for downtime or errors
    • Configure log aggregation if needed

📊 Monitoring & Maintenance

Built-in Monitoring

Render provides:

  • Real-time logs in the dashboard
  • Performance metrics (CPU, memory, response time)
  • Uptime monitoring
  • Error tracking

Health Checks

The API includes a comprehensive health endpoint at /health that checks:

  • Application status
  • Database connectivity
  • System uptime
  • Memory usage

Scaling

Vertical Scaling:

  • Upgrade to higher plans for more CPU/RAM
  • Database scaling handled automatically

Horizontal Scaling:

  • Increase worker count in environment variables
  • Consider Redis for session storage across instances

🛠 Troubleshooting

Common Issues

  1. Database Connection Errors

    # Check DATABASE_URL format
    # Ensure database is in same region
    # Verify firewall settings
  2. Import Errors

    # Ensure all dependencies are in requirements.txt
    # Check Python version compatibility
    # Verify file structure
  3. Port Binding Issues

    # Render automatically sets PORT=10000
    # Don't override this in production
    # Use HOST=0.0.0.0
  4. Slow Database Initialization

    # First deployment takes longer due to table creation
    # Check logs for migration progress
    # Subsequent deploys will be faster

Accessing Logs

# Via Render Dashboard
1. Go to your service
2. Click "Logs" tab
3. Use filters to find specific issues

# Via Render CLI (optional)
render logs service-name --follow

Database Access

# Via Render Dashboard
1. Go to your database service
2. Click "Connect" for connection details
3. Use psql or any PostgreSQL client

# Connection string format:
postgresql://username:password@hostname:port/database

📈 Performance Optimization

Production Recommendations

  1. Database Optimization

    • Use connection pooling (already configured)
    • Monitor slow queries
    • Regular VACUUM and ANALYZE
    • Consider read replicas for high traffic
  2. Application Optimization

    • Enable gzip compression
    • Use caching for frequently accessed data
    • Optimize database queries
    • Implement pagination for large datasets
  3. Monitoring

    • Set up error tracking (Sentry integration)
    • Monitor API response times
    • Track database performance
    • Set up uptime monitoring

🔄 CI/CD Setup

Automatic Deployments

Render automatically deploys when you push to your connected branch:

# Push changes
git add .
git commit -m "Update API features"
git push origin main

# Render automatically:
# 1. Detects changes
# 2. Runs build process
# 3. Deploys with zero downtime
# 4. Health checks new version
# 5. Routes traffic to new deployment

Manual Deployments

# Via Render Dashboard
1. Go to your service
2. Click "Manual Deploy"
3. Select commit/branch
4. Click "Deploy"

💰 Cost Optimization

Free Tier Limitations

  • Web service: 750 hours/month
  • Database: 90 days, then $7/month
  • Services sleep after 15 minutes of inactivity
  • 500 MB disk space

Upgrading Plans

  • Starter ($7/month): No sleep, custom domains
  • Standard ($25/month): More resources, better performance
  • Pro Plans: High availability, advanced features

🆘 Support & Resources

Documentation

Community

Contact


🎉 Deployment Complete!

Once deployed, your API will be available at:

  • API Endpoint: https://your-service-name.onrender.com
  • API Documentation: https://your-service-name.onrender.com/docs
  • Health Check: https://your-service-name.onrender.com/health

The API includes comprehensive documentation and examples accessible via the /docs endpoint.

Next Steps:

  1. Test all endpoints thoroughly
  2. Set up monitoring and alerts
  3. Configure your frontend to use the new API URL
  4. Set up custom domain (optional)
  5. Monitor performance and scale as needed

Happy deploying! 🚀