This repository contains two applications (Go and Rails) that are deployed using Kamal. This guide will help you set up and deploy both applications.
- Docker installed and running
- Ruby 3.0+ installed (for Kamal gem)
- Access to the target server (SSH key configured)
- GitHub Container Registry (ghcr.io) access
- Git installed
- Install Kamal:
gem install kamal- Set up environment variables:
export KAMAL_REGISTRY_PASSWORD="your_github_token"For Rails application, additional variables are needed:
export RAILS_MASTER_KEY="your_rails_master_key"
export POSTGRES_PASSWORD="your_postgres_password"The Go application uses a simple deployment setup with the following configuration:
- Service name:
goapp - Registry: GitHub Container Registry (ghcr.io)
- No SSL configuration (development setup)
- Build and push the Docker image:
cd go
kamal build- Deploy the application:
kamal deploy- Check deployment status:
kamal statusThe Rails application has a more complex setup with:
- Service name:
rails-app - PostgreSQL database as an accessory service
- Registry: GitHub Container Registry (ghcr.io)
- No SSL configuration (development setup)
- First-time setup for PostgreSQL:
cd rails
kamal accessory boot db- Build and push the Docker image:
kamal build- Deploy the application:
kamal deploy- Check deployment status:
kamal statuskamal setup: Prepare servers for first deploykamal deploy: Deploy the applicationkamal rollback: Rollback to the previous versionkamal restart: Restart the applicationkamal logs: View application logskamal accessory reboot [name]: Restart an accessory servicekamal lock: Lock deploymentskamal unlock: Unlock deployments
- Go application:
go/config/deploy.yml - Rails application:
rails/config/deploy.yml
- Ubuntu 22.04 LTS (recommended)
- Docker installed
- Open ports:
- 80/443 for web traffic
- 5432 for PostgreSQL (Rails app only)
- SSH access
-
If deployment fails:
- Check server connectivity
- Verify environment variables are set
- Review logs with
kamal logs - Ensure Docker registry access is configured
-
Database issues (Rails):
- Check PostgreSQL container status
- Verify database credentials
- Check database logs
-
Container issues:
- Use
kamal app execto debug inside containers - Check Docker logs on the server
- Verify disk space and resource usage
- Use