Back to library

Render Deployment

Skill for Render Deployment — auto-generated from documentation

infrastructure
by skynetv1.0.0
render-deployinfrastructureauto-generated

0

Total Uses

0

Successes

0%

Success Rate

Compatible Agents

claude-codecodexgemini

Instruction

--- name: Render Deployment description: Use this skill when you need to deploy web applications, APIs, static sites, or services to Render cloud platform. Essential for setting up continuous deployment, configuring environment variables, managing domains, and scaling applications. metadata: author: skynet version: 1.0.0 category: infrastructure --- # Render Deployment ## Overview Render is a modern cloud platform for deploying web applications, APIs, static sites, and background services with automatic builds, SSL, and global CDN. ## Prerequisites - Git repository with your code - Render account - Basic understanding of your application's runtime requirements ## Common Workflows ### 1. Deploy Web Service from Git #### Connect Repository ```bash # First, ensure your code is in a Git repository git init git add . git commit -m "Initial commit" git remote add origin https://github.com/username/repo.git git push -u origin main ``` #### Service Configuration (render.yaml) ```yaml services: - type: web name: my-app env: node # node, python, ruby, go, rust, docker buildCommand: npm install && npm run build startCommand: npm start plan: free # free, starter, standard, pro envVars: - key: NODE_ENV value: production - key: DATABASE_URL fromDatabase: name: my-database property: connectionString ``` #### Environment-Specific Deployment ```bash # Production deployment git push origin main # Staging deployment (separate service) git checkout -b staging git push origin staging ``` ### 2. Static Site Deployment #### For React/Vue/Angular Apps ```yaml services: - type: web name: frontend env: static buildCommand: npm install && npm run build staticPublishPath: ./dist routes: - type: rewrite source: /* destination: /index.html ``` #### For Jekyll/Hugo Sites ```yaml services: - type: web name: blog env: static buildCommand: bundle install && bundle exec jekyll build staticPublishPath: ./_site ``` ### 3. API Service Deployment #### Node.js Express API ```yaml services: - type: web name: api env: node buildCommand: npm install startCommand: node server.js healthCheckPath: /health envVars: - key: PORT value: 10000 - key: API_KEY sync: false # Requires manual entry in dashboard ``` #### Python Flask/Django API ```yaml services: - type: web name: python-api env: python buildCommand: pip install -r requirements.txt startCommand: gunicorn app:app envVars: - key: FLASK_ENV value: production ``` ### 4. Database Setup #### PostgreSQL Database ```yaml databases: - name: my-database databaseName: myapp user: myapp_user plan: free # free, starter, standard, pro ``` #### Connect to Database ```bash # Get connection string from Render dashboard DATABASE_URL="postgresql://user:password@hostname:port/database" # Test connection psql $DATABASE_URL -c "SELECT version();" ``` ### 5. Background Services #### Worker Service ```yaml services: - type: worker name: background-worker env: node buildCommand: npm install startCommand: node worker.js envVars: - key: QUEUE_URL value: redis://redis-service:6379 ``` #### Cron Job ```yaml services: - type: cron name: daily-cleanup env: python buildCommand: pip install -r requirements.txt startCommand: python cleanup.py schedule: "0 2 * * *" # Daily at 2 AM UTC ``` ## Decision Trees ### Choose Service Type ``` Is it a web application? ├── Yes → type: web │ ├── Static files only? → env: static │ ├── Node.js? → env: node │ ├── Python? → env: python │ ├── Custom Docker? → env: docker │ └── Other runtime? → env: [ruby|go|rust] └── No ├── Background processing? → type: worker ├── Scheduled tasks? → type: cron └── Database needed? → Add databases section ``` ### Environment Strategy ``` Application stage? ├── Development → Use free plan, simple config ├── Staging → Separate service, environment variables └── Production → Paid plan, custom domains, monitoring ``` ## Environment Variables ### Set via render.yaml ```yaml envVars: - key: NODE_ENV value: production - key: API_URL value: https://api.myapp.com - key: SECRET_KEY generateValue: true # Auto-generate secure value ``` ### Set via Dashboard ``` 1. Go to service dashboard 2. Navigate to Environment tab 3. Add key-value pairs 4. Click "Save Changes" ``` ## Custom Domains ### Add Custom Domain ```yaml services: - type: web name: my-app customDomains: - name: myapp.com - name: www.myapp.com ``` ### DNS Configuration ``` # Add these records to your DNS provider: Type: CNAME Name: www Value: your-app.onrender.com Type: A Name: @ Value: [Render IP from dashboard] ``` ## Scaling and Performance ### Auto-scaling Configuration ```yaml services: - type: web name: scalable-app plan: standard scaling: minInstances: 2 maxInstances: 10 targetMemoryPercent: 80 targetCPUPercent: 80 ``` ### Performance Monitoring ```javascript // Add health check endpoint app.get('/health', (req, res) => { res.status(200).json({ status: 'healthy', timestamp: new Date().toISOString(), uptime: process.uptime() }); }); ``` ## Docker Deployment ### Dockerfile Example ```dockerfile FROM node:16-alpine WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 10000 CMD ["npm", "start"] ``` ### Docker Service Configuration ```yaml services: - type: web name: docker-app env: docker dockerfilePath: ./Dockerfile dockerContext: . ``` ## Troubleshooting ### Common Build Errors #### "Build failed: command not found" ```bash # Solution: Specify correct build command in render.yaml buildCommand: npm ci && npm run build # For Python buildCommand: pip install -r requirements.txt # For Ruby buildCommand: bundle install ``` #### "Port binding failed" ```javascript // Ensure app binds to PORT environment variable const PORT = process.env.PORT || 3000; app.listen(PORT, '0.0.0.0', () => { console.log(`Server running on port ${PORT}`); }); ``` #### "Health check failed" ```yaml # Add health check path services: - type: web healthCheckPath: /health ``` ### Runtime Errors #### "Service crashed: Exit code 1" ```bash # Check logs in Render dashboard # Common fixes: # 1. Verify start command startCommand: node server.js # 2. Check environment variables # 3. Ensure database connection is working ``` #### "Database connection failed" ```javascript // Use connection pooling and error handling const { Pool } = require('pg'); const pool = new Pool({ connectionString: process.env.DATABASE_URL, ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false }); ``` ### Deployment Issues #### "Deploy stuck in building" ```yaml # Optimize build process services: - type: web buildCommand: npm ci --only=production && npm run build:prod ``` #### "Static files not serving" ```yaml # Verify static publish path services: - type: web env: static staticPublishPath: ./build # React # staticPublishPath: ./dist # Vue/Vite ``` ### Performance Issues #### "Slow response times" ```yaml # Upgrade plan or enable auto-scaling services: - type: web plan: standard # Upgrade from free numInstances: 2 # Multiple instances ``` #### "Memory limit exceeded" ```javascript // Optimize memory usage process.on('warning', (warning) => { console.warn('Memory warning:', warning); }); // Monitor memory setInterval(() => { const used = process.memoryUsage(); console.log('Memory usage:', Math.round(used.rss / 1024 / 1024), 'MB'); }, 30000); ``` ## Best Practices 1. **Use render.yaml** for infrastructure as code 2. **Environment variables** for configuration 3. **Health checks** for reliability 4. **Proper error handling** in applications 5. **Database connection pooling** for performance 6. **Staging environments** for testing 7. **Monitor logs** regularly 8. **Use CDN** for static assets 9. **Implement graceful shutdowns** 10. **Regular security updates**

Install

curl -s https://skills.skynet.ceo/api/skills/render-deploy/skill.md