Simple Cheap Hosting

Everyone wants a presence on the web - and no one wants to pay a lot. All kinds of businesses, from your local butcher to one of your many local conglomerates, all exist on the cloud during this day and age. Yet, we as individuals normally only exist within social media platforms. Within these platforms we are limited by the rules and regulations of the dreaded terms of service - which I doubt most of you have read.

When a good friend of mine explained to me how he set up and hosted his site almost free of charge through simple static site hosting on AWS I was intrigued. No longer would I need to put up with trying to hack through wordpress and a full content management system for simply writing out basic articles. I could simply write up an article with basic markdown and publish it out with a full simplistic CI/CD pipeline - all while allowing me to start playing around with a cloud provider I have not had a lot of exposure to. The only difference was that instead of AWS I chose the Google Cloud Platform.

Now let’s get to everything I worked through to get this up and running with only minimal fuss.

Domain Name Hosting

So this is where I ran into some issues. Prefixed domain names verses root domain names and why are these things looking correct. Take a deep breath and go read about CNAME records. Oh is everyone having fun now? Oh and guess what - you can create an infinite unresolvable loop. I wish we were smarter than that but infinite loops will always be an issue within development and technology.

www.pushtothe.cloud CNAME c.storage.googleapis.com

Oh yea make sure you have www in your bucket name. Yea don’t say I didn’t warn you. I had issues where I had 2 buckets pointing back and forth and a root redirect doesn’t really work that well and gets really confusing. Mostly because you can have a CNAME record on a root. If you have a redirect from the root to the www then to the CNAME for google cloud storage - well things get confusing.

Anyways google does have a good detail on getting this set up. Just beware of the CNAME mess as I stated above. You get into a circle that prevents things from showing up unless you duplicate the files in both of your buckets. No one wants to deal with that.

Google Cloud Build

Install Cloud SDK

Install the Cloud SDK from the Google Cloud platform. It’s as easy as opening up a powershell window in administrator mode and running the following:

(New-Object Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe")
& $env:Temp\GoogleCloudSDKInstaller.exe

Hugo Cloud Build Tutorial

Now let’s go and follow the actual tutorial for building in the cloud from Google with Hugo.

gcloud builds submit . --config=cloudbuild.yaml

Output

Step #0: Pulling image: gcr.io/pushtothecloud/hugo
Step #0: Using default tag: latest
Step #0: Error response from daemon: manifest for gcr.io/pushtothecloud/hugo:latest not found

Oh wait we need to actually upload the hugo container to be able to build in the cloud. Let’s actually get the cloud builds community repo and look at the hugo build. Go a git clone on this repo and then switch to that directory. Now you’ll be able to actually do a clou dbuild of the docker file that you will use for cloud builds.

gcloud builds submit . --config=cloudbuild.yaml

I know it looks exactly the same as what we already did - doesn’t it? Well onto more important things now. Let’s see if our own cloud build actually works now. Switch back into your hugo site directory and fire off your cloud build.

Wait did I just did a cloud build? Why yes I did. Feels fantastic. Also every time you do a push you will now get a new build automatically deployed out to your site.