From 016fdb57a193b28c5c38e3f58d91b47e39e35ca6 Mon Sep 17 00:00:00 2001 From: Nogweii Date: Sat, 20 May 2023 19:01:09 -0700 Subject: [PATCH] fix environment variable handling --- README.md | 7 ++++--- docker-compose.yml | 11 ++++++++++- server.conf.template | 14 +++++++------- startup_script.sh | 21 +++++++++++++++++---- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 61e14ff..35b57d9 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,12 @@ There are a number of environment variables available to configure Suwayomi: | Variable | Default | Description | |:-:|:-:|:-:| +| **TZ** | `Etc/UTC` | What time zone the container thinks it is. | | **BIND_IP** | `0.0.0.0` | The interface to listen on, inside the container. You almost never want to change this. | | **BIND_PORT** | `4567` | Which port Suwayomi will listen on | -| **SOCKS_PROXY_ENABLED** | `true` | Whether Suwayomi will connect through a SOCKS5 proxy | -| **SOCKS_PROXY_HOST** | `0.0.0.0` | The TCP host of the SOCKS5 proxy | -| **SOCKS_PROXY_PORT** | `0.0.0.0` | The port of the SOCKS5 proxy | +| **SOCKS_PROXY_ENABLED** | `false` | Whether Suwayomi will connect through a SOCKS5 proxy | +| **SOCKS_PROXY_HOST** | `""` | The TCP host of the SOCKS5 proxy | +| **SOCKS_PROXY_PORT** | `""` | The port of the SOCKS5 proxy | | **DOWNLOAD_AS_CBZ** | `false` | Whether Suwayomi should save the manga to disk in CBZ format | | **MAX_PARALLEL_UPDATE** | `10` | How many sources can be updated at the same time? | | **BASIC_AUTH_ENABLED** | `false` | Whether Suwayomi requires HTTP Basic Auth to get in. | diff --git a/docker-compose.yml b/docker-compose.yml index 1db24cc..49b34ab 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,19 @@ --- version: '3.7' services: - tachidesk-docker: + suwayomi: image: tachidesk:new environment: - TZ=Etc/UTC # Use TZ database name from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + - DEBUG=true + - BIND_IP=0.0.0.0 + - BIND_PORT=4567 + - SOCKS_PROXY_ENABLED=false + - DOWNLOAD_AS_CBZ=true + - MAX_PARALLEL_UPDATE=3 + - BASIC_AUTH_ENABLED=true + - BASIC_AUTH_USERNAME=manga + - BASIC_AUTH_PASSWORD=hello123 volumes: - ./data:/home/suwayomi/.local/share/Tachidesk ports: diff --git a/server.conf.template b/server.conf.template index 50506dc..d6a69ca 100644 --- a/server.conf.template +++ b/server.conf.template @@ -1,9 +1,9 @@ # Server ip and port bindings -server.ip = "${BIND_IP:-0.0.0.0}" -server.port = ${BIND_PORT:-4567} +server.ip = "${BIND_IP}" +server.port = ${BIND_PORT} # Socks5 proxy -server.socksProxy = ${SOCKS_PROXY_ENABLED:-false} +server.socksProxy = ${SOCKS_PROXY_ENABLED} server.socksProxyHost = "${SOCKS_PROXY_HOST}" server.socksProxyPort = "${SOCKS_PROXY_PORT}" @@ -15,18 +15,18 @@ server.webUIInterface = "browser" # "browser" or "electron" server.electronPath = "" # downloader -server.downloadAsCbz = ${DOWNLOAD_AS_CBZ:-false} +server.downloadAsCbz = ${DOWNLOAD_AS_CBZ} server.downloadsPath = "" # updater # sets how many sources can be updated in parallel. updates are grouped by source and all mangas of a source are updated synchronously -server.maxParallelUpdateRequests = ${MAX_PARALLEL_UPDATE:-10} +server.maxParallelUpdateRequests = ${MAX_PARALLEL_UPDATE} # Authentication -server.basicAuthEnabled = ${BASIC_AUTH_ENABLED:-false} +server.basicAuthEnabled = ${BASIC_AUTH_ENABLED} server.basicAuthUsername = "${BASIC_AUTH_USERNAME}" server.basicAuthPassword = "${BASIC_AUTH_PASSWORD}" # misc -server.debugLogsEnabled = ${DEBUG:-true} +server.debugLogsEnabled = ${DEBUG} server.systemTrayEnabled = false # always disabled as we are in a headless container diff --git a/startup_script.sh b/startup_script.sh index cb324e6..98ee988 100755 --- a/startup_script.sh +++ b/startup_script.sh @@ -1,11 +1,24 @@ #!/bin/sh -set -euo 'pipefail' +# Immediately bail out if any command fails: +set -e echo "Suwayomi data location inside the container: /home/suwayomi/.local/share/Tachidesk" -if [ ! -f /home/suwayomi/.local/share/Tachidesk/server.conf ]; then - envsubst < /home/suwayomi/server.conf.template > /home/suwayomi/.local/share/Tachidesk/server.conf -fi +# set default values for environment variables: +export TZ="${TZ:-Etc/UTC}" +export BIND_IP="${BIND_IP:-0.0.0.0}" +export BIND_PORT="${BIND_PORT:-4567}" +export SOCKS_PROXY_ENABLED="${SOCKS_PROXY_ENABLED:-false}" +export SOCKS_PROXY_HOST="${SOCKS_PROXY_HOST:-""}" +export SOCKS_PROXY_PORT="${SOCKS_PROXY_PORT:-""}" +export DOWNLOAD_AS_CBZ="${DOWNLOAD_AS_CBZ:-false}" +export MAX_PARALLEL_UPDATE="${MAX_PARALLEL_UPDATE:-10}" +export BASIC_AUTH_ENABLED="${BASIC_AUTH_ENABLED:-false}" +export BASIC_AUTH_USERNAME="${BASIC_AUTH_USERNAME:-""}" +export BASIC_AUTH_PASSWORD="${BASIC_AUTH_PASSWORD:-""}" +export DEBUG="${DEBUG:-true}" + +envsubst < /home/suwayomi/server.conf.template > /home/suwayomi/.local/share/Tachidesk/server.conf exec java -jar "/home/suwayomi/startup/tachidesk_latest.jar";