Loading...
Loading...
Deploy containerized applications (especially Rails) to VPS using Kamal 2. Covers deploy.yml configuration, accessories (PostgreSQL, Redis, Sidekiq), SSL/TLS, secrets management, CI/CD with GitHub Actions, database backups, server hardening, debugging, and scaling. Use when setting up Kamal, configuring deployments, troubleshooting deploy issues, or managing production infrastructure with Kamal.
npx skill4agent add faqndo97/ai-skills kamal-deployment# Install
gem install kamal
# Initialize in your project
kamal init
# Creates: config/deploy.yml, .kamal/secrets, .kamal/hooks/
# First deploy (bootstraps servers + deploys)
kamal setup
# Subsequent deploys
kamal deploywebjobkamalkamal initconfig/deploy.yml.kamal/secrets/upconfig.assume_ssl = trueconfig.force_ssl = trueproduction.rb/upconfig.host_authorization = { exclude: ->(request) { request.path == "/up" } }kamal setupkamal deploy # Full deploy (build + push + deploy)
kamal deploy --skip-push # Deploy existing image from registry
kamal deploy --version=VERSION # Deploy specific versionkamal accessory boot all # Boot all accessories
kamal accessory boot postgres # Boot specific accessory
kamal accessory reboot redis # Reboot an accessory
kamal accessory remove postgres # Remove an accessory
kamal accessory details postgres
kamal accessory logs postgres# Logs
kamal app logs # Application logs
kamal app logs -f # Follow logs
kamal app logs -r web # Logs for specific role
kamal proxy logs # Proxy logs
# Console access
kamal app exec -i 'bin/rails console'
kamal app exec -i --reuse bash # Shell into running container
kamal app exec --primary "bin/rails about"
# Rollback
kamal app containers # List available versions
kamal rollback [VERSION] # Rollback to version
# Redeploy (skip bootstrap, proxy setup, pruning, registry login)
kamal redeploy
# Locks
kamal lock status # Check deploy lock
kamal lock acquire -m "reason" # Prevent deploys
kamal lock release # Allow deploys again
# Server management
kamal server bootstrap # Bootstrap servers with Docker
kamal details # Show details about all containers
kamal audit # Show audit log from servers
kamal prune # Prune old images and containers
kamal config # Show combined config (includes secrets!)
kamal docs [SECTION] # Show Kamal configuration docs
# Cleanup
kamal remove # Remove everything from servers| Flag | Description |
|---|---|
| Detailed logging |
| Minimal logging |
| Run against specific app version |
| Primary host only |
| Comma-separated hosts (supports wildcards) |
| Comma-separated roles (supports wildcards) |
| Deployment destination |
| Skip hook execution |
# Run migrations via entrypoint (recommended)
# bin/docker-entrypoint handles db:prepare automatically
# Or via pre-deploy hook
kamal app exec -p -q -d $KAMAL_DESTINATION --version $KAMAL_VERSION "rails db:migrate"
# Database backup (with S3 backup accessory)
kamal accessory exec s3_backup "sh backup.sh"
kamal accessory exec s3_backup "sh restore.sh".kamal/hooks/docker-setuppre-connectpre-buildpre-deploypost-deploypre-app-bootpost-app-bootpre-proxy-rebootpost-proxy-rebootkamal upgrade # In-place upgrade from Kamal 1 to 2
kamal upgrade --rolling # Zero-downtime upgrade
kamal downgrade # Reverse if neededkamalconfig.assume_ssl = trueproduction.rb/etc/resolv.confdeploy_timeoutasset_pathconfig/deploy.ymlconfig.reload_routes = falseforward_headers: true