Pular para o conteúdo

Render Cheat Sheet

Overview

Render is a cloud platform that provides a unified experience for deploying web services, static sites, background workers, cron jobs, and managed databases. It connects directly to your Git repository (GitHub or GitLab) and automatically builds and deploys your application on every push. Render aims to combine the simplicity of Heroku with the power of AWS at a competitive price.

Render supports a wide range of languages and frameworks out of the box, including Node.js, Python, Ruby, Go, Rust, Elixir, PHP, and Docker. It provides free TLS certificates, global CDN for static sites, private networking between services, persistent disks, and a built-in key-value store. Services auto-scale, and the platform handles infrastructure management automatically.

Installation

Render CLI

# Currently Render is primarily managed through:
# 1. Web Dashboard: https://dashboard.render.com
# 2. Render API
# 3. Infrastructure as Code (render.yaml)

# There is no official CLI, but the API can be used with curl
# Blueprint files (render.yaml) define infrastructure as code

Connecting a Repository

1. Sign up at https://render.com
2. Connect your GitHub or GitLab account
3. Click "New" and select service type
4. Choose repository and branch
5. Configure build and start commands
6. Deploy

Service Types

Service TypeDescriptionUse Case
Web ServiceLong-running HTTP serversAPIs, web apps
Static SiteStatic HTML/CSS/JS filesSPAs, docs, marketing sites
Background WorkerNon-HTTP processesQueue consumers, data processing
Cron JobScheduled tasksPeriodic scripts, reports
Private ServiceInternal-only servicesMicroservices, internal APIs
PostgreSQLManaged PostgreSQL databaseApplication database
RedisManaged Redis instanceCaching, queues

Core Configuration

render.yaml (Blueprint)

