safetyMaster / render-deploy.md
mrvero's picture
Upload folder using huggingface_hub
0469d65 verified

A newer version of the Gradio SDK is available: 5.43.1

Upgrade

πŸš€ Deploy SafetyMaster Pro to Render (Free)

Why Render?

  • Free tier: 512 MB RAM, automatic HTTPS, zero-downtime deploys
  • Easy setup: Similar to Railway, just connect your GitHub repo
  • No credit card required for free tier
  • Perfect for Flask apps with AI models

πŸ“‹ Prerequisites

  • GitHub account with your SafetyMaster Pro code
  • Clean repository (large files already removed via .gitignore)

πŸ”§ Step 1: Prepare Your App

Your app is already configured for cloud deployment! The existing files work perfectly:

  • βœ… Dockerfile - Ready for containerized deployment
  • βœ… requirements.txt - Python dependencies
  • βœ… web_interface.py - Uses PORT environment variable
  • βœ… .dockerignore - Excludes unnecessary files

🌐 Step 2: Deploy to Render

Option A: Web Interface (Recommended)

  1. Sign up: Go to render.com and create free account
  2. Connect GitHub: Link your GitHub account
  3. Create Web Service:
    • Click "New +" β†’ "Web Service"
    • Select your SafetyMaster repository
    • Choose "Docker" as environment
    • Set service name: safetymaster-pro

Option B: Using render.yaml (Advanced)

Create render.yaml in your project root:

services:
  - type: web
    name: safetymaster-pro
    env: docker
    plan: free
    dockerfilePath: ./Dockerfile
    envVars:
      - key: PORT
        value: 10000
      - key: PYTHONUNBUFFERED
        value: 1

βš™οΈ Step 3: Configuration

Environment Variables (if needed)

  • PORT: Automatically set by Render
  • SECRET_KEY: Add your own secret key for Flask sessions

Build Settings

  • Build Command: Automatically detected from Dockerfile
  • Start Command: Automatically detected from Dockerfile

🎯 Step 4: Deploy

  1. Push to GitHub: Make sure your latest code is pushed
  2. Auto-deploy: Render will automatically build and deploy
  3. Monitor: Watch the build logs in Render dashboard
  4. Access: Your app will be available at https://safetymaster-pro.onrender.com

πŸ“Š Expected Performance

Free Tier Limits

  • RAM: 512 MB (sufficient for your Flask app)
  • CPU: 0.1 CPU units (shared)
  • Storage: Ephemeral (files reset on restart)
  • Bandwidth: 100 GB/month
  • Build time: 15 minutes max

AI Model Considerations

  • Models download automatically on first run
  • May take 2-3 minutes for first startup (cold start)
  • Subsequent requests are fast
  • App sleeps after 15 minutes of inactivity (free tier)

πŸ”§ Troubleshooting

Common Issues

  1. Build timeout: Models are too large

    • Solution: Models download at runtime (already configured)
  2. Memory issues: App uses too much RAM

    • Solution: Optimize model loading in safety_detector.py
  3. Slow startup: First request takes time

    • Solution: Normal behavior, subsequent requests are fast

Optimization Tips

# In safety_detector.py - already implemented
# Models download only when needed
# Efficient memory usage
# Automatic cleanup

πŸ†“ Alternative Free Hosts

If Render doesn't work, try these:

1. Fly.io

  • Free tier: 3 VMs, 3GB storage
  • Setup: flyctl launch (requires credit card)
  • Pros: Better performance, global edge

2. Koyeb

  • Free tier: 1 web service
  • Setup: Connect GitHub repo
  • Pros: No credit card required

3. PythonAnywhere

  • Free tier: 512MB storage
  • Setup: Upload files manually
  • Pros: Python-focused, very simple

πŸŽ‰ Success!

Once deployed, your SafetyMaster Pro will be live at: https://your-app-name.onrender.com

Features available:

  • βœ… Real-time safety monitoring
  • βœ… PPE detection (Hard Hat, Safety Vest, Mask)
  • βœ… Violation alerts
  • βœ… Web dashboard
  • βœ… Image capture

πŸ“ž Need Help?


Ready to deploy? Just push your code to GitHub and connect it to Render! πŸš€