Setting up my Server

This is the third version of my blog. It is a Ruby on Rails app, running on a DigitalOcean Droplet. In this post I will describe how and why I setup my own server.

Why

Originally I hosted my blog on wordpress.com. It was nice, but I wanted to use my blog to learn, and design. And I knew that I didn't write often, and so I wanted to lower my costs.

And so I moved it to GitHub Pages and used Jekyll (like GitHub Pages do). It was nice and performant.
But I never was really happy with it. Mainly, because of drafts: Jekyll has a drafts feature, but the only way to sync a draft between devices was by Git. And I didn't want all my drafts to by in the open. So I used other editors (mostly notes apps) to sync my drafts.
Then I learned about the IndieWeb. But because Jekyll precompiles everything, I couldn't implement most of it. Neither anything else dynamic.

Last year I started to learn Ruby and Ruby on Rails. Yes, it was because of Hotwire. And so because I was looking for a project for Rails and wanted to implement some IndieWeb stuff, I thought to myself: I could write my own CMS!
So I did.

Domain Provider

I already had this domain. All I had to do was to point it to my new server. For my domain provider I use Hover. Yes I'm listening to Podcast, why are you asking?

The  hosting options

There are a lot of hosting providers. For my Rails blog there where two relevant groups:
  • Virtual Private Server Hosts
  • App Platforms (PaaS)
The PaaS manage the server for you, but are more expensive.

On PaaS you usually also can't store permanent files on the local disc. You have to use a cloud file storage, like AWS S3. I didn't want to have to manage another service. But every tutorial did discourage the use of the :local Active Storage service. But then I found through GoRails' Deploy tutorial Capistrano. And it does have a method to link files and directories! This will only be my blog, so there will never be a high upload load.
So I did chose a virtual private server on DigitalOcean. If the local files upload didn't work out, then I could still move them to a cloud storage. There would only be my files after all.

How

The source code is not that relevant. You can find it on Github. But let me say one thing: I always didn't want to do backend development or manage a backend, because of the fear of miss configuration or implementing something in an unsave way. Rails does handle many of them (SQL injections for example), and many other security problems are documented.

Mostly my blog is a standard Rails app. I want to learn Rails after all. But I didn't need the full capabilities of Devise: There would only be one user/author: me. Which allowed me to move my credentials into Rails credentials.yml.enc. Which is a standard way for Rails apps to store encrypted sensitive information. Even in a public repository! Matured frameworks are awesome!

DigitalOcean has a special Rails Droplet. I tried it, but didn't know how it worked. If you are just starting, I would recommend to use a standard Linux Server and follow a tutorial instead.
For the actual deployment I used GoRails' Deploy awesome tutorial. It worked, with the exception of when I wanted to install Let's Encrypt. There I used certbot and it's tutorial from EFF. You need snapd installed.

Many hosting providers have a referral program, where the new user gets a expiring free credit (for DigitalOcean it is $100 for 60 days). Use them! They allow you to experiment with new servers and setups, until you find the one with which you are comfortable. Something didn't work, and you can't find out what? Make a new server and start anew! And then throw the old one away!

DigitalOcean also has a web-based console, to login into your server. I used it up until actually deploying my blog. No SSH certificates to manage, just clicking on a link.

Problems with pgcrypto

The first deployment with the ActiveJob backend Good Job, did fail. It couldn't activate the Postgresql extension pgcrypto.
How to activate it wasn't documented, anywhere (that I could find). But there was this answer from Stack overflow (this one also explains it well).

Pay attention to the description!
First connect with PSQL (or PgAdmin) to your DB. I missed that at first!

su - dbuser
psql mydb
And then:
CREATE EXTENSION IF NOT EXISTS pgcrypto;
And now I could deploy!

Conclusions

Running a server is not the scary thing. It is kind of nice! You just have to check your server for outdated packages once in a while.

There is also something about owning your own server! The idea behind the IndieWeb: This is my page! My corner of the web, to decide to do as I please. I own it.