Run your blog with Ghost, Docker with Free SSL Certificate

Run your blog with Ghost, Docker with Free SSL Certificate

In this blog post I'll show you how to set up your own blog just like mine with Ghost, Docker, Nginx and LetsEncrypt for HTTPS. You can follow these instructions to kick-start your own blog or find some alternative approaches in the conclusion.

When I decided to start my blog I knew that I wanted it to have a clean and uncluttered theme, no dependencies on an external relational database and that it should allow me to write in Markdown. Markdown is a kind of structured text for writing documentation which gets turned into HTML for viewing.

Before starting, What you need to build this set-up

  1. A linux machine installed with Docker and Docker-compose
you can replicate this setup to any environments, whether it is VPS or Raspberry-pi or Home lab server

2. NGIX Proxy, you can follow below guide to set-up easy nginx proxy manager

Install Nginx Proxy Manager (NPM) with Docker
This tutorial is focus on showing you how to deploy the Nginx proxy manager:

Run the blog with Ghost and Docker

here we are setup the ghost with help of docker.

  • create directory under your /home
mkdir ghost
cd ghost
nano docker-compose.yml

You can copy paste below code to your machine, change below variables

MYSQL_ROOT_PASSWORD: 
database__connection__password:
url: youblog.com
version: '3'
services:

  ghost:
    image: ghost:latest
    restart: always
    ports:
      - 9090:2368
    depends_on:
      - ghostdb
    environment:
      url: https://youblog.com
      database__client: mysql
      database__connection__host: ghostdb
      database__connection__user: root
      database__connection__password: changeme
      database__connection__database: ghost
    volumes:
      - ./content:/var/lib/ghost/content
      - ./config.production.json:/var/lib/ghost/config.production.json

  ghostdb:
    image: mysql:5.7
    ports:
      - 3306:3306
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: changeme
    volumes:
      - ./mysql:/var/lib/mysql

  matoma:
    depends_on:
      - ghostdb
    image: matomo:latest
    restart: unless-stopped
    ports:
      - 9091:80
    volumes:
    - ./config/matomo:/var/www/html/config:rw
    - ./config/php.ini:/usr/local/etc/php/php.ini

volumes:
  mysql:
  content:
  config:

networks:
  default:
    external:
      name: nginx-proxy-network

docker-compose.yml

once you have done hit ctrl+x and save the file

now you need to create another file called config.production.json in the same directory

nano config.production.json
{
  "url": "https://yourblog.com",
  "server": {
    "port": 2368,
    "host": "0.0.0.0"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "ghostdb",
      "user": "root",
      "password": "changeme",
      "database": "ghost"
    }
  },
  "mail": {
    "from": "'Your Name' <[email protected]>",
    "transport": "SMTP",
    "options": {
      "service": "Mailgun",
      "host": "smtp.eu.mailgun.org",
      "port": 465,
      "secureConnection": true,
      "auth": {
        "user": "[email protected]",
        "pass": "copy your SMTP password"
      }
    }
  },
  "logging": {
      "rotation": {
      "enabled": true,
      "count": 10,
      "period": "1d"
    },
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}

config.production.json

once you have done hit ctrl+x and save the file

Starting Docker Containers

once you have all file you may execute below command to run the docker containers

docker-compose up -d

Setting up ghost account

access your site http://yourblog.com/ghost enter details and start your blog

Happy Blogging ;)