Lately I’ve been playing with GCP and Firebase just for the sake of exploring the offerings that cloud providers other than AWS have. As I mentioned in a previous post, this site is hosted on Firebase for almost nothing, and I’m playing around with GCP features while using the free tier, and free trial credit. With the free tier alone, you get a lot of Google Cloud Functions executions, and plenty of Container Builder time before you have to pay anything. So for shits and giggles, I decided to make it so Google Assistant will deploy my site for me.

Note that this is not a full tutorial, and none of this is production ready. This is just the ramblings of someone who likes to play with GCP and Golang. If you really wanted to use this for important workloads, there are things to consider like security of the Firebase CI token.

Breakdown and Flow

It’s pretty simple when you break it down. Basically I have a custom IFTTT Applet that triggers a web hook. That web hook calls a Google Cloud Functions URL. When triggered, the Cloud Function will parse the request, and turn it into environment variables for a Container Builder build step. Container build then runs an image I built that reads those environment variables, runs Hugo, and deploys that to Firebase. Easy enough.

Deployment Flow

IFTTT Setup

IFTTT allows you to create an applet that is trigged by custom phrases said to Google Assistant. That phrase can then trigger a web hook for custom integrations. An example of what I have setup is below.

IFTTT Setup

You should be able to see now why I called out security above. For this simple personal project, I’m not too worried about giving IFTTT my Firebase CI token, but I wouldn’t do this for a company that I worked for. Roles would be the best way to handle this, but I haven’t yet figured out how to allow Firebase Hosting access from a GCP Role.

Google Cloud Functions Setup

I like writing Go code, so for this, I used Kelsey Hightower’s Golang shim. Following the http example provided in that repo, I created a quick and dirty bit of code that parses a JSON request, feeds that into environment variables for the Container Builder build step, and triggers a new build. The code for that can be found here.

Container Builder Setup

In the FirebaseDeployBot repo mentioned above, I created a docker folder that contains a Dockerfile and an entrypoint script. The Dockerfile creates an Alpine-based image that has Hugo and the Firebase CLI installed. The entrypoint script clones the site repo and submodules from GitHub, builds the Hugo site, and deploys to Firebase based on the environment variables passed to the container when it’s started.

Container Builder doesn’t really have anything setup, necessarily, but the GCP function will tell Container Builder to run a container from the image defined in the Dockerfile (which I put in Docker Hub), and set the environment variables that the script requires to build and deploy.

That’s It

Now when I post this page, all I do is hugo serve locally to verify it looks good, commit it to GitHub, and ask Google to build my site.

Assistant Building My Site

Today I took and passed the Docker Certified Associate exam and I wanted to write up my thoughts on it (mostly just to make me write something). The short version is that it’s harder than I expected and it is well thought out.

Background

I’ve been working with Docker professionally for just over two years. Most of this time has been spent maintaining Amazon ECS clusters. For a little while, I was helping support a Docker Swarm cluster pre-SwarmKit. Recently, I’ve been given an opportunity to work with Kubernetes. Most of these clusters have been part of a larger platform to support developers in a PaSS-like way so they can deploy their services with less friction. With this, I’ve become quite familiar with Docker and the paradigms that come with it.

At work, I’m expected to be somewhat of an expert in Docker and the surrounding technologies, so when the exam was announced, I figured it couldn’t hurt to try for it.

Thoughts on the Exam

As I mentioned at the top, the exam was tougher than I thought. I still did quite well, but before taking it, I was beginning to think I over-prepared. My advantage going in is that I have been working with it for a while. Several of the questions I did not know the answer to off the top of my head, but through the process of elimination, and having familiarity with other Docker tooling, I was often able to derive the answer.

Many of the questions were somewhat specific. I can’t give examples, but you are expected to know how to do a process, and what the process is doing — at least at a high level. There weren’t any questions that dove into how the network works at the Linux Kernel level, or anything that deep, but if it’s on the study guide, you should have an idea of how to do the thing, and what is happening when it does that thing.

Based on the study guide, I was worried that I would have to be fairly proficient in DTR and UCP. Although these were definitely topics on my version of the exam, it was not at the same ratio as what they have on the study guide. Don’t take this as fact, though. Your exam could be different questions than mine, so it’s possible someone will have a ton of questions on these two. But either way, once you learn the rest of the concepts in the study guide, DTR and UCP are pretty easy to get your head around.

Overall, I thought the exam was pretty well done, but it may not be for everyone. If you are using Docker to ship relatively simple apps on something like Amazon ECS, or just using it for your development work, then this cert is probably overkill.

Study Material

I used these two things.

Most of my studying was done with the top link (I started well before the Linux Academy course existed). Both were pretty good sources, but the one caution I have with using any video training is to make sure you still read the appropriate documentation, and try the stuff out yourself. Linux Academy hit almost everything that came up on my exam, but with the questions presented, I know just watching the videos and doing the labs would not have been enough for me to remember some of the specifics required by the questions.

Everything on the exam was called out on the study guide Docker put out (which DevOps Academy mirrors). Make sure you understand all of the concepts on the list before going into the exam. If you can speak to everything on there, and you can perform any of the processes they mention, you’ll probably be fine.

I’m not sure these notes will make sense to anyone else, but my notes are available on github.