# render.yaml — Infrastructure as Code
services:
  # Web Service
  - type: web
    name: my-api
    runtime: node
    region: oregon
    plan: starter
    buildCommand: npm install && npm run build
    startCommand: npm start
    envVars:
      - key: NODE_ENV
        value: production
      - key: DATABASE_URL
        fromDatabase:
          name: my-db
          property: connectionString
      - key: REDIS_URL
        fromService:
          name: my-redis
          type: redis
          property: connectionString
      - key: SECRET_KEY
        generateValue: true
    healthCheckPath: /health
    autoDeploy: true

  # Static Site
  - type: web
    name: my-frontend
    runtime: static
    buildCommand: npm install && npm run build
    staticPublishPath: dist
    headers:
      - path: /*
        name: X-Frame-Options
        value: DENY
    routes:
      - type: rewrite
        source: /*
        destination: /index.html

  # Background Worker
  - type: worker
    name: queue-processor
    runtime: python
    buildCommand: pip install -r requirements.txt
    startCommand: python worker.py
    envVars:
      - key: REDIS_URL
        fromService:
          name: my-redis
          type: redis
          property: connectionString

  # Cron Job
  - type: cron
    name: daily-report
    runtime: node
    buildCommand: npm install
    startCommand: node scripts/report.js
    schedule: "0 8 * * *"

  # Private Service (internal only)
  - type: pserv
    name: internal-api
    runtime: docker
    dockerfilePath: ./Dockerfile
    envVars:
      - key: PORT
        value: 3001

databases:
  - name: my-db
    plan: starter
    region: oregon
    postgresMajorVersion: 16
    databaseName: myapp
    user: myapp

  - name: my-redis
    plan: starter
    region: oregon
    maxmemoryPolicy: allkeys-lru

Environment Groups

# Shared environment variables across services
envVarGroups:
  - name: shared-settings
    envVars:
      - key: APP_NAME
        value: MyApp
      - key: LOG_LEVEL
        value: info
      - key: SENTRY_DSN
        value: https://xxx@sentry.io/123

services:
  - type: web
    name: my-api
    envVars:
      - fromGroup: shared-settings

Deployment

Language-Specific Configurations

# Node.js
- type: web
  name: node-app
  runtime: node
  buildCommand: npm ci && npm run build
  startCommand: node dist/server.js
  nodeVersion: 20

# Python
- type: web
  name: python-app
  runtime: python
  buildCommand: pip install -r requirements.txt
  startCommand: gunicorn app:app --bind 0.0.0.0:$PORT
  pythonVersion: "3.12"

# Go
- type: web
  name: go-app
  runtime: go
  buildCommand: go build -o server .
  startCommand: ./server

# Docker
- type: web
  name: docker-app
  runtime: docker
  dockerfilePath: ./Dockerfile
  dockerContext: .

Dockerfile Example

# For Docker-based deployments
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./
EXPOSE 3000
CMD ["node", "dist/server.js"]

Health Checks

services:
  - type: web
    name: my-api
    healthCheckPath: /health
    # Render pings this endpoint to verify the service is healthy
    # Must return 200 status code
// Express health check endpoint
app.get("/health", (req, res) => {
  res.status(200).json({ status: "ok", uptime: process.uptime() })
})

API Usage

# List services
curl "https://api.render.com/v1/services" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Get service details
curl "https://api.render.com/v1/services/SERVICE_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Trigger a deploy
curl -X POST "https://api.render.com/v1/services/SERVICE_ID/deploys" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"clearCache": "do_not_clear"}'

# List deploys
curl "https://api.render.com/v1/services/SERVICE_ID/deploys" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Suspend a service
curl -X POST "https://api.render.com/v1/services/SERVICE_ID/suspend" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Resume a service
curl -X POST "https://api.render.com/v1/services/SERVICE_ID/resume" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Get environment variables
curl "https://api.render.com/v1/services/SERVICE_ID/env-vars" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Update environment variable
curl -X PUT "https://api.render.com/v1/services/SERVICE_ID/env-vars" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[{"key":"LOG_LEVEL","value":"debug"}]'

Advanced Usage

Persistent Disks

services:
  - type: web
    name: my-app
    disk:
      name: app-data
      mountPath: /var/data
      sizeGB: 10

Custom Domains

# Via Dashboard:
1. Go to Service > Settings > Custom Domains
2. Add your domain (e.g., api.example.com)
3. Add DNS records as instructed:
   - CNAME record pointing to your-service.onrender.com
   - Or A record for apex domains
4. TLS certificate is provisioned automatically

Auto-Scaling

services:
  - type: web
    name: my-api
    plan: standard
    scaling:
      minInstances: 1
      maxInstances: 10
      targetMemoryPercent: 80
      targetCPUPercent: 70

Preview Environments

# render.yaml
previewsEnabled: true
previewsExpireAfterDays: 7

services:
  - type: web
    name: my-api
    previews:
      generation: automatic

Deploy Hooks

# Trigger deploy via webhook URL
curl -X POST "https://api.render.com/deploy/srv-XXXX?key=YOUR_DEPLOY_KEY"

# Use in CI/CD pipelines or external automation

Logging

# View logs via API
curl "https://api.render.com/v1/services/SERVICE_ID/logs" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Stream logs (via dashboard)
# Dashboard > Service > Logs tab
# Filter by deployment, search text

Troubleshooting

IssueSolution
Build failingCheck build command and runtime version; review build logs in dashboard
Service not startingVerify start command; ensure app listens on $PORT environment variable
Deploy stuckCheck for large dependencies or build steps; increase plan if hitting limits
Database connection refusedUse the internal connection string for services in the same region
Static site 404Set up rewrite rules for SPA routing; check staticPublishPath
Environment variables not foundVerify env vars in dashboard; redeploy after changes
Health check failingEnsure /health endpoint returns 200; check that server starts within timeout
Custom domain not workingVerify DNS records; wait for TLS certificate provisioning (up to 30 min)
Disk fullMonitor disk usage; increase sizeGB or clean up old files