Automated deployment of Hugo with Vultr VPS and Github Actions - Part 1

Automated deployment of Hugo with Vultr VPS and Github Actions - Part 1

In this series we’re going to get our hugo blog off the ground and deployed to a vultr VPS.

We’ll be using the core concepts of infrastructure as code to ensure that we can track all changes to both our infrastructure (docker) as well as our blog and automate the entire process so that we can update our blog whenever we make a git commit.

 

The stack

First lets take a look at our tech stack and go over the reasoning for making these choices and what each piece does for us.

VPS - Vultr

This will be used to host our website and docker containers.

There are numerous VPS (Virtual Private Server) providers that we could choose to handle the server workload. I went with Vultr because they are relatively cheap, have a data center in the APAC region and are usually well regarded.

Feel free to sign up using my referal code if you dont already have a VPS.

Some other options:

  • Any of the cloud providers (Azure, AWS, GCP)
  • Digital Ocean
  • Linode

 

DNS - Google Domains

This will be used to manage our domain name and DNS records.

Google Domains offers a number of different TLDs (top level domains) that you can choose from, but they also provide 1x free proxy email address that you can use with the domain to forward to a secondary address. This is great when you dont want to also pay for a mail provider.

In addition to that they also have good DNS record management tools and allow setting up synthetic records to redirect things.

 

Application/Reverse Proxy - Traefik

This will be our traefik (pun intented) controller. It will make sure users are sent to the correct place.

Traefik is a reverse proxy or application proxy, it acts as the middle-man between the outside web and your VPS. It will ensure that all our sites have a HTTPS certificate, ensure that anytime a user accesses a certain url they’re sent to the correct docker container and provide some monitor/metrics.

Traefik is great when you’re working with docker as it can automatically detect our running containers and we can even configure our container directly just by using environment variables in our Dockerfile.

Some other options:

  • Consul (HashiCorp)
  • NGINX
  • HAProxy

 

SSL Certificate - Lets Encrypt

We need to ensure our blog is secured with HTTPS by default.

Gone are the days of manually requesting/renewing/installing certificates, let’s encrypt with the ACME protocol ensure that we always have an SSL certificate and that we never forget to renew it.

There is nothing else like it.

 

Web Server - NGINX

This will host our built static files from hugo as well as provide appropriate Cache-Control and any other heads we need to set.

Some other options:

  • Caddy

 

Infrastructure - Docker

We need a way to ensure our infrastructure is defined in code, and what better way to do that then with Docker.

Docker allows us to define a docker-compose.yml file which define multiple different services.

Some other options:

  • Kubernetes

 

Source Control and Automation Pipeline - Github

We need to store our code somewhere right?

Github is fairly ubiqitous when it comes to managing your code. And now that we can use Github Actions and host more private repositories its a great choice.

Some other options:

  • Azure DevOps
  • Bitbucket

 

Blogging Platform - Hugo

This will be the platform we use to actually write our blog!

Hugo is a great SSG (Static Site Generator) written in GO, so its nice and fast albeit can be a little steep learning curve. We can write our posts in markdown, get a nice theme and hey presto! We have a nice looking blog. It also handles SEO out of the box and we can also do some cool things such as running purgeCSS so that we can get an excellent Google Lighthouse score.

Some other options:

  • Jekyll
  • Ghost
  • WordPress

 


 

Okay…that was a lot, go and take a quick 🚶‍♀️ and come back for Part 2!