Upgrading to Ghost 5.x from 4.x using Docker and Azure App Service
Ghost 5 was announced in May and just now, I have got around to upgrading. Ghost 5 brings lots of exciting changes which you can see here. Below is the process on how to uprade to Ghost 5 from Ghost 4. It's safe to say, this should not take you longer than 15 to 20 minutes. It was surprising easy and it literally 1 change, so kudos to the Ghost team for making it seamless.
In the Dockerfile change the version from 4 to 5. The Dockerfile should look like the below. Side note, I did try to upgrade to Ghost 5 when it was released however there was a compatibility issue with the ghost-azurestorage package as it was using an outdated version of "Sharp". This however, has now been updated in this commit so I did not have to make any other changes. There was a workaround posted in this blog post in the comments section which required the cloning of the ghost-azurestorage repo and essentially "building" the package locally with the updated dependencies.
Next we want to build our new Dockerfile so in the terminal run
docker build -t myname/ghost-blog .
Once this has built we want to run this locally as a database migration will take place. I am not using CI/CD as my blog is running on the Azure App Service Basic Plan so I do not have any deployment slots.
Next we need to run the docker image. Run the below command
docker run -d --name ghost-blog -e url=http://localhost:3001 -p 3001:2368 myname/ghost-blog
In docker desktop you will see the logs look something like the below. You will see that the logs for the migration are being shown. After the migration is complete, run your site locally by navigation to localhost:3001 and your site should be up and running. Next we just need to publish our docker image to docker hub and then restart the app service to pull the latest changes and that's it, we are done.
Next we need to push our docker build. Run the below command. You might have to login first using "Docker login" and follow the instructions.
docker push myname/ghost-blog
Last but not least, we need to restart our app service to pull the latest changes so go to the Azure portal and click Restart. You will have to wait a few minutes for the image to be pulled and then done.
And that is literally it. I hope this post makes it that bit more easier for you to upgrade your blog.