Docker Compose Deployment With Traefik - Solved

Wow, I am excited. Have been using Obsidian and now found SilverBullet: clean, compact, innovative and open - Thank You!

edit: Solved my initial error in the Traefik tags - here is a working docker-compose.yaml

Peter

services:
  silverbullet:
    image: ghcr.io/silverbulletmd/silverbullet:v2
    restart: unless-stopped
    environment:
    - SB_USER=peter:mypassword
    - PUID=1000
    - PGID=1000
    - TZ=Europe/Berlin
    volumes:
      - ./space:/space
#    ports:
#      - 3000:3000
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.silverbullet.entrypoints=http"
      - "traefik.http.routers.silverbullet.rule=Host(`silverbullet.mydomain.de`)"
      - "traefik.http.middlewares.silverbullet-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.silverbullet.middlewares=silverbullet-https-redirect"
      - "traefik.http.routers.silverbullet-secure.entrypoints=https"
      - "traefik.http.routers.silverbullet-secure.rule=Host(`silverbullet.mydomain.de`)"
      - "traefik.http.routers.silverbullet-secure.tls=true"
      - "traefik.http.routers.silverbullet-secure.service=silverbullet"
      - "traefik.http.services.silverbullet.loadbalancer.server.port=3000"
      - "traefik.docker.network=private"
    networks:
      silverbullet:
      private:
  # To enable auto upgrades, run watchtower
  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      silverbullet:
networks:
  silverbullet:
  private:
    external: true
1 Like

Traefik can get confusing at times, but it’s really good for Docker containers. Personally, I’ve been using NGINX with some community made web-UI since forever, but recently switched to Traefik because some things are just easier. Glad to see you trying SB!

I’ve been using Obsidian for the longest time. Almost my entire time in high school, actually. When I discovered SB, I made the switch. I like that I can access SB from my browser and host it under a domain which I can access anywhere without the need for installing anything extra. Plus, SB being open-source? That was the final nail in Obsidian’s coffin, haha.

Ok, I should definitely look into Trafaek finally then…

Zef, thank you for this great tool, I am definitely on board. I simply put my Obsidian markdown files in the space - and there is everything, ready to go.

I had my Obsidian files synced with syncthing to various devices, but I really do prefer running this as a service from a home server. Being able to directly reuse the Obsidian files demonstrates the strength of the markdown format, much prefered over a database internal storage structure.

I use my own domain with a dedicated subdomain per service, e.g. SilverBullet or Paperless. I run a Traefik server (in docker) on each hardware server (Box PC, Raspberry Pi) which collects various docker based services and makes them available on the respective subdomain, for which it also gets a let’s encrypt certificate. (Kudos to [GitHub - JamesTurland/JimsGarage: Homelab Goodies]) The Traefik server establishes a Cloudflare tunnel (cloudflared). I access each service via it’s own domain via Cloudflare. This gives me an external authentication layer (github or Google login) and I can select which family or friends can reach which service. This setup has proven to be stable and reliable for more than two years, so I am happy with it.

Adding another service like now SilverBullet only requires the Traefik labels, adding a CNAME for local access to my Pihole and registering the application for the respective tunnel in Cloudflare.

As I said, I am alredy hooked on to SilverBullet because it checks those boxes that kept me from fully embracing Obsidian. I do like Obsidian’s realtime search which shows a list of boxes with document name and a preview of the context(s) where the term is found as you type the search string. I would love to see something similar in SilverBullet, eventually. Apart from that, I am actually happy I get rid of some of the clutter that I had accumulated in the Obsidian setup.

Great project, thanks again!
Peter

2 Likes

Hi all

Just adding here my setup with Traefik. If you don’t need also HTTP (and then redirecting to HTTPS), less labels can be used. Here is my label set:

    labels:
      - traefik.enable=true
      - traefik.http.routers.sb-https.tls=true
      - traefik.http.routers.sb-https.tls.certresolver=ionos
      - traefik.http.routers.sb-https.entrypoints=websecure
      - traefik.http.routers.sb-https.rule=Host(`sb.domain.somewhere`)

In here, the line traefik.http.routers.sb-https.tls.certresolver=ionos refers to a configured cert provider, in my case ionos. This provider is configfured in Traefik’s static config and will issue a Let’s Encrypt certificate for the given Host sb.domain.somewhere.

I didn’t need to provide any ports to Traefik, it picks up the port 3000 opened by the SB container automatically.

The only additional things I did were:

  1. Adding the Traefik network to the SB container
  2. Commenting out the Ports part for the SB container
  3. Adding the Traefik network to the docker-compose file as external network

Here are the snippets:

# Inside SB service definition:

networks:
  - frontend

#  ports:
#    - 3000:3000

# At the end of the docker-compose file:

networks:
  frontend:
    external: true

Best,
Pascal

In my setup I don’t seem to be able to drop the other labels, but thats surely how Traefik has been setup. I have followed Jim’s (James Turland) approach, but it may be too complicated.

Don‘t know about dropping the port, didn‘t know that, never used it. But for the https redirection I just have that once in my traefik.yaml config likes this. So it does http to https redirection for every service as I don‘t host anything http only anyways. I find it quite useful.

entryPoints:
  web:
    address: :80
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https

  websecure:
    address: :443