In this article, we'll walk through the complete process of working with kamal in a server environment. Understanding ruby is essential for maintaining a reliable and performant infrastructure.
Pipeline Configuration
Performance benchmarks show that properly tuned kamal can handle significantly more concurrent connections than the default configuration. The key improvements come from adjusting worker processes and connection pooling.
# .github/workflows/deploy.yml
name: Deploy to Production
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: |
docker build -t myapp:latest .
- name: Deploy
run: |
ssh deploy@server 'cd /opt/myapp && docker compose pull && docker compose up -d'
Each line in the configuration serves a specific purpose. The comments explain the reasoning behind each setting, making it easier to customize for your specific use case.
Build and Test Setup
After applying these changes, monitor the server's resource usage for at least 24 hours to ensure stability. Tools like htop, iostat, and vmstat can provide real-time insights into system performance.
# Set up deployment pipeline
mkdir -p /opt/myapp
cd /opt/myapp
# Create deployment script
cat << 'EOF' > deploy.sh
#!/bin/bash
set -euo pipefail
echo "Deploying version: $1"
docker pull myapp:$1
docker compose down
DOCKER_TAG=$1 docker compose up -d
echo "Deployment complete"
EOF
chmod +x deploy.sh
Each line in the configuration serves a specific purpose. The comments explain the reasoning behind each setting, making it easier to customize for your specific use case.
Deployment Automation
If you encounter issues during setup, check the system logs first. Most problems can be diagnosed by examining the output of journalctl or the application-specific log files in /var/log/.
# .github/workflows/deploy.yml
name: Deploy to Production
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: |
docker build -t myapp:latest .
- name: Deploy
run: |
ssh deploy@server 'cd /opt/myapp && docker compose pull && docker compose up -d'
This configuration provides a good balance between performance and resource usage. For high-traffic scenarios, you may need to increase the limits further.
Environment Management
The ruby component plays a crucial role in the overall architecture. Understanding how it interacts with kamal will help you make better configuration decisions.
# Set up deployment pipeline
mkdir -p /opt/myapp
cd /opt/myapp
# Create deployment script
cat << 'EOF' > deploy.sh
#!/bin/bash
set -euo pipefail
echo "Deploying version: $1"
docker pull myapp:$1
docker compose down
DOCKER_TAG=$1 docker compose up -d
echo "Deployment complete"
EOF
chmod +x deploy.sh
These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.
- Review log files weekly for anomalies
- Monitor disk space usage and set up alerts
- Keep your system packages updated regularly
Next Steps
With kamal now set up and running, consider implementing monitoring to track performance metrics over time. Regularly review your configuration as your workload changes and scale resources accordingly.