Ghost is a great up and coming blogging engine. I've been hosting it on Azure quite successfully, though I've learned a few things along the way. As I've been working with Azure Web Sites and the Git deployment, I've discovered that with a bit of configuration, the deployment process runs smoothly and accurately.
If you do the following steps, you are more likely to end up with a successful deployment and upgrade.
- Go ahead and install Ghost from the gallery.
- Modify the default node version to 0.10.40.
- Setup Local Git for continuous deployment.
- Clone your git repository
- Add .gitignore to stop tracking dependencies
- Remove dependencies from git
- Modify package.json
Install Ghost from the Gallery
To install Ghost in Azure, the easiest way is to navigate to https://portal.azure.com and create a new resource. Filter the gallery by Ghost and select the Ghost entry that is in the Web + Mobil category.
Fill in the minimal required properties, by giving it an app name, choose the subscription, select the proper resource group, and fill out the email settings for notification.
Azure will provision your site in a few minutes.
Default Node Version
Before we setup Git for deployment, we want to setup the default node version. This is important when the application reruns the 'npm install --production' command during the installation of Ghost site. If the wrong version of node is used, the dependencies will be wrong.
Local Git for Deployment
Now that we have properly set the version of node, we can setup the Git Repository. In the settings, go to the Publishing section and choose the Continuous deployment. Choose a source and select the Local Git Repository. This will create a Git repository and initialize it with the already deployed files.
Clone Git Repository
In your development environment, go ahead and clone the git repository. You can find the address for the repository in the properties of the website in the Azure portal.
Exclude Dependencies from Git
It's very important to exclude the Node dependencies from your Git repository, so future changes will not affect it, so create a new
.gitignore file in the root of your site and add the following:
Remove dependencies from Git
One last bit of setup is required. You need to remove all references to the node_modules from Git. These were created prior to setting up the
.gitignore file. Just run the following git commands to exclude the files.
git rm -r -f node_modules git rm -r -f iisnode
You are now all setup for publishing Ghost to Azure with Git.