Ghost File Downloads with Docker, Caddyserver, Traefik, and LetsEncrypt

Before we begin, you might be interested in a similar writeup I have on Docker, Ghost Blog, Traefik, and FileBrowser. This post replaces Filebrowser with Caddyserver

Woah, that is a mouthful, but you probably know why you are here. In today's short lesson we will build out the doker-compose.yml file with all the docker-labels and Traefik configuration that enables simple file downloads from within your Ghost blog.

docker-compose.yml

version: '3'

services:

   images:
        container_name: caddy
        image: caddy/caddy:scratch
        command: file-server --root /files
        restart: always
        networks:
            - web
        volumes:
            - ./files:/files:ro
        labels:
            - traefik.http.routers.images.rule=Host(`files.<DOMAIN>`)
            - traefik.http.routers.images.tls=true
            - traefik.http.routers.images.tls.certresolver=le
            - traefik.http.services.images.loadbalancer.server.port=2015
            
    ghost:
        image: ghost:3-alpine
        container_name: ghost
        restart: unless-stopped
        volumes:
            - "./ghostdata:/var/lib/ghost/content"

        environment: 
            url: https://www.<DOMAIN>.com

        networks:
            - web

        labels:
            - "traefik.docker.network=web"
            - "traefik.enable=true"
            - "traefik.frontend.rule=Host:www.<DOMAIN>.com,<DOMAIN>.com"
            - "traefik.port=2368"
            - "traefik.protocol=http"
            - "traefik.backend=ghost"
            - "traefik.frontend.headers.SSLRedirect=true"
            - "traefik.frontend.headers.SSLHost=www.<DOMAIN>.com"
            - "traefik.frontend.headers.SSLForceHost=true"

networks:
    web:
        external: true