DEV Community

Alex Spinov
Alex Spinov

Posted on

Kamal Has a Free API: Deploy Docker Apps Without Kubernetes

Kubernetes is overkill for 99% of apps. Kamal deploys Docker containers to bare servers with zero-downtime — and it's what 37signals uses for Hey.com and Basecamp.

What Is Kamal?

Kamal (from the creators of Ruby on Rails) deploys Docker containers to any Linux server. No Kubernetes. No orchestrator. Just Docker + SSH.

gem install kamal
kamal init
Enter fullscreen mode Exit fullscreen mode

Configuration

# config/deploy.yml
service: my-app
image: myregistry/my-app

servers:
  web:
    - 192.168.1.1
    - 192.168.1.2
  worker:
    hosts:
      - 192.168.1.3
    cmd: bundle exec sidekiq

proxy:
  ssl: true
  host: myapp.com

env:
  clear:
    RAILS_ENV: production
  secret:
    - DATABASE_URL
    - SECRET_KEY_BASE

accessories:
  db:
    image: postgres:16
    host: 192.168.1.1
    port: 5432
    env:
      clear:
        POSTGRES_DB: myapp_production
      secret:
        - POSTGRES_PASSWORD
    volumes:
      - /var/lib/postgresql/data:/var/lib/postgresql/data

  redis:
    image: redis:7
    host: 192.168.1.1
    port: 6379
Enter fullscreen mode Exit fullscreen mode

Deploy

# First deploy — sets up everything
kamal setup

# Subsequent deploys
kamal deploy

# Zero-downtime deploys with kamal-proxy:
# 1. Build new image
# 2. Start new container
# 3. Health check passes
# 4. Route traffic to new container
# 5. Stop old container
Enter fullscreen mode Exit fullscreen mode

Commands

kamal deploy          # Build, push, deploy
kamal rollback        # Rollback to previous version
kamal app logs        # View logs
kamal app exec "rails console"  # Remote console
kamal env push        # Push env changes
kamal accessory reboot db  # Restart database
Enter fullscreen mode Exit fullscreen mode

Why Kamal Over Kubernetes

Feature Kubernetes Kamal
Setup time Hours/days 10 minutes
Learning curve Steep Minimal
Min servers 3+ (control plane) 1
Config files Dozens of YAML 1 YAML
Zero-downtime Yes Yes
Cost $50+/mo (managed) $5/mo (bare VPS)

Basecamp, Hey.com, ONCE — all deployed with Kamal on bare servers.


Building deployment tools? Check out my developer tools or email spinov001@gmail.com.

Top comments (0)