So, for this personal site, the plan was to build out a basic website that has a headless CMS that could be customized to a React or Angular client facing frontend. Then I realised that this was a silly idea and made for and extremely convoluted project structure for what essentially needs to be a list of projects and a sarcastic 'look at me' bio. So instead I went with Craft CMS and Twig Templates as the simple, out of the box templating engine.
Now that I has the CMS and the front end decided, I needed to choose how to style the site. Design, by no means my forte, so I decided to give Tailwind a whirl. It's touted itself as a utility-first CSS framework. This meant I could do the styling within the templates and remove most of the CSS requirements for what needs to be a simple site. Tailwind suited this purpose, but I would have to have a much harder think about the it's value if the site were to require more complexity. I think Tailwind could get very messy very quickly.
For a development environment, I created a simple Docker config that pulls in the Craft CMS docker image to run Apache and Postgres locally. This means I can replicate the production environment locally and decrease the risk of failure on the live server.
The next step was to choose a host. I toyed with the idea of AWS hosting using EC2, RDS, Route53 and S3 as the infrastructure. I then, however, decided that Jeff Bezos has enough money and I'm a little tired of the AWS interface. So I decided that Digital Ocean was the go. So I created an account, setup a droplet running Ubuntu 20.04 and installed Apache based on the Craft CMS requirements. Connected it to a Postgres database through the Digital Ocean web interface and hey presto, we have ourselves a server.
The final step was deployment. At first it was going to be an FTP situation. I thought it to be the quickest, easiest option. Then I reminded myself that that's a dumb option. So I looked at deployment options. I've had experience with Deployer previously, but looked into Deploybot and Octopus Deploy first as a bit of a change. But ultimately decided to go with Deployer because it is open source and already had Craft CMS recipes out of the box.
So now, I have a server on Digital Ocean. I have my code stored safely in Github. I have a local environment running Docker for ease of development and I have a deployment pipeline that is as simple as running "dep deploy". Easy, right? Wrong. Setting this up came with it's challenges. The first being a weird PHP error on the initial deploy. When I initially created the Droplet, I ran through the requirements for Craft and installed them all. One of the first things installed was PHP 8.1, followed by the rest of the shopping list. Once I deployed the first release and configured the Apache server, I kept running into a page that was returning the index.php file as a plain HTML file. Weird, right? After a bit of debugging and a few choice words about my life choices that led me here, I decided to re install PHP. That worked. I'm still not entirely sure why. I can only assume that I changed something along the way after initially installing PHP.
The next issue I ran into was on initial deployment, I needed to install Craft in release 1 to successfully complete the deployment. So ultimately release 1 fails. You cd into that directory on the server and then run the install command for craft to complete the setup and this allows the deployment to continue. However, this brought a new issue.
See, I initially setup with the idea of deploying into a MYSQL database. Seemed simple enough until I tried to deploy to Digital Oceans MYSQL instance. Every time I ran the Craft CMS installer, I received an failure message complaining that MyIAM engine needed to be enabled for the Craft CMS searchindex table to correctly configure. This, it turns out, is something Digital Ocean doesn't offer on the MYSQL instances. A bit of digging led me to a Github thread where the Craft developers gave two options. Those were, enable MyIAM or use Postgres... I now use Postgres.
After all that effort, I now have a site where I can ramble on about my side projects and personal adventures!