My previous blog was built with BlogEngine.NET and blog post content saved in files on the Azure web server because I didn't want the hassle and the costs of a database.
I decided to leave Azure for AWS because Microsoft decided to change the terms on the developer subscription with free credits that I had had for so many years and needed a new subscription and then pay after 12 months. I didn't want to do that so I thought I might as well go all in into AWS as most of my cloud experience is there anyway.
I had found a bug upgrading BlogEngine, I didn't want to modify any source code and the people maintaining it weren't going to fix the issue. I wanted better support and also able to keep costs dead low or zero.
This meant my requirements for a new blog would be:
- easy to use and well supported blog app
- can create a static website
- easy to backup the content
- easy to update the static files and upload them
- hosting costs low or zero
After plenty of googling I decided on Ghost and there were existing tools to use to create static files for hosting. Easy right? Well as it turned out there were quite a few things that didn't go right and at least one rabbit hole entered and escaped to get to this point.
I know I could have incurred some costs with a monthly subscription with Ghost managing it for me but where's the fun in that! I wanted to learn something new and I like having something to write about and share.
Creating the static files
I found this blog article on creating and hosting your static files from your Ghost blog in Google Cloud but I'm using AWS. This section will make some assumptions you have read the article and/or seen the existing code.
The author first created a Docker version of the Ghost blog and used an existing tool to create the static files. This is what I have changed:
- Copied the files from GitHub.
- Removed the gcloud.repo file as I'm using AWS.
- Updated the
docker-compose.ymlwith more configured values.
- Arguments added for the author e-mail and Disqus site name and version numbers updated. I don't want to use the latest versions because I want predictability in my setup.
- Environment Ghost domain updated.
- Additional volumes for the static and backup files to be saved to.
- Next, the Dockerfile had many changes.
- Replaced the
LABELthat uses the
sudowhen getting the dependencies.
- Replaced the Google Cloud installation with AWS client.
- A specific version of Ghost will be installed as per the argument.
- A custom script will replace the variables with the argument values before the Disqus patch is applied to the blog.
- As you can see from the above script it passes the Ghost version and Disqus site to the following script that then updated the
disqus.patchfile with the values. This is my improvement over the original GitHub so I do not need to update the version numbers every time I update Ghost.
- Then the following patch would be applied when the
Dockerfileran to use configured the values,
DISQUS_SITE. This is essential for the patch to be applied to the installed Ghost blog. Note here I am using the default casper theme.
So I have all that code customised for my blog and I need to create the static files.
- If this is the first time setup then from the root project run
- Go to
https://binarydreams.bizand edit your brand new Ghost blog or import your backup content.
- I would have generated the static files using
docker-compose exec app /usr/local/bin/generate_static_content.shbut that comes later in my setup when I upload to S3.
In what you have seen so far there is still more configuration I could do and I will come back to this article if I do make other changes. In the next few articles I will show what I did to easily backup and update the static website with two separate scripts.