Skip to content

Latest commit

 

History

History
342 lines (263 loc) · 9.18 KB

File metadata and controls

342 lines (263 loc) · 9.18 KB

Deploying InstaGist to Render.com

Complete guide for deploying your custom n8n image with InstaGist to Render.com.

Overview

Since Render.com doesn't allow you to install packages directly on their managed Docker containers, you need to:

  1. Build a custom Docker image with yt-dlp and ffmpeg
  2. Push it to a container registry (Docker Hub or GitHub Container Registry)
  3. Deploy it on Render.com using your custom image

Option 1: Using Docker Hub (Recommended)

Step 1: Build and Push Custom Image

  1. Create a Docker Hub account (if you don't have one)

  2. Login to Docker Hub from your terminal

    docker login
  3. Build your custom n8n image

    cd /Users/fribu/Sites/insta-gist
    docker build -t your-dockerhub-username/insta-gist-n8n:latest .
  4. Test the image locally (optional but recommended)

    docker run -p 5678:5678 your-dockerhub-username/insta-gist-n8n:latest

    Visit http://localhost:5678 to verify n8n starts correctly

  5. Push to Docker Hub

    docker push your-dockerhub-username/insta-gist-n8n:latest

Step 2: Deploy to Render.com

  1. Go to Render.com Dashboard

  2. Create a New Web Service

    • Click "New +" → "Web Service"
  3. Configure the Service

    • Deployment Method: Choose "Deploy an existing image from a registry"
    • Image URL: Enter your Docker Hub image
      your-dockerhub-username/insta-gist-n8n:latest
      
  4. Configure Service Settings

    • Name: insta-gist-n8n (or your preferred name)
    • Region: Choose closest to your users
    • Instance Type:
      • Start with "Free" for testing
      • Upgrade to "Starter" ($7/mo) or higher for production
    • Port: 5678
  5. Add Environment Variables Click "Advanced" and add these environment variables:

    Key Value Notes
    N8N_HOST Your Render URL (e.g., insta-gist-n8n.onrender.com) Required
    N8N_PROTOCOL https Render provides HTTPS
    WEBHOOK_URL https://your-app.onrender.com Your full Render URL
    GENERIC_TIMEZONE America/New_York Your timezone
    N8N_ENCRYPTION_KEY Generate a random string For credential encryption

    Generate encryption key:

    openssl rand -hex 32
  6. Create the Service

    • Click "Create Web Service"
    • Render will deploy your custom n8n image
    • Wait for deployment to complete (5-10 minutes)
  7. Access n8n

    • Once deployed, visit your Render URL: https://your-app.onrender.com
    • Complete n8n setup wizard
    • Create your admin account

Step 3: Import and Configure Workflow

  1. Import the workflow

    • In n8n UI: Workflows → Import from File
    • Select n8n-workflows/instagram-gist-workflow.json
  2. Add OpenAI credentials

    • Credentials → Add Credential → OpenAI API
    • Enter your OpenAI API key
  3. Update webhook nodes

    • The webhook URL will be: https://your-app.onrender.com/webhook/instagram-gist
    • Note this URL for testing
  4. Activate the workflow

    • Toggle the workflow to "Active"

Step 4: Test the Deployment

export WEBHOOK_URL="https://your-app.onrender.com/webhook/instagram-gist"
./scripts/test-webhook.sh "https://www.instagram.com/reel/EXAMPLE/"

Option 2: Using GitHub Container Registry (GHCR)

If you prefer using GitHub's container registry:

Step 1: Build and Push to GHCR

  1. Create a Personal Access Token

    • Go to GitHub → Settings → Developer settings → Personal access tokens
    • Generate new token with write:packages permission
  2. Login to GHCR

    echo YOUR_GITHUB_TOKEN | docker login ghcr.io -u YOUR_GITHUB_USERNAME --password-stdin
  3. Build and tag the image

    docker build -t ghcr.io/your-github-username/insta-gist-n8n:latest .
  4. Push to GHCR

    docker push ghcr.io/your-github-username/insta-gist-n8n:latest
  5. Make the package public (for Render to access)

    • Go to GitHub → Your profile → Packages
    • Find insta-gist-n8n
    • Package settings → Change visibility → Public

Step 2: Deploy to Render

Follow the same steps as Option 1, but use the GHCR image URL:

ghcr.io/your-github-username/insta-gist-n8n:latest

Option 3: Deploy Directly from GitHub (Automatic Builds)

For automatic rebuilds when you update the Dockerfile:

Step 1: Push Code to GitHub

  1. Create a GitHub repository

    cd /Users/fribu/Sites/insta-gist
    git init
    git add .
    git commit -m "Initial commit: InstaGist n8n workflow"
    git remote add origin https://github.com/your-username/insta-gist.git
    git push -u origin main
  2. Create render.yaml (see next section)

Step 2: Connect to Render

  1. In Render Dashboard

    • Click "New +" → "Blueprint"
    • Connect your GitHub repository
    • Render will automatically detect render.yaml
  2. Approve and Deploy

    • Review the configuration
    • Click "Apply"

render.yaml Configuration

Create this file for automatic deployments:

services:
  - type: web
    name: insta-gist-n8n
    env: docker
    dockerfilePath: ./Dockerfile
    plan: free  # or 'starter' for production
    region: oregon  # or your preferred region
    envVars:
      - key: N8N_HOST
        sync: false
      - key: N8N_PROTOCOL
        value: https
      - key: WEBHOOK_URL
        sync: false
      - key: GENERIC_TIMEZONE
        value: UTC
      - key: N8N_ENCRYPTION_KEY
        generateValue: true
    healthCheckPath: /healthz

Important Render.com Considerations

Free Tier Limitations

  • Sleep after 15 minutes of inactivity
    • Service will spin down
    • First request after sleep takes 30-60 seconds to wake up
    • Not suitable for production

Solution: Upgrade to Starter plan ($7/mo) for always-on service

Disk Space

  • Ephemeral filesystem

    • Temporary files are deleted on restart
    • /tmp is cleared periodically
    • This is fine for InstaGist (we cleanup files anyway)
  • Persistent storage

    • n8n data needs to persist
    • Use Render Disks (paid feature) or external database

For n8n persistence, add a disk:

  1. In Render Dashboard → Your Service → Settings
  2. Add a Disk
  3. Mount at /home/node/.n8n
  4. Size: 1GB should be sufficient

Environment Variables Best Practices

Required variables:

N8N_HOST=your-app.onrender.com
N8N_PROTOCOL=https
WEBHOOK_URL=https://your-app.onrender.com
N8N_ENCRYPTION_KEY=your-generated-key

Optional but recommended:

# For better performance
N8N_METRICS=true
EXECUTIONS_DATA_PRUNE=true
EXECUTIONS_DATA_MAX_AGE=168  # 7 days

# For security
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=your-secure-password

Updating Your Deployment

When you update the Dockerfile

Option 1: Manual rebuild

# Rebuild and push
docker build -t your-dockerhub-username/insta-gist-n8n:latest .
docker push your-dockerhub-username/insta-gist-n8n:latest

# In Render: Manual Deploy → Clear build cache & deploy

Option 2: Automatic with render.yaml

# Just push to GitHub
git add .
git commit -m "Update Dockerfile"
git push

# Render will automatically rebuild and deploy

Troubleshooting

Service won't start

  • Check Render logs: Dashboard → Your Service → Logs
  • Common issues:
    • Missing environment variables
    • Port mismatch (should be 5678)
    • Build errors in Dockerfile

yt-dlp or ffmpeg not found

  • Verify build completed successfully
  • Check build logs in Render
  • Try rebuilding with cache cleared

Workflow execution fails

  • Check n8n execution logs
  • Verify OpenAI credentials are set
  • Test with a known-good Instagram URL

Slow response times

  • Free tier spins down after 15 min inactivity
  • Upgrade to paid tier for production use
  • Consider adding a health check ping to keep service warm

Cost Estimate

Render.com

  • Free tier: $0/mo (but sleeps after inactivity)
  • Starter: $7/mo (always on, 512MB RAM)
  • Standard: $25/mo (1GB RAM, better for high volume)

Total Monthly Cost

  • Render Starter: $7/mo
  • OpenAI API: ~$3-30/mo (depends on usage)
  • Total: $10-40/mo

Production Checklist

  • Use Starter plan or higher (no sleep)
  • Add persistent disk for n8n data
  • Set N8N_ENCRYPTION_KEY
  • Enable basic auth or set up proper authentication
  • Set up custom domain (optional)
  • Configure error notifications
  • Set up monitoring/alerts
  • Add rate limiting to webhook
  • Implement caching for frequently accessed videos
  • Set execution data retention policy

Next Steps

  1. Build and push your Docker image
  2. Deploy to Render.com
  3. Import the InstaGist workflow
  4. Add OpenAI credentials
  5. Test with a sample Instagram URL
  6. Consider upgrading to paid tier for production

Support Resources