Pieter Kraamwinkel

Blog

A new website

Posted on

I really like programming as it is a hobby where you are never done learning new things. New languages and frameworks keep getting made, and new methodologies emerge from them. I learned the most from people blogging about what they had learned, and I felt a little itch to start doing that myself as well. In this first article - Yay! - I will explain how I got this blog up and running.

First steps

I already had a little website I did little with on a shared hosting with only one domain name. I wanted to hook up multiple domain names to this same shared hosting, but my hosting packet did not allow that. To solve this, I decided to hire a VPS instead and do the configuration myself.

At work I head some colleagues that where working on another project talking about Docker and how much it eased their process of deploying their applications.

That same evening, I was chatting with some other developers and mentioned that I just hired a VPS and was looking for a way to set everything up. The first response was if I already performed a sudo apt-get install docker docker-compose. That was convincing.

For those who have never heard of Docker before: Docker allows you to create containers in which you can run your applications. These containers are isolated from each other and from the rest of you system, unless you explicitly specify channels between them. This makes managing your applications a lot easier.

In the end I ended up with four docker containers: one container that builds the application behind the blog, one for Traefik, one for the blog and one for Elasticsearch.

I do not want to go into too much detail, as that might make this article a bit too boring. I will instead shortly describe what each container is currently doing.

Traefik

In order to allow anyone on this blog, I needed a reverse proxy. In the same chat conversation docker was mentioned, a few reverse proxies were named. Among them was Traefik, which integrates really well with docker. I didn't want to spend to much time on configuring a reverse proxy, so I decided to go with Traefik.

Traefik is easy to use once it is set up, but the set up itself was quite a challenge. Luckily I got a lot of help from Maarten Zuidhoorn who was also one of the people who advised me to use Traefik.

It quickly paid of after setting up one domain, as setting up the others was as simple as adding them to a list in the docker configuration file.

The blog itself

The backend is currently written in NodeJS with Express.

For the markup of the blog articles, I was looking for some framework that could handle that for me.

Unfortunately I was unable to find anything that allowed me to create code blocks in which I can specify the programming language used, so I wrote a little text parser for that instead. It currently only supports paragraphs, headings and code blocks. For now that is enough and if I need more later I can extend it easily.

The syntax coloring is done with highlight.js, which I choose because it works server side and keeps the HTML as clean as possible.

I wanted to keep the front end as basic as possible. Blogs do not need JavaScript in my opinion, so I decided to stay away from it completely. Currently only HTML and CSS is used.

Originally I wanted to write this blog in Haskell, but my knowledge is currently too limited for that. I hope I get to rewrite it in Haskell in the near future.

Elasticsearch

The blog articles resemble documents that have no direct relation between each other, and as such I wanted to save them in a NoSQL database. I choose for Elasticsearch for its search capabilities and because I already used a previous version of Elasticsearch in my internship a few years ago and wanted to try it out again.

Overkill?

I already got some comments during the development of this blog that the technologies used might be too advanced for what I want to achieve.

It's true that for just blogging this is a bit too much. Not just the technologies themselves, but also making your own blog software.

Elasticsearch and Traefik are not needed for a little blog on a single server. There are other technologies that make it easy to have your own website and blog in no time.

But even if I decided to go with those other technologies, it still would be overkill to do all that myself. I could have simply upgraded my packet to allow me to hook up other domains to my shared hosting and use some blogging software written in PHP.

To be honest, the only reason I could give you is that I was curious. Yep, that's it. And I am happy I was curious, because it was a lot of fun building this site!

Next steps

The first two things I want to add are comments and a contact page.

Another thing I want to do, as I already mentioned, is rewriting the blog in Haskell. There is not much code, and I already tried to write the code in an as functional way as possible to make the process easier. The current code is a mess I do not want to show anyone, but after the rewrite I will make the Haskell code public.

That's all for now

Thank you for reading this wall of text, and I hope to see you next time!