Bootstrap the Virtual Machine
Goal
The goal of this post is to setup the virtual machine we created in Baby's First Google Compute Instance with everything we need to deploy our Rails app using Kamal.
Steps
First, we should still have Secure Shell connecting us to our VM, which we covered in the previous post, Locking Your Virtual Machine's Front Door.
We need to refresh the package list. The package list is like a catalog that tells your system what software is available to install and what versions exist in the repositories (software sources). When you refresh it with apt update, your system downloads the latest version of this catalog to know about new or updated packages that are available.
The command sudo apt update
is like sending building inspectors to survey a construction site they haven't visited in a while. They check for what new materials and building codes have been released since their last visit. But they're just updating their records, not actually installing anything yet.
Run:
sudo apt update
Next we will update the installed packages. This one will take a few minutes to complete.
The command sudo apt upgrade
is like bringing the construction crews in with all the new materials and updated blueprints. They'll replace outdated components with newer versions. The "-y" flag is like pre-signing all the work orders, telling them to go ahead with all recommended upgrades without asking for approval at each step.
Run:
sudo apt upgrade -y
Now we install docker
, curl
, and git
on our new VM. These package installations are like calling in specialized contractors to install specific new systems. Each one adds new functionality to your home.
Docker allows us to run containers on the VM. cURL
is a command line tool that allows us to transfer data to and from other servers. git
is a version control tool.
Run:
sudo apt install -y docker.io curl git
Finally we need to add our user the Docker group so that we can run Docker commands without sudo
. It is like giving yourself a master key to the security system, so you don't need to call the building supervisor (sudo) every time you want to adjust the settings.
sudo usermod -a -G docker <username>
In my case, I run sudo usermod -a -G docker jesse
.
Run exit
to end the SSH
connection.
jesse@instance-1:~$ sudo usermod -a -G docker jesse
jesse@instance-1:~$ exit
logout
Connection to 34.58.127.13 closed.
Conclusion
We've now done everything necessary to prepare our VM for our Rails application and Kamal. Now, it's time to make our Rails application in our next post, Hello World Rails Speed Run.
Member discussion