Deployment, Dynos & Config
Heroku: Deployment, Dynos & Config Heroku is a PaaS (Platform as a Service) that runs apps in containers called dynos. Deploy via Git push, Docker, or CI/CD. He…
Heroku: Deployment, Dynos & Config
Heroku is a PaaS (Platform as a Service) that runs apps in containers called dynos. Deploy via Git push, Docker, or CI/CD. Heroku handles OS, runtime, scaling, and infrastructure.
Deploy via Git
# Install Heroku CLI
brew tap heroku/brew && brew install heroku
# Login and create app
heroku login
heroku create my-app-name
# or: heroku create (auto-generates a name)
# Deploy
git push heroku main
# View logs
heroku logs --tail
# Open app in browser
heroku open
# Run one-off commands
heroku run bash
heroku run npx prisma migrate deploy
heroku run python manage.py migrateProcfile
The Procfile defines process types. Heroku reads it to know how to start your app.
# Procfile — no file extension, at repo root
# Web process (receives HTTP traffic)
web: node dist/server.js
# or:
web: npm start
# or:
web: gunicorn myapp.wsgi
# Background worker
worker: node workers/queue-processor.js
# Release phase — runs before new dynos start (use for migrations)
release: npx prisma migrate deploy
# or:
release: python manage.py migrateDynos
Eco/Basic ($5-7/mo): single dyno, sleeps after 30 min of inactivity — for hobby projects
Standard-1X/2X ($25-50/mo): always-on, 512MB-1GB RAM
Performance-M/L ($250-500/mo): dedicated compute, auto-scaling available
Free tier: discontinued in 2022 — use Railway, Render, or Fly.io for free alternatives
Dyno count: heroku ps:scale web=2 — run 2 web dynos for load distribution
Dyno formation: heroku ps — see running dynos and their status
# Scale dynos
heroku ps:scale web=2 worker=1
# Check dyno status
heroku ps
# Restart dynos
heroku restart
heroku dyno:restart web.1 # restart specific dynoConfig Vars (Environment Variables)
# Set config vars
heroku config:set DATABASE_URL=postgres://...
heroku config:set NODE_ENV=production REDIS_URL=redis://...
# View all config vars
heroku config
# Get one value
heroku config:get DATABASE_URL
# Remove a var
heroku config:unset MY_VAR
# Copy config from one app to another
heroku config -s --app source-app | xargs heroku config:set --app target-appBuildpacks
# Heroku auto-detects language via buildpacks
# Node.js: package.json present
# Python: requirements.txt or Pipfile
# Ruby: Gemfile
# Specify explicitly
heroku buildpacks:set heroku/nodejs
heroku buildpacks:set heroku/python
# Multiple buildpacks (e.g., Node + Python)
heroku buildpacks:add --index 1 heroku/nodejs
heroku buildpacks:add --index 2 heroku/python
# Custom buildpack
heroku buildpacks:set https://github.com/owner/buildpack.git