This blog post is a quickie where I document how I deployed CovidNearMe onto Google Cloud Platform or GCP using HatchBox.io. I need to start by giving a huge shout out to Tony Carnevale from Google who went above and beyond in providing outstanding support.
Here are the stages.
Stage 1: Create a Cluster
Note: Even a single machine is considered a cluster.
- Go to HatchBox.io
- Login with your account.
- Click on Clusters and define a New Cluster.
- Name the cluster GCP Covid Near Me (or that's what I did).
- Select Somewhere Else as the hosting provider.
- Select the Everything on a Single Server option.
- If you are using the GCP Cloud SQL (postgresql) and GCP Redis then remove these options from the Roles list.
- Enter the IP address under public ip.
- Set the private IP to 127.0.0.
- There appears to be a bug where you can't provision the server unless a local redis installation is selected so add it back.
- Click provision the server and you will be given an SSH command to run as root on the box. You SSH in, do a sudo su, execute the command and exit out
- You click Test / Provision (I forget which) and your server will be flawlessly setup.
Stage 2: Create an App on the Cluster
- Click on Apps.
- Click on Create a New App.
- Choose the cluster from the drop down list.
- Click on your git repo host.
- Set the name of your application (I like to include the name of the cluster with the app name since this app is already deployed to digital ocean).
- Enter the name of the repo (easily find this from .git/config in your Rails root directory).
- Set external host for the database if you are using Google's Cloud SQL. This means that you need to define a postgres configuration url. The format for this url is this: postgresql://user:email@example.com/database. You simply need to replace user with your username, password with your password, databasehost.com with your database server and database with the name of the database.
Define your Rails Master Key right away so you don't screw this up and have to ask Chris Oliver for support (and thus sound like an idiot). Your rails Master Key can be found in and copied with: cat config/master.key pbcopy (if you are on OSX)
- Do an initial deploy. This will give you an HTTP only application. You can't have HTTPS until you have a domain assigned to the server so you have to start with HTTP.
- You can then define SSL. I'd like to illustrate those steps but I didn't write them down well enough so that will have to be a future blog post.
- Make sure that you have SSH on the GCP cluster open to the IP address for the Hatchbox deployment engine. This ip address, today, March 24, 2020, is 22.214.171.124.