How to self host librarian on docker compose

Librarian is a front-end for Odysee, Just like invidious for youtube. So you can use librarian to watch odysee videos without being tracked or without crypto sh!t

It's easy to host it but before I start I will assume that: * You are running debian 11 * You already have a VPS: https://blog.esmailelbob.xyz/how-to-get-a-vps * Your linux distro is up-to-date (sudo apt update && sudo apt upgrade) * You have a domain name: https://blog.esmailelbob.xyz/how-to-get-a-domain-name * Have sudo access or root account * Already installed docker and docker-compose: https://blog.esmailelbob.xyz/how-to-install-docker-and-docker-compose * Already installed Nginx: https://blog.esmailelbob.xyz/how-to-install-and-configure-nginx-96yp * Already have a reverse proxy conf file: https://blog.esmailelbob.xyz/how-to-use-reverse-proxy-with-nginx * Already have certbot to issue cert: https://blog.esmailelbob.xyz/how-to-use-certbot-with-nginx-to-make-your-website-get

Changes in DNS (domain side)

You really do not need to add any dns entries except if you want to create subdomain for this container then you go in your domain's dns panel and add either CNAME entry that looks like subdomain.domain.com and make it's target the root domain domain.com or A entry with subdoamin.domain.com and make it's target the IP of your VPS

librarian docker-compose file

We need a docker-compose.yml file so we can start librarian, for me I use this file:

version: '3'

services:
  librarian:
    #build: .
    image: nineteengladespool/librarian:latest
    ports:
      - 127.0.0.1:4403:3000
    volumes:
      - ./data/config.yml:/app/config.yml
    restart: unless-stopped

Optional stuff to change: 127.0.0.1:4403: The IP and port number for librarian (so we can use it later for nginx to reverse proxy it) ./data/config.yml: Where our config file for librarian will be saved at

config.yml file (just take an idea how it looks like)

api_url: https://api.na-backend.odysee.com/api/v1/proxy
auth_token: [**SECRET**]
blocked_claims: claimid,claim2
domain: https://librarian.esmailelbob.xyz
enable_live_stream: false
fiber_prefork: false
hmac_key: [**SECRET**]
image_cache: "false"
image_cache_dir: /var/cache/librarian
instance_privacy:
  data_collected_device: true
  data_collected_diagnostic_only: false
  data_collected_ip: true
  data_collected_url: true
  data_not_collected: false
  instance_cloudflare: false
  instance_country: Canada
  instance_provider: Kimsufi
  message: ""
  privacy_policy: ""
port: "3000"
streaming_api_url: https://api.na-backend.odysee.com/api/v1/proxy
use_http3: false
video_streaming_url: ""

[SECRET]: are tokens that I deleted to protect myself

Spin it up!

Now after we done editing, and everything is cool. We need to run our container so just run:

docker-compose up -d

the -d option does not let docker post logs of running application but if you want to see logs you can run:

sudo docker-compose logs -f -t

To check if there any weird behaviors or errors

Nginx

Now after we make sure it's running well. We need to serve it over the internet (called reverse proxy) so without much talk, here is our server block for librarian:

server {
        listen [::]:80;
        listen 80;
       
        server_name [domain name] ;

       location / {
               include /etc/nginx/reverse-proxy.conf;
               proxy_pass http://127.0.0.1:4403/;
       }
}

server_name: Change this to match domain name of librarian include: is our reverse proxy file proxy_pass: the IP and port of our running docker image

After this you should be up and running for librarian! :) just do not forget to run certbot --nginx to make it secure with https://

Update it

Of course after some time the image will be outdated and you need to update and what I love about docker that it's easy to update, really just to do it run:

docker-compose down && docker-compose pull && docker-compose up -d

What it does is: 1) Stops the container, 2) Pull last update (download last update) and 3) Re-run the container back!

Firewall

If you use firewall (ufw for example) you really do not need any ports other than 443 and 80 as we use nginx reverse proxy

#howto #selfhost #docker