DEV Community

Alex Spinov
Alex Spinov

Posted on

Kamal Has a Free API — Deploy Docker Apps to Any Server Without Kubernetes

TL;DR

Kamal (by Basecamp/37signals) deploys Docker containers to any server over SSH. No Kubernetes, no PaaS fees — just your app on bare metal or any VPS, with zero downtime deployments.

What Is Kamal?

Kamal makes deployment simple:

  • Zero downtime — blue-green deployments with Traefik
  • Any server — bare metal, Hetzner, DigitalOcean, AWS EC2
  • Docker-based — build and deploy containers
  • Multi-server — deploy to multiple servers at once
  • Accessories — manage databases, Redis, etc. alongside your app
  • SSL — automatic Let's Encrypt via Traefik
  • Free — MIT license, created by DHH/37signals

Quick Start

# Install
gem install kamal

# Initialize
kamal init

# Deploy!
kamal deploy
Enter fullscreen mode Exit fullscreen mode

Configuration

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

servers:
  web:
    hosts:
      - 1.2.3.4
      - 5.6.7.8
    labels:
      traefik.http.routers.my-app.rule: Host(`myapp.com`)

  worker:
    hosts:
      - 9.10.11.12
    cmd: node worker.js

registry:
  server: ghcr.io
  username: myuser
  password:
    - KAMAL_REGISTRY_PASSWORD

env:
  clear:
    NODE_ENV: production
    PORT: 3000
  secret:
    - DATABASE_URL
    - REDIS_URL
    - SECRET_KEY

traefik:
  options:
    publish:
      - "443:443"
    volume:
      - "/letsencrypt:/letsencrypt"
  args:
    entryPoints.websecure.address: ":443"
    certificatesResolvers.letsencrypt.acme.email: "admin@myapp.com"
    certificatesResolvers.letsencrypt.acme.storage: "/letsencrypt/acme.json"
    certificatesResolvers.letsencrypt.acme.httpChallenge.entryPoint: "web"

accessories:
  db:
    image: postgres:16
    host: 1.2.3.4
    port: 5432
    env:
      secret:
        - POSTGRES_PASSWORD
    directories:
      - data:/var/lib/postgresql/data

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

Deploy Commands

# First deploy (sets up everything)
kamal setup

# Subsequent deploys (zero downtime)
kamal deploy

# Deploy to specific servers
kamal deploy --hosts=1.2.3.4

# Rollback to previous version
kamal rollback

# View logs
kamal app logs

# Open console
kamal app exec -i bash

# Check status
kamal details
Enter fullscreen mode Exit fullscreen mode

Environment Secrets

# .kamal/secrets
KAMAL_REGISTRY_PASSWORD=ghp_xxx
DATABASE_URL=postgresql://...
REDIS_URL=redis://...
SECRET_KEY=supersecret
Enter fullscreen mode Exit fullscreen mode

Kamal vs Alternatives

Feature Kamal Kubernetes Coolify Dokku
Complexity Low Very High Low Low
Zero downtime Yes Yes Yes Plugin
Multi-server Yes Yes Yes No
SSL Auto (Traefik) Cert-manager Auto Auto
Learning curve 30 min Weeks 1 hour 1 hour
Infrastructure Any SSH server K8s cluster Any VPS Any VPS
Created by 37signals Google Community Community
Min resources 1 GB RAM 4+ GB RAM 2 GB RAM 1 GB RAM

Cost Comparison

Setup Monthly Cost
Vercel Pro $20/member
Railway $5-20+
Heroku $25+
Kamal + Hetzner VPS $4-7
Kamal + DigitalOcean $6-12

Resources


Deploying scraping services? My Apify tools run in the cloud, but for self-hosted scrapers, Kamal deploys them with zero downtime. Questions? Email spinov001@gmail.com

Top comments (0)