/ Azure Deploy

Upgrading Ghost for Azure Deploy

This post will cover my experience of upgrading ghost v 1.10 forked from my friend, Thiago Passos' git repository. Hopefully, you can benefit from my trial and error, and get the answer that you've been expecting. You can check the final product of the upgrade on my git repository.

Let me begin by with a big disclaimer up front.

If you use Ghost below version 1.13, you might need to remove and re-deploy your App Service as you need to do ghost migrate, yet we have no access to ghost command globally in our Azure App Service.

Now, let's get started.

Upgrading is not that hard...

If you know what to expect.

I'm relatively new to Azure environment. To be precise, I have never used Azure App Service before. The concept that Thiago showed me about Azure Deploy sparks my interest in upgrading his TryGhost repository then deploy my own blog with the final product.

Apparently, there is no proper way of upgrading the Ghost blog in the cloud other than:

  1. Syncing the git repository (for version 1.13 and above), or
  2. To completely redeploy Ghost to a new App Service.

Regardless, these two options require you to download Ghost from https://ghost.org/developers/ then overwrite it to your existing repository.
Then, you need to wire up several settings to make sure everything will be working fine.

Check and make a note of your previous changes

You don't want to just delete all your personal touch just for the sake of upgrading, do you?

Keep track of your previous changes. Most UI changes are easy to implements since the theme does not change a lot. But, if you did some changes in logic, make sure you know where it is and copy it across if possible.

Now, it's time to get to the most important part.

Crucial scripts

You would notice that I have an extra file in my repository: knex-migrator.js. This script will help us in doing the knex migrator init without the hassle of directing it inside the path.

You would also notice that I edited several other scripts.

  1. MigratorConfig.js: I enforced the usage of sqlite3 by default since I realised that most of us that use this kind of deployment wouldn't spin another SQL instance just for the database. Moreover, sqlite3 is fast enough to handle blog.
  2. packages.json: I added a "postinstall": "node knex-migrator.js" script inside the scripts tag. This will run the knex migrator just after the npm install finishes. I also swapped the node version requirement to enforce using 8.9.0, then 6.9.5.
  3. azuredeploy.json: This is the most crucial part. Change the WEBSITE_NODE_DEFAULT_VERSION value to your preference of node version. You can check the available node versions from https://[yourblogname].azurewebsites.net/api/diagnostics/runtime. Make sure you put the available version. Otherwise, Azure App Service will default your node version to 0.10.40 and will cause a lot of issues.

The WEBSITE_NODE_DEFAULT_VERSION had been the most annoying part of my experience in setting up this Ghost blog. I received a lot of error regarding using const in strict mode which everyone said that I need to upgrade my node version, yet I thought version 8.9.0 exist in Azure App Service.

Hope this helps you in upgrading the Ghost. If you have any comments or suggestions, please do send me a message and I'll get back to you as soon as I can.