Category Archives: Blog

containerized blog

Another chapter in the ever growing book that is the story of my blog, as is good and right for any developer.

This is now coming at you from docker-compose. The blog, I mean. It used to be on a normal digital ocean droplet running on bare metal (well, low tier instance so probably a vmware instance but you know what I mean). Even worse, to my great shame it was just a normal wordpress instance. Now, it’s still running on that same vmware instance and it’s still wordpress, but it’s using roots/bedrock.

Dark Mode

bedrock (this link opens in a new window) by roots (this link opens in a new window)

WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure

roots/bedrock lets you manage wordpress as a composer dependency, including themes and plugins. Essentially that means the whole blog is now a git repo with a single composer.json and composer.lock file. Of course there’s a bit more to it with .env files and persistent stuff, but essentially that’s it. This is very cool on its own, but just moving one wordpress site to using composer isn’t cool enough, so I did the same for the archive. The archive was using some plugins that don’t even exist anymore, but I manged to find and patch their successors well enough to keep it afloat, so now that’s also managed with composer. That means I can easily upgrade and patch both blogs on my machine, test them here, and if everything work quickly run the same upgrade in a predictable manner in production. Cool.

But this server doesn’t just host wordpress, it’s also running my nrk_subs app, my cv app, and new as of today, my lolz aggregator. What I really want is to run everything in nice little docker containers so I can duplicate everything locally and develop it further there in the same way I would do at work, so that’s what I did. I first built the containers I needed for the blogs and then started incorporating the other projects which were already mostly containerized. So currently, this is the docker-compose.yml that manages everything here.

version: "3.8"

      context: "./database/docker"
      - "./storage/blog_and_archive.sql.gz:/docker-entrypoint-initdb.d/initdb.sql.gz"
      - "./database/data:/var/lib/mysql"
    container_name: "database"
      test: ["CMD", "mysqladmin", "ping", "--silent"]
    command: "--default-authentication-plugin=mysql_native_password"
    env_file: .env

    image: brbcoffee/blog-base
    env_file: .env
      - database
      DB_HOST: database:3306
      XDEBUG_CONFIG: remote_host=
      - "./blog/:/var/www/blog"
      - "./storage/media/blog:/var/www/blog/web/app/uploads"

    image: brbcoffee/blog-base
    env_file: .env
      - database
      DB_HOST: database:3306
      XDEBUG_CONFIG: remote_host=
      - "./archive/:/var/www/archive"
      - "./storage/media/archive:/var/www/archive/web/app/uploads"

    image: brbcoffee/proxy
    env_file: .env
      - "80:80"
      - "443:443"
      - blog
      - archive
      - cv
      - subs
      - blog
      - archive
      - lolz

    image: mailhog/mailhog
#    ports:
#      - "1025:1025"
#      - "8025:8025"

    image: brbcoffee/cv
      - "./storage/resume/CV.xml:/app/data/CV.xml"

    image: "brbcoffee/subs"

    image: php:7.3-fpm
      - APP_ENV=prod
      - "./lolz:/var/www/lolz"

    image: brbcoffee/lolz-cron
      - APP_ENV=prod
      - "./lolz:/app

As you can see a lot is managed in the .env file, and a lot of code is mounted in. The code mounting’s not necessary for everything, and I’ll be tweaking it going forward, but for now I mostly wanted to get it live so I had an MVP to work from. There are also a lot of brbcoffee/* images here, those are built in a Makefile specific to the project. I factored it out of the docker-compose.yml file in order to separate concerns a bit once the docker-compose.yml file started getting too hairy. The goal is to get rid of the droplet entirely and run the whole setup in kubernetes or something like that.

One hiccup was ssl. The rest has actually been working for weeks, but I couldn’t figure out a clean way to do ssl. In the end I decided I’m ok with not having the certificates automatically renew in version one and just fetched a wildcard with certbot and built it into the proxy container for now.

So there it is, all the stuff on brbcoffee now runs in docker containers under docker-compose. The blogs and the proxy are in the main repo, while the other services have their own repositories which are installed as git submodules. I can toggle a single .env variable and add a build arg and have node serve in dev mode, have the blog containers run xdebug, and have the python containers run a debugpy listener for fullstack local dev. Pretty cool stuff.


Welcome to Https BRBcoffee, and thank you to Let’s Encrypt and certbot for making it a breeze, mostly.
Tomorrow there will be a blog post up about the changes I needed to make to my Apache configuration in order to get certbot to play nice.

For now, glory in that green padlock! And don’t go to the archive if you want it to stay green. WordPress doesn’t automatically update image links, so I’ll need to fix that at some point. The CV though I had no trouble with, even though it’s a Flask app that Apache just redirects traffic to. Good job, Apache, good job, python!

And the archive is restored!

I did it! I partially restored the dead disk, and I did the necessary doctoring on the old WordPress database dump. Sadly, my OffTopic blog wasn’t in the backup tarball, so that’s gone forever. It only had a handful of posts anyway, so no big loss.

Anyway, has everything dating back to february 2009. I was 18 when I wrote that stuff. Don’t judge. Some of the images are gone, as is the nature of the internet. Sorry about that.


Phoenix blog

Here follows an account of how almost a decade of blogging got lost in the æther:

  1. The power supply for my old netbook broke.
  2. I moved.
  3. I moved from Amazon AWS to DigitalOcean.
  4. I moved from Ubuntu to Fedora (DigitalOcean used to support Arch, but doesn’t anymore. This annoys me).
  5. I didn’t update the blog for a long time.
  6. I retrieved all the data from my netbook hard drive’s ext4 partition that looked interesting.
  7. I turned the old hard drive into a backup disk.
  8. I wrote a new partition table to my backup disk.
  9. I added an NTFS partition to my backup disk’s partition table.
  10. I discovered that my website was down.
  11. I discovered that I had failed to retrieve the backup of the blog from the old hard drive.
  12. I discovered that I only had that one backup.
  13. I wept.

Now, I’ve tried to run some basic data recovery. It’s easy enough to retrieve data from a deleted ext4 partition, but getting data from a partition that has been deleted, whose partition table no longer exists, and that has been overwritten by a non-compatible partition type, that’s a completely different story. There are very few vectors left to me at this point. They are:

    • Find a backup disk that has my blog on it.
      • Number of possible disks: 1.
      • Probability that any of them have my blog: 0.2.
    • Download everything has on me. Write a program to retrieve all the blog posts, in order, with metadata.

Things I’ve learned from this:

    1. Your offsite backup is only as reliable as your offsite hardware.
    2. Your offsite hardware is only as reliable as your offsite hardware maintainer.
    3. Don’t be your own offsite hardware maintainer.
    4. I don’t really care what I blogged about in high school.

So, that’s where I’m at. As soon as I have a few minutes to spare I’ll decide whether or not it’s worth it to mine through the internet wayback machine for my teenage musings. I’m guessing I’ll end up doing it for the challenge, and hey, I could even write a blog series about how I did it! But even if I do this thing, and succeed, I won’t import the old blog into this one. BRBcoffee is reborn today, free of the past. Brace for impact.

Bjørn out.