From bab4b9b05662e2584981d2eefee8d5174e430808 Mon Sep 17 00:00:00 2001 From: Jake Klinker Date: Sun, 19 Nov 2023 10:23:07 -0700 Subject: [PATCH] Update other-database-backends.md Add documentation about how to use a docker compose postgres container and connect it to tubesync. This seems like a fairly basic use case that many users would want to implement, given the large performance benefits it brings. --- docs/other-database-backends.md | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/other-database-backends.md b/docs/other-database-backends.md index 17d61a22..d0b1d1f7 100644 --- a/docs/other-database-backends.md +++ b/docs/other-database-backends.md @@ -78,3 +78,46 @@ entry in the container or stdout logs: If you see a line similar to the above and the web interface loads, congratulations, you are now using an external database server for your TubeSync data! + +## Docker Compose + +If you're using Docker Compose and simply want to connect to another container with +the DB for the performance benefits, a configuration like this would be enough: + +``` + tubesync-db: + image: postgres:15.2 + container_name: tubesync-db + restart: unless-stopped + volumes: + - //init.sql:/docker-entrypoint-initdb.d/init.sql + - //tubesync-db:/var/lib/postgresql/data + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=testpassword + + tubesync: + image: ghcr.io/meeb/tubesync:latest + container_name: tubesync + restart: unless-stopped + ports: + - 4848:4848 + volumes: + - //tubesync/config:/config + - //YouTube:/downloads + environment: + - DATABASE_CONNECTION=postgresql://postgres:testpassword@tubesync-db:5432/tubesync + depends_on: + - tubesync-db +``` + +Note that an `init.sql` file is needed to initialize the `tubesync` +database before it can be written to. This file should contain: + +``` +CREATE DATABASE tubesync; +``` + +Then it must be mapped to `/docker-entrypoint-initdb.d/init.sql` for it +to be executed on first startup of the container. See the `tubesync-db` +volume mapping above for how to do this.