No More Ugly Upgrades

No More Ugly Upgrades

Gone are the days I used to sit in front of a green screen, sweating with fear as a cursor blinked.

The upgrade command seemed to wrap several times around the screen with so many flags, switches, and built-in hacks that we used to play rock-paper-scissors to see who would hit the enter key and be ultimately responsible for the upgrade.

Another automation hack is we would place a book on the spacebar to prevent the upgrade from going idle during the upgrade all while sleeping on server room floors. The book was our CI/CD and monitoring tool!

Today, working with Docker and containers makes upgrades light years easier with a whole slew of additional options. Upgrading OS versions, Application versions, or everything as a big bang if wanted is easier than ever.

Do you want to upgrade with no downtime using Blue/Green deployments, or how about rolling updates to upgrade? This is all possible. The most challenging part of upgrading today is deciding what and how to upgrade.

This blog is powered by Ghost which has an official image on Docker Hub. The Ghost team seems to be increasing the speed at which new features and releases become available. With the power of Docker Compose, upgrading to the next version is a matter of seconds, not minutes or hours.

When a new version of Ghost is released, I quickly devour the release notes and understand everything about the upgrade, features, and bug fixes.

Next, I backed up my entire server with the AWS S3 CLI tool. The AWS CLI tool backups my Docker environment, container configs, and data just to ensure everything is current and it works well (This runs daily as a cron as well).

Finally, I pulled the latest version of Ghost and restarted my container. Done! Yeah, that's it. My upgrade procedure is to pull, restart, and go get another coffee.

Ghost Configuration

Before we can run off and start upgrading things, it's important to understand what is running in my Ghost environment. This blog setup includes a docker-compose.yml file, which makes this entire process a lot easier.

The compose file includes pulling the image directly from Docker Hub instead of building it ourselves. Also, I store the data (DB, themes & images) in a data container which allows me to separate Ghost from the Application container.

This allows Ghost to be upgraded and still persist data. Important if you want to keep your data.

Ghost docker-compose.yml file:

  ghost:
  image: ghost
    environment:
       - VIRTUAL_HOST=brianchristner.io
       - NODE_ENV=production
       - PUBLIC_URL=https://www.brianchristner.io
       - GHOST_CONTENT=/usr/src/ghost/content
       - GHOST_SOURCE=/usr/src/ghost

 volumes_from:
  - data-store
 ports:
   - "80:2368"
 restart: always
Ghost Configuration

Upgrading Ghost

So, how does a standard Docker update look like in practice? We will use the Ghost compose file from above as our upgrade example. All these commands are run from the Ghost project directory.

  1. Run docker-compose ps. This tells us the current scenario and ensures everything looks correct before we begin.
    $ docker-compose ps
  2. Pull the latest image from Docker Hub. The pull downloads the latest version and stores it locally on your Docker Host. Don't worry; the old version is still available if you need to roll it back.
    $ docker-compose pull
  3. Restart the container.
    $ docker-compose restart ghost
  4. Grab a coffee and marvel at your achievement.
Ghost Upgrade

Conclusion

The Ghost upgrade example above is one of the many container upgrade possibilities. My blog is not mission-critical, so downtime is entirely acceptable.

The downtime in my upgrade is minimal and offline only for the time it takes to restart the container. However, if you require no downtime deployments, Blue/Green deployments. It creates two separate installations of your Docker stack allowing for rolling upgrades.

This enables the upgrade of each instance of your service, allowing multiple versions to run simultaneously until the upgrade is complete. Don't forget that if the upgrade fails, it is just as easy to roll back to previous versions.

Whatever upgrade method you choose will have pros and cons for your environment. However, these upgrade options are what make Docker and containers so amazing.

The ability to pick and choose our path rather than being forced down a monolithic upgrade path is what helps me sleep at night (I'm no longer on server room floors).

Follow me

If you liked this article, Follow Me on Twitter to stay updated!