services:

  tunnel:
    image: cloudflare/cloudflared
    command: tunnel --no-autoupdate run
    restart: always
    environment:
      TUNNEL_TOKEN: ${TUNNEL_TOKEN}
    depends_on:
      - ghost
      - caddy

  caddy:
    image: caddy:alpine
    volumes:
      - ./static:/usr/share/caddy/static
    restart: always

  ghost:  
    image: ghost:5-alpine
    restart: always
    depends_on:
      - db
    environment:
      # see https://ghost.org/docs/config/#configuration-options
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: ${MYSQL_PASSWORD}
      database__connection__database: ghost
      mail__transport: SMTP
      mail__options__service: Mailgun
      mail__from: ${MAILGUN_USERNAME}
      mail__options__auth__user: ${MAILGUN_USERNAME}
      mail__options__auth__pass: ${MAILGUN_PASSWORD}
      url: ${URL}
      server__port: 80
    volumes:
      - ./data/ghost:/var/lib/ghost/content

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
    volumes:
      - ./data/db:/var/lib/mysql