What is Kamal?
Kamal (formerly MRSK) is a deployment tool from the creators of Rails (37signals/Basecamp). It deploys containerized web apps to any server — bare metal, VPS, or cloud — without Kubernetes complexity.
Kamal 2 powers HEY.com and Basecamp in production.
Quick Start
gem install kamal
kamal init
kamal setup
kamal deploy
Configuration
# config/deploy.yml
service: my-app
image: myorg/my-app
servers:
web:
hosts:
- 192.168.1.1
- 192.168.1.2
options:
memory: 512m
worker:
hosts:
- 192.168.1.3
cmd: bundle exec sidekiq
registry:
username: myorg
password:
- KAMAL_REGISTRY_PASSWORD
env:
clear:
RAILS_ENV: production
DATABASE_URL: postgres://db-host/myapp
secret:
- RAILS_MASTER_KEY
- STRIPE_SECRET_KEY
proxy:
ssl: true
host: myapp.com
app_port: 3000
accessories:
db:
image: postgres:16
host: 192.168.1.4
port: 5432
env:
clear:
POSTGRES_DB: myapp_production
secret:
- POSTGRES_PASSWORD
directories:
- data:/var/lib/postgresql/data
redis:
image: redis:7
host: 192.168.1.4
port: 6379
directories:
- data:/data
Zero-Downtime Deploys
# Deploy with zero downtime
kamal deploy
# What happens:
# 1. Build Docker image locally
# 2. Push to registry
# 3. Pull on servers
# 4. Start new container
# 5. Health check passes
# 6. Switch traffic (kamal-proxy)
# 7. Stop old container
The built-in kamal-proxy handles traffic switching — no nginx config needed.
Key Commands
# First-time setup (installs Docker, kamal-proxy)
kamal setup
# Deploy latest code
kamal deploy
# Rollback to previous version
kamal rollback
# View logs
kamal app logs
kamal app logs -f # Follow
# Run console
kamal app exec -i 'bin/rails console'
# Run one-off task
kamal app exec 'bin/rails db:migrate'
# Manage accessories
kamal accessory boot db
kamal accessory logs db
# Check server details
kamal details
Kamal 2 New Features
Built-in Proxy (replaces Traefik)
Kamal 2 ships with kamal-proxy — a purpose-built reverse proxy:
proxy:
ssl: true
host: myapp.com
buffering:
requests: true
responses: true
max_request_body: 10m
response_timeout: 30
healthcheck:
interval: 3
path: /up
timeout: 3
Aliases
# config/deploy.yml
aliases:
console: app exec -i 'bin/rails console'
logs: app logs -f
shell: app exec -i bash
kamal console # Opens Rails console on production
kamal logs # Follows production logs
Multi-App on Single Server
# app1/config/deploy.yml
proxy:
host: app1.com
# app2/config/deploy.yml
proxy:
host: app2.com
Multiple apps share the same server, kamal-proxy routes by hostname.
Cost Comparison
| Setup | Monthly Cost |
|---|---|
| Heroku (2 dynos) | $50-100 |
| AWS ECS/Fargate | $50-150 |
| Kubernetes (EKS) | $75-200+ |
| Kamal + Hetzner VPS | $5-20 |
Kamal + a $5 VPS = production-ready deployment.
Need help deploying apps or setting up CI/CD pipelines?
📧 spinov001@gmail.com
🔧 My tools on Apify Store
Kamal, Docker Compose, or Kubernetes? Share your deployment stack!
Top comments (0)