In the spirit of dogfooding I got my blog running on Giant Swarm, first I tried Ghost, then moved to Wordpress.
My goal in this article was to do that without relying on any deep Docker or Giant Swarm knowledge. Learn how to do this yourself.
My Twitter profile reads “developer whisperer” and that is always my answer to whether I am a developer or not. I’m not, I just get along with them, understand them, and love seeing them get things done. I try to bridge the gap between MBA types and developers. In the end, I’m just one of the many tiny wheels building a company fully focussed on helping developers succeed.
Our infrastructure is built for developers to run microservice architectures on, but there are a lot of simple tools that are bound to run on Giant Swarm and one of the first for many of us, even in times of Medium, would be a blog. I’ve been blogging since 2001 and have thousands of posts … admittedly a lot from the early days. I ran on LiveJournal, Typepad, Wordpress.org, Wordpress.com, Tumblr, and a few others. Yes, I love to move my blog. And with The Grid coming around soon, I am looking forward to integrating that into it.
On to our documentation. Yes, I am trying to take the route I presume a novice would take and am trying to discard any pre-existing knowledge I have about Giant Swarm or Docker. How can we say it’s “simple” otherwise.
Interlude: On my second company, I had to be the sysadmin for some time and pretty quickly learned that Windows PCs cost me a few hours a month while Macs use up a few hours a year. Hence, I required everyone to have a Mac or Linux, in which case they know what they do anyway. The rule remains in place. Hence, we are doing this on OSX.
The first steps are quickly done. Getting homebrew installed and saying hi to the swarm is easy. Pretty soon I am logged in to my account, forcing myself to try the helloworld. A big discussion ensued with Matthias about its usefulness. In the end I had to admit that me being somebody that had seen lots of swarm.json files, I might be biased and it does actually provide a good first step to get you started. Matthias won. (Note: We now have a completely revamped Docs with an updated annotated hello world example). It’s running, it works. I am a tidy person, so:
$ swarm delete helloworld
What next? I went on to the second part of our Getting Started Guide (which again is now revamped and called “Your first application – in your language”) but there, my impatience won. Who needs to try out stuff locally (good idea btw ;)) and I don’t want a current weather app. Admittedly, to learn how containers play together, that again is good. I see a trend here. :)
Still, I jumped right in and built first my own application. As I wanted to do this the easy way, without building my own docker containers, I relied on existing ones, which you can find easy enough through Google or directly through the Docker Registry. Using the above-mentioned Ghost Docker image, I started cobbling together my first real
That was easy enough. As a pointer, the port you mention in the
swarm.json there is not the port exposed on the domain(s), which is currently always
:80, but rather the port the container publishes towards our load balancers, which then handle it onwards to the domain(s).
$ swarm up
And up it goes and Ghost is running. Kick Ass! Then reality kicked in. Themes need to be part of the Docker container to allow me to choose other themes. I needed to build my own container. Bummer. That wasn’t the plan.
$ swarm delete
That is actually a problem I didn’t want to tackle as it is worth another post, and admittedly it is a problem with Ghost. I can say that simply editing the Dockerfile of the original container to download a few themes is easy enough, but first of all not beautiful and too much for this post. Hence, suffice to say it can easily run. More on running Ghost will come in the future.
I had another problem with Ghost, as I am currently still using wordpress.com and the import scripts I found left out all the tags. So, second idea: move to a self hosted Wordpress.This must be as easy. Above that, I could split up Wordpress the app and the MySQL database in two different containers. My own little microservice architecture … ok, not really, but more micro than one container and more room for improvement in the future. ;)
We always said that we want to build Giant Swarm to run standard Docker Containers, without change to the container itself, using our intelligent Ambassador system to interlink them. Can it be that easy? There are official containers for both MySQL and WordPress.
So what does the swarm.json look like? (I commented with
# which you need to remove because JSON can’t be commented in real life, it can in a blog post ;))
$ swarm up $ swarm status $ swarm logs <mysql_instance_id> ... running $ swarm logs <wordpress_instance_id> ... running
Check blog.thylmann.net. Up. We have liftoff.
If you’d like to try this out yourself, just adapt my swarm.json to your needs and have your own blog hosted on the swarm. The only thing you need is an invitation to our Alpha.
This article should get you started with a simple blog setup with Docker on Giant Swarm. It’s still not perfect, but it’s a good version 1 (I am using it in production that is). I’m already thinking of improving it, but that’s for another blog post. Maybe I’ll even go into some caching solutions for high traffic blogs.