Ghost setup using Docker

For a long time, I was using WordPress for a basic website setup. I mainly did this since it was easy to set up and run with a LAMP stack (Apache/MySQL/PHP). This was the old way I did things, you know just what I taught myself over the years. LAMP was always a stable setup, and still is of course.
Over the past couple of years, I have started to dive deep into containerization. This started in my own environment with lots of Self-hosted goodies, more to come on this. So I figured, why not bring this to my web hosting?
I heard about Ghost on the self-hosted podcast. It took some time for me to actually take a look at this. Mainly since my day job is all about computing, I don't have as much time for my home lab as I used to. Since spinning up containers is a breeze, I spun up a local copy on my large Docker VM. For this I used Docker Compose since it has a MySQL database attached.
version: '3.1'
services:
ghost:
image: ghost:4-alpine
restart: always
ports:
- 8080:2368
environment:
database__client: mysql
database__connection__host: db
database__connection__user: root
database__connection__password: example
database__connection__database: ghost
url: http://localhost:8080
db:
image: mysql:8.0
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
I pulled this Docker compose from Dockerhub, it is just an example as you can see from the password field. However, it's a quick setup, and I was able to quickly get started with Ghost. My first impression were'nt great, maybe it was the colors. But once I played around I started to like it. The application has great customizations and even allows for "code injection", meaning you can input HTML, CSS, and I think Java into the header/footer files. The next major plus was everything could be written in markdown. This is a major plus since it makes editing content a breeze.
After some refinement and reading the documentation, I was able to edit the compose file. The above will only work as a test. You will lose all your configurations if you don't set up volumes for MySQL and Ghost. Below is my final compose file.
version: '3.1'
volumes:
ghost:
ghost-db:
services:
ghost:
image: ghost:latest
restart: always
ports:
- 8080:2368
volumes:
- ghost:/var/lib/ghost/content
environment:
database__client: mysql
database__connection__host: db
database__connection__user: root
database__connection__password: #Change This
database__connection__database: ghost
# this url value is just an example, and is likely wrong for your environment!
url: http://127.0.0.1:8080
db:
image: mysql:8
restart: always
volumes:
- ghost-db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: #Change This
To get this running all we need to do is initialize with a docker compose command.
docker compose -f ghost.yaml up -d