Ghost - Docker Compose

Ghost - Docker Compose
Photo by Tandem X Visuals / Unsplash

The official Ghost Docker repo is cumbersome and not for everyone, especially me!

Look at these mess!
https://github.com/TryGhost/ghost-docker
https://docs.ghost.org/install/docker

So I came up with my own compose.yaml that is simpler and works well with Cloudflare proxy... check it out!


services:
  ghost:
    image: ghost:6-alpine
    container_name: ghost_cms
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "80:2368"
    environment:
      # Core routing
      url: https://piyorose.com
      NODE_ENV: production
      
      # Database Connection Parameters
      database__client: mysql
      database__connection__host: db
      database__connection__port: 3306
      database__connection__user: ghost_user
      database__connection__password: Ghost_Secure_Password_123!
      database__connection__database: ghost_production

      # SMTP Email Configuration (Transactional)
      # Replace these placeholders with your actual provider credentials
      mail__transport: SMTP
      mail__options__host: live.smtp.mailtrap.io
      mail__options__port: 587
      mail__options__auth__user: api
      mail__options__auth__pass: <YOUR_API_TOKEN>
      mail__from: "[email protected]"
      mail__options__secureConnection: "false"

    volumes:
      - ./ghost_content:/var/lib/ghost/content

  db:
    image: mysql:8.4
    container_name: ghost_db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: Root_Secure_Password_123!
      MYSQL_USER: ghost_user
      MYSQL_PASSWORD: Ghost_Secure_Password_123!
      MYSQL_DATABASE: ghost_production
    volumes:
      - ./ghost_mysql:/var/lib/mysql
    healthcheck:
      # Ensures Ghost waits for MySQL to finish initialization
      test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -u root -p$$MYSQL_ROOT_PASSWORD || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s