Introduction
Deploying an application on your own machine is never a simple task. Nonetheless, I found using Kamal to deploy apps on my own VM is pretty easy. It allows me to run multiple apps on a very basic and cheap VM with Docker.
Though I really enjoy what Kamal brings to me, I want to write a tutorial for it. However, while I was writing the article about Kamal, I noticed I was always stuck at some points and thought: how can a beginner know how to rent a VM if they have never done that before?
That's why I want to write this article. There are some preparations for Kamal's deployment which are very trivial and simple, but they could intimidate software newbies. In this article, I'm going to introduce how to do the following three things:
- Rent a virtual machine
- Buy a domain name
- Set up a Dockerfile
These are prerequisites of deployment of Kamal (or even any deployment nowadays). To be honest, these three tasks are "boring" part of web app development. However, we will have a little bit of help from modern AI in each step. I hope that makes them no longer dreadful, and you may even enjoy the process 😎
Rent a Virtual Machine (VM)
Since our goal is to deploy things on your own VM, you have to have a VM first. In fact, you can get a VM on cloud providers' websites easily. You can pick any one from those big cloud providers:
- Amazon AWS EC2
- Google GCP Compute Engine
- Microsoft Azure Virtual Machine
- DigitalOcean Droplet
- Akamai Cloud Compute
I completely don't understand why their names are so random, but they all mean the same thing---their VM service. There are also many smaller providers. If you want, you can ask AI
What VPS options do I have in my region? (VPS, Virtual Private Server)
-
What cloud providers can I choose to rent a VM?
and you should get a suggestion list.
I eventually chose DigitalOcean Droplet. I live in Toronto, and one of their data centers is here. Although I will only show how to enable and connect to a VM on Digital Ocean, the same workflow can be easily applied to all other cloud providers.
Create a new VM
First, go to DigitalOcean. Sign up an account if you don't have one and then log in. Go to the "Droplets" page and click "Create Droplet". You will see many different settings you can configure for the new VM.
For the OS, if you don't have any clue which to install, I suggest choosing Ubuntu or Debian. For the specification of the machine, since we are just practicing and learning, we chose the minimum option. At this moment in September 2025, I get a machine with
- 1 CPU
- 1 GB RAM
- 25 GB SSD Disk
- 1TB network transfer It costs only $6/month, which is cheaper than Starbucks coffee ☕.
(A DigitalOcean exclusive feature) A good part of Droplet creation is that you can create a SSH key to log in. You can also choose Password to set a root password and set the SSH key authentication later. Up to you.
After the droplet is created successfully. You should see your new VM appear in the Droplets list.
Copy its IP address and use ssh
to connect to it.
ssh root@IP_OF_THE_DROPLET
# or if you use a different ssh key
ssh -i ~/.ssh/you_ssh_private_key root@IP_OF_THE_VM
If it connects successfully, then you're good.
Add ssh-key to log in
(If you already added the ssh-key, you can skip this section.) The step is to add ssh-key to log in the VM. Why don't we just stick to the password? The answer is that it will make the deployment easier in the future, and it's also more secure.
You can ask AI if you really don't have a clue how to do that:
How to generate a ssh-key pair and use it to log into my VM?
However, the workflow should be similar like below:
# generate ssh key pair in ~/.ssh, it will create
# 1. Private key: ~/.ssh/id_ed25519
# 2. Public key: ~/.ssh/id_ed25519.pub
ssh-keygen -t ed25519 -C "your_email@example.com"
# show the content of the public key, and then copy it
cat ~/.ssh/id_ed25519.pub
# login to your VM with your password
ssh root@IP_OF_THE_VM
# edit ~/.ssh/authorized_keys
# paste the public key's content in this file
vim ~/.ssh/authorized_keys
At this point, you should be able to login the VM directly like below and without entering password
ssh root@IP_OF_THE_VM
Buy a domain
You need a domain name to direct to your VM, so your users can use https://your-domain.com
instead of a meaningless IP, like 123.123.0.1. You can get a very cheap domain from any domain name provider.
Again, you can ask AI to give you a list of providers if you want. Especially you want a special Top-level domain (the last part of the domain name, like .com, .net), as far as I know, some top-level domains are only sold on specific sites.
You just need to come up with a good domain name you'd like, and search it on those providers' websites. Below is the example that I tried to search get-food-in-gta
, and it gave me a long list of available domain names, each one also has a rent price on it
It is just like online shopping (but for geeks...). Whichever creative domain name you get, you need to configure the DNS A record to point to your VM's IP. (Please note that you MUST use IPv4, since IPv6 is not supported by Kamal yet at the moment when I write this article).
Find the entrance to the DNS management page for the domain name you just bought:
Add a new A record. If there is an existing A record, you can delete it.
After the A record is added, create a CNAME record for www. It usually points to the same place, for example: www.google.com and google.com should be the same.
DNS needs a period of time up to 1 day to be activated. Be patient, you can use ssh
to connect to the VM by the domain name to check if the settings are active.
ssh root@your-domain.com
Once you connect to the VM by the command above, the VM is all set.
Set up the Dockerfile
I think this is the most interesting part in this AI era, and why I think AI really boost productivity. In the past: Yes, I knew Docker. Yes, I knew Linux. And I know every detail of my application. However, writing a Dockerfile from scratch isn't a joyful task. Recall how you set up your new computer; writing the Dockerfile is exactly like that process.
The situation has changed now. Since a Dockerfile follows a strict format, which is a very reproducible pattern for LLM. AI can generate a well-structured, well-written, good-practice Dockerfile for you if you provide it with the whole project as the context.
Below, I created a small web app by using Nuxt and tried to use Gemini CLI to create a suitable Dockerfile for it. Again, you can use any AI assisting tools: Claude Code, Copilot, Cursor, etc. I just want to present the idea.
Install Gemini CLI
First, go to https://github.com/google-gemini/gemini-cli and follow the instructions to install Gemini CLI on your machine. Then open your project with your editor. If you happen to use VSCode, you can also install the Gemini CLI Companion extension, which can let Gemini CLI know which files are opened in VSCode.
Open the terminal in VSCode and start Gemini CLI. Although we can start telling the Gemini to generate the juicy Dockerfile for us right away, it will be better if you execute the command /init
first. /init
will analyze the whole project and create a Gemini.md
in your project, which will help Gemini CLI have a basic context of your project.
!gemini cli ext](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50ow23illxauabsgh5jn.png)
When the next step is just to tell Gemini CLI to generate the Dockerfile, there are infinite options there:
Generate a Dockerfile for this project
Generate a Dockerfile for this Nuxt project
Generate a Dockerfile for this Nuxt project. Use Node 22 Alpine as the base image
- ... You can be more specific and detailed as you would like.
Okay...I admit I oversimplify this process (especially the Dockerfile part) and make AI seem like black magic. A big project which couples with many services like database, cache, storage, etc., may not be as easy as it is demonstrated above. However, I guarantee it will give you a very nice template as the entry point.
Conclusion
Maintaining Linux servers, DNS records and Dockerfile are all skills that deserve thorough studying and let you master them. AI makes the process faster; however, it doesn't mean that we don't need to learn them anymore. Because the current AI doesn't truly "automate" those things, it can still contain many mistakes in it. It just makes them easier to start with.
On the other hand, these things are just the foundation, the starting point of the goal. Our final goal is to deploy our applications, so I think getting the results by AI first is acceptable.😃
Top comments (0)