Deploying to AmericanCloud with Kamal-Deploy

DRAFT

David Heinemeier Hansson (DHH) advocates for "The Cloud Exit"  to escape high costs and vendor lock-in. Big tech companies want developers to believe that running their own servers is complex and risky, but this is far from the truth. Basecamp has been vocal about this issue and has developed Kamal, a tool that simplifies deploying containers to any server.

This article will follow up on the Intro to Kamal Video and provide specific steps needed for deploying to AmericanCloud.

Create your AmericanCloud Account


They are a cost-effective platform that is 50 - 70% cheaper than the big cloud providers.

Create a New Server


Let's get you set up on a minimal server that I'm using to host several blogs just like this one.  For simplicity, we'll use the default network and assign a Public IP address.  

I'm choosing the standard server type, Ubuntu (Noble) with 1 CPU, 2GB RAM, and 25GB storage. This will cost $0.03/hour or about $21 a month.

Create a new SSH key & start the instance!

Create New Instance


Configure SSH and Security Settings


Before we do anything we need to get your new instance connected to the internet.  We will be adding a firewall and port forwarding rule for 443.

You should also lock down port 22 to your IP address.

Network


Move your SSH key to a secure location:

mv ~/Downloads/american.txt ~/.ssh/american_id_rsa
chmod 600 ~/.ssh/american_id_rsa

Connect to your instance:

ssh -i ~/.ssh/american_id_rsa cloud@172.000.000.000

Software Update and Security


After succefully connecting to your instance let's run some updates and disable password authenication.

sudo vim /etc/ssh/sshd_config
sudo vim /etc/ssh/sshd_config.d/50-cloud-init.conf
PasswordAuthentication no
sudo service ssh restart

Install and Set Up Kamal

Update deploy.yml with your server IP address, domain name and I perfer to specifiy my ssh key.

servers:
  web:
    - 172.000.000.000
proxy:
  ssl: true
  hosts:
  - jonathanspooner.com
  - www.jonathanspooner.com
  app_port: 3000
ssh:
  user: cloud
  keys_only: true
  keys: [ "~/.ssh/american_id_rsa" ]

Ok it's time to run "kamal setup".  On first run you'll likely get an error.  You'll need to add run the following command to add docker to the correct group.

sudo groupadd docker 
sudo usermod -aG docker $USER

Run "kamal setup" again. 

Configure Cloudflare for Security and Performance


  • Add your public IP address to Cloudflare and enable proxying.
  • Configure SSL termination.
  • Enable Full SSL encryption mode.

Final Thoughts


By following these steps, you can efficiently deploy applications on AmericanCloud while keeping costs low.