setting up ghost cms in docker

i went on an adventure yesterday. i wanted to play with ghost cms just to see how it differs from wordpress. i was quite impressed by how quickly i was able to crash it. i first started using the docker container with mysql hosted in another container. after i noticed that the container was crashing i started poking around with some git posts about similar issues....

after about an hour i narrowed it down to a node module called sharp. apparently its used for image manipulations which made sense because it was crashing when i was uploading an image. so i thought, maybe its something in the container here. so i installed npm on my server, installed the ghost-cli and ran the install. nope, same thing

one post suggested entering the bash shell of the container and "sudo rm -f /" on the node module itself. hilarious. where do these kids come up with these things. i tried it anyway. it didnt crash any longer, but posted an error about not being able to upload images.

next clue i found pointed to disabling the image optimizations in the options. well thats cool, now ive got to map configs. set nginx all up and then put the value for disabling image optimization in the config.production.json. sweet that worked. went back over to the docker container and realized the config wasnt mapped to the volume mounts. ugh. may as well just put this on a newer server maybe?

i ended up finding through a series of other git issues logged to the main project that there was a library that needed a specific CPU instruction. makes sense, my server is about a decade old. I then moved what I had done already over to another server that was a little newer and seemed to work perfectly. oh well... i wanted to move containers to this new server anyway.

i found it really weird that the container cant use the docker secrets. apparently it is because of the way they use the values and not set them as variables. no matter, i found when i was mapping the config i could just put the credentials in there. luckily i set it up with ghost-cli so i had that basic config to look at.

TLDR -

  • make sure youre running a newer cpu that supports SSE4.2
  • subscribe and you'll find a couple more hints and example config entries below
  • dont try to use docker secrets in the compose file as they dont use them in the container that way. best to just set the db settings in the config file
  • email needs to be sent when using the fqdn/dns name of the website. you cant point to a local ip/port as it does some mx record checking and subscription mails will fail

Example docker compose entry.

ghost_prod: 
  image: ghost:latest 
  container_name: ghost_prod 
  restart: always 
  ports: - 8180:2368 
  environment: 
  	- NODE_ENV=production # set either production or development
  volumes: 
  	- /mnt/containers/ghost_prod/content:/var/lib/ghost/content 
    - /mnt/containers/ghost_prod/config.production.json:/var/lib/ghost/config.production.json

config.production.json

{
  "url": "https://yourdomain.net/",
  "server": {
    "port": 2368,
    "host": "::"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "mysqlserver",
      "user": "ghostDBUser",
      "password": "supersecretpassword",
      "database": "ghost_dbname"
    }
  },
  "mail": {
    "transport": "SMTP",
    "from":"'your displayname' <[email protected]>",
    "options": {
      "host": "smtp.ionos.com",
      "port": 587,
      "secure": false,
      "requireTLS": true,
      "auth": {
        "type": "LOGIN",
        "user": "[email protected]",
        "pass": "supersecretpassword"
      }
    }
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}