Skip to content

Audiobookshelf in Docker Swarm

Skip the setup and get Audiobookshelf "ElfHosted"! πŸ₯³

Want to skip the self-assembly, and have Audiobookshelf INSTANTLY "Just Workβ„’"?

ElfHosted is an open-source app hosting platform (geek-cookbook-as-a-service), crafted with love by @funkypenguin - get your ElfHosted 🧝 instance of Audiobookshelf now!

Audiobookshelf is a powerful audiobook / podcast streaming server, whose strength lies in its native app support on Android / iOS (Testflight required).

Audiobookshelf Screenshot

Features include:

  • Fully open-source, including the android & iOS app (in beta)
  • Stream all audio formats on the fly
  • Search and add podcasts to download episodes w/ auto-download
  • Multi-user support w/ custom permissions
  • Keeps progress per user and syncs across devices
  • Auto-detects library updates, no need to re-scan
  • Upload books and podcasts w/ bulk upload drag and drop folders
  • Backup your metadata + automated daily backups
  • Progressive Web App (PWA)
  • Chromecast support on the web app and android app
  • Fetch metadata and cover art from several sources
  • Basic ebook support and e-reader (experimental)
  • Merge your audio files into a single m4b w/ metadata and embedded cover (experimental)

The developers are actively making improvements (as evidenced by the audiobookserver github repo!), and welcome suggestions. There's even a Discord server!

Audiobookshelf requirements

Ingredients

Already deployed:

New:

  • DNS entry for your auth host ("audiobookshelf.yourdomain.com" is a good choice), pointed to your keepalived IP

Setup data locations

First, we create a directory to hold the metadata and config (Audiobookshelf docs indicate that these should be separate directories):

mkdir /var/data/audiobookshelf/metadata
mkdir /var/data/audiobookshelf/config

Setup environment

It's helpful to keep environment variables in a separate file, so create /var/data/config/audiobookshelf/audiobookshelf.env, as follows (you may want to customise the UID/GID to match those of your media folder):

AUDIOBOOKSHELF_UID=99
AUDIOBOOKSHELF_GID=100

Audiobookshelf Docker Swarm config

Create a docker swarm config file in docker-compose syntax (v3), something like the example below.. example:

Fast-track with premix! πŸš€

"Premix" is a git repository which includes necessary docker-compose and env files for all published recipes. This means that you can launch any recipe with just a git pull and a docker stack deploy πŸ‘.

πŸš€ Update: Premix now includes an ansible playbook, enabling you to deploy an entire stack + recipes, with a single ansible command! (more here)

/var/data/config/audiobookshelf/audiobookshelf.yml
version: '3'

services:
  app:
    image: advplyr/audiobookshelf
    env_file: /var/data/config/audiobookshelf/audiobookshelf.env
    volumes:
      - /var/data/audiobookshelf/config:/config
      - /var/data/audiobookshelf/metadata:/metadata
      # Set this next volume to wherever you store your audiobook library. 
      # You can define multiple libraries within this folder, like `/media/audio/podcasts`, `/media/audio/audiobooks`, etc
      - /var/data/media:/media
    deploy:
      replicas: 1      
      labels:
        # traefik
        - traefik.enable=true
        - traefik.docker.network=traefik_public

        # traefikv1
        - traefik.frontend.rule=Host:audiobookshelf.example.com
        - traefik.port=80       

        # traefikv2
        - "traefik.http.routers.audiobookshelf.rule=Host(`audiobookshelf.example.com`)"
        - "traefik.http.routers.audiobookshelf.entrypoints=https"
        - "traefik.http.services.audiobookshelf.loadbalancer.server.port=80"

    networks:
      - traefik_public

networks:
  traefik_public:
    external: true

Should we use Traefik Forward Auth?

No, because (a) the mobile apps won't work with session/cookie based auth, and (b) the docs indicate that using middleware which alters CORS with Traefik will cause the app to error!

Run Audiobookshelf

Launch the audiobookshelf stack by running docker stack deploy audiobookshelf -c <path -to-docker-compose.yml>

Setup audiobookshelf

Now hit the URL you created for Audiobookshelf, and you'll find yourself presented with the "Initial Server Setup". After creating a user and password, setup your libraries, and then either stream your audio directly in your browser, or fire up the Android / iOS app and listen on the go! 1

Summary

What have we achieved? We can now easily consume our audio books / podcasts via Audiobookshelf, securely over our Traefik-exposed service! 2

Summary

Created:

  • Audiobookshelf is running, able to access your media libraries, and is streaming books / podcasts to you, wherever you are! πŸ“– 🎧

Chef's notes πŸ““


  1. The apps also allow you to download entire books to your device, so that you can listen without being directly connected! ↩

  2. Audiobookshelf pairs very nicely with Readarr, and Prowlarr, to automate your audio book sourcing and management! ↩

Tip your waiter (sponsor) πŸ‘

Did you receive excellent service? Want to compliment the chef? (..and support development of current and future recipes!) Sponsor me on Github / Ko-Fi / Patreon, or see the contribute page for more (free or paid) ways to say thank you! πŸ‘

Employ your chef (engage) 🀝

Is this too much of a geeky PITA? Do you just want results, stat? I do this for a living - I'm a full-time Kubernetes contractor, providing consulting and engineering expertise to businesses needing short-term, short-notice support in the cloud-native space, including AWS/Azure/GKE, Kubernetes, CI/CD and automation.

Learn more about working with me here.

Flirt with waiter (subscribe) πŸ’Œ

Want to know now when this recipe gets updated, or when future recipes are added? Subscribe to the RSS feed, or leave your email address below, and we'll keep you updated.

Your comments? πŸ’¬