PostgreSQL information
I've noticed that using sqlite was unreliable with lots of crashes and lockouts and I decided to migrate to PostgreSQL for better experience. However, I am not really a fan of creating database containers for each of my stacks so I try to stick with creating a database stack and connecting whatever services I have to that database instead of using "depends-on". However, for tubesync, there is a problem because the container does not retry the connection if the database is not up. Therefore, it stays unusable unless manually restarted.
This is a workaround for the current issue. First create a database stack and make sure that the volume paths are correct and init.sql ispresent.
init.sql
CREATE DATABASE tubesync;
Compose
name: databases
services:
# PostgreSQL
postgresql:
image: postgres:latest
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
container_name: PostgreSQL
labels:
- "com.centurylinklabs.watchtower.enable=false" # disable watchtower updates
shm_size: 128mb
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=admin
- POSTGRES_DB=Default-Database
- TZ=Europe/Istanbul
volumes:
- /volume1/docker/Databases/PostgreSQL/data:/var/lib/postgresql/data
- /volume1/docker/Databases/PostgreSQL/init-scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- 9419:5432
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- default
restart: unless-stopped
# Adminer
adminer:
image: adminer:latest
container_name: Adminer
labels:
- "com.centurylinklabs.watchtower.enable=false" # disable watchtower updates
environment:
- TZ=Europe/Istanbul
ports:
- 8665:8080
extra_hosts:
- "host.docker.internal:host-gateway"
networks:
- default
restart: unless-stopped
networks:
default:
name: database_network
ipam:
driver: default
config:
- subnet: "172.16.15.0/24"
Then download the wait-for-it.sh from https://github.com/vishnubob/wait-for-it create a custom-entrypoint.sh file with below contents Make sure that bind mounts are correct with wait-for-it.sh and custom-entrypoint.sh are present.
custom-entrypoint.sh
#!/bin/sh
# custom-entrypoint.sh
# Wait for PostgreSQL to be ready
/docker-scripts/wait-for-it.sh PostgreSQL:5432 --timeout=30 --strict -- echo "PostgreSQL is up."
# Execute the original entrypoint script
exec /init
Compose
name: downloaders
services:
tubesync:
image: ghcr.io/meeb/tubesync:latest
container_name: TubeSync
entrypoint: ["/docker-scripts/custom-entrypoint.sh"]
labels:
- "com.centurylinklabs.watchtower.enable=true"
environment:
- TZ=Europe/Istanbul
- PUID=1035
- PGID=100
- HTTP_USER=admin
- HTTP_PASS=admin
- DATABASE_CONNECTION=postgresql://admin:admin@PostgreSQL:5432/tubesync
volumes:
- /volume1/docker/Downloaders/TubeSync/config:/config
- /volume1/Downloads/TubeSync:/downloads
- docker-scripts:/docker-scripts
ports:
- 4848:4848
extra_hosts:
- "host.docker.internal:host-gateway"
restart: unless-stopped
networks:
- database_network
- default
networks:
default:
name: downloader_network
ipam:
driver: default
config:
- subnet: "172.16.1.0/24"
database_network:
name: database_network
external: true
volumes:
docker-scripts:
name: docker-scripts
driver: local
driver_opts:
type: none
device: /volume1/docker/docker-scripts
o: bind
this will make sure that TubeSync will wait for the PostgreSQL to be ready before starting the container without modifying any docker image.