Good luck, to anyone who decides to take the exam!

Before working on this project, I had a crappy site that I had been meaning to update for a couple years. It was built to satisfy the requirements of a class I was taking using a bloated bootstrap template, and it was hosted on a VPS that I was already paying for. Well, I finally got around to updating this site, and now I’m going to ramble about the tools I’m using to build it, and the hosting options that I explored to make it cost almost nothing.

Hugo and the HPSTR theme

Hugo Logo

To start, I’m a lazy person. My VPS isn’t a lot of work, but it’s work that I don’t really need to do anymore since the tooling for static sites is great, and static site hosting is easy. At one point, my VPS ran more than static website, but not anymore, so it’s not worth the upkeep.

For creating content like a blog, there are lots of good static site generators. There is even this site listing them, which is provided by a static site hosting company (makes sense). Since I’m a bit of a golang fanboy, and since the tool works well, I went with Hugo and the HPSTR Theme.

But this is just some background context. The hosting is really the point of my ramblings in this post.

Static Site Hosting

For a site that doesn’t get a lot of traffic, there are several options available now where you can host your site for free, or really cheaply. The tools talked about here are the ones I put on my list to explore, but I’m sure there are probably other cheap ways to achieve the same.

AWS

AWS S3 Logo

With Amazon Web Services (AWS), it’s really easy to use S3 and Route 53 for hosting a static site. If you want to get fancy, you can even add CloudFront as a CDN to make your website load even faster. It’s cheap, and to host this site, at the current size and rate of traffic, the calculator shows that it would be pennies each month, and under $0.10 a month if I add CF.

These fees assume that you are out of the Free Tier usage. If you ran your site for a year on AWS, you would probably get a good idea of what it will cost you later. My site gets almost no traffic, so know that your bill could be a bit higher.

I’ve been working in AWS for a couple of years now, and I’ve deployed static content using S3 before. I love not having to rack and wire servers anymore (yes I’ve racked servers), but the more I use AWS, the more it’s inconsistencies annoy me. Some services are better than others (S3 being a better one), but I like the idea of seeing what else is out there, and if the other cloud providers are any better.

GCP

Cloud Storage Logo.png

As I just mentioned, I wanted to check out other cloud providers because I get annoyed with AWS sometimes. Google Cloud Platform (GCP) has always interested me for some reason, so I used this as an excuse to play around with it. In my initial usage, I’m impressed. The UI is much prettier, and more user friendly, and so far the docs have been great. The always free tier is better than the AWS Offering for my needs, and the $300 credit to use in the first year is compelling. Hopefully GCP will keep impressing me as I continue to play around with it.

When you look at the docs for static site hosting on GCP, there is a red flag (almost literally) that sticks out right away - GCP does not natively support hosting over HTTPS. As they call out in the docs, you can use something like CloudFlare to secure your site, or you can use Firebase Hosting. I’m kind of a nut about securing everything, regardless of what it is. I also like the idea of simple management that’s all in one place. For these reasons, I added Firebase Hosting to the list of provides to look at.

Encrypt All the Things

Firebase

Firebase Hosting Logo

I had previously explored firebase for very simple projects, but never really their hosting. During my explorations of GCP I did learn that Firebase is basically a gateway drug to GCP, so that’s intriguing.

If you look at the pricing page, you get 1 GB of storage and 10 GB of traffic for Hosting in the free Spark Plan; that’s quite a bit for my static site needs. The documentation makes it look straight forward too.

There is a caveat with using Firebase. If you already have a GCP account on the email you are using for Firebase, it appears that have to use the pay-as-you-go plan. Still, it’s relatively inexpensive unless you get a lot of traffic.

Azure

Azure Web App Logo

For Azure, I didn’t explore this as much. This was one of the last ones on my list, and I found that GCP and Firebase would both give me free hosting (for my site anyways). Although Azure is still a really cheap competitor, I’m incredibly stingy. If I was already Azure, I would explore this option more. Here are the docs for more info.

The Winner is Firebase, For Now

At the time of writing, this site is hosted on Firebase. So far, I like it. In practice, the tooling was pretty easy to use (although a lot to install), and it meets my needs. Basically my workflow is what’s below. I do have some automation in there, but this is the gist of what happens.

hugo serve

# write stuff

hugo
firebase serve

# Grumble that my PowerShell text just turned yellow...

# make sure it looks good

firebase deploy

While testing, I started scraping some metadata and searching around a bit, and I was pretty happy to find that they are probably using NGINX to host static content, Firebase hosting supports HTTP2, and it gets an “A” on SSL Labs. As a side note, they’re using Let’s Encrypt as the certificate authority.

SSL Labs Results

I have two more sites to migrate off of this VPS, so I might explore using GCP and CloudFlare for one of them. For my wife’s site, I’m going to migrate it to Firebase, because it will be easy enough for her to do on her own before I get around to automating everything. I’ll stick with it for this site.

Update

Another free static site hosting option that didn’t cross my mind at the time is Github Pages. It looks pretty straight forward, and I know several people that are happily using it. Firebase ties in to a lot of the tooling I want to experiment with, so I’m going to stick with it for now.

I don’t plan to update this post for any of the other cheap or free ways to do this, but so many people I know are using Github, so I figured it deserved a quick mention.