Deploy to Render

Render Overview and Your First Web Service

30 мин

Render is a platform-as-a-service that builds and runs your code from a Git repository. You get HTTPS, logs, automatic deploys, managed databases and background workers without managing servers. PandaDev itself is designed to run on Render.

Service types

Type Use for
Web Service apps that serve HTTP (Flask, Django, Node)
Static Site plain HTML/CSS/JS or built frontends
Background Worker queue consumers, long-running jobs
Cron Job scheduled tasks
Private Service internal services not exposed to the internet
PostgreSQL / Key Value (Redis-compatible) managed data stores

Deploying a Flask app

  1. Push your code to GitHub or GitLab, with requirements.txt, a wsgi.py exposing app, and gunicorn in requirements.
  2. In the dashboard choose New → Web Service and connect the repository.
  3. Configure:
Setting Example
Runtime Python
Build command pip install -r requirements.txt
Start command gunicorn wsgi:app -c gunicorn.conf.py
Instance type start small; scale later
Health check path /api/health
  1. Add environment variables (next modules), then create the service.

Render builds, starts your app, routes https://<name>.onrender.com to it and redeploys on every push to the selected branch.

Binding to the port

Render tells your app which port to listen on through the PORT environment variable. Bind to 0.0.0.0:$PORT:

# gunicorn.conf.py
import os
bind = f"0.0.0.0:{os.environ.get('PORT', '10000')}"

A service that listens on the wrong port fails its health check and never becomes live.

Python version

Pin it so builds are reproducible: set a PYTHON_VERSION environment variable (for example 3.11.9) or a .python-version file, as described in Render's docs.

Free vs paid instances

Free instances are great for experiments but spin down when idle (the next request waits for a cold start) and have limits. Use a paid instance for anything customers rely on.

Exercise

Deploy a minimal Flask app with a /api/health route to Render, push a change and watch the automatic redeploy in the Events and Logs tabs.

Check yourself

  • Which service type runs scheduled jobs?
  • Why must the app bind to $PORT?
  • What happens to a free instance when idle?

Ваш прогресс сохраняется только в этом браузере.

Отправить на проверку (10 баллов)