From 146da91296ac39923e95111c4b05c2e2a553fa8e Mon Sep 17 00:00:00 2001 From: Nogweii Date: Sat, 20 May 2023 18:42:20 -0700 Subject: [PATCH] Rewrite the startup script to use envsubst --- Dockerfile | 10 +++++++ README.md | 70 +++++++++++++++++++++++--------------------- docker-compose.yml | 2 +- server.conf | 23 --------------- server.conf.template | 32 ++++++++++++++++++++ startup_script.sh | 21 +++++-------- 6 files changed, 87 insertions(+), 71 deletions(-) delete mode 100644 server.conf create mode 100644 server.conf.template diff --git a/Dockerfile b/Dockerfile index 29556c2..ea09a84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,14 +24,24 @@ LABEL maintainer="suwayomi" \ download_url=$TACHIDESK_RELEASE_DOWNLOAD_URL \ org.opencontainers.image.licenses="MPL-2.0" +# Install envsubst from GNU's gettext project +RUN apt-get update && \ + apt-get -y install gettext-base && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Create a user to run as RUN groupadd --gid 1000 suwayomi && \ useradd --uid 1000 --gid suwayomi --no-log-init suwayomi && \ mkdir -p /home/suwayomi && \ chown -R suwayomi:suwayomi /home/suwayomi USER suwayomi WORKDIR /home/suwayomi + +# Copy the app into the container RUN curl -s --create-dirs -L $TACHIDESK_RELEASE_DOWNLOAD_URL -o /home/suwayomi/startup/tachidesk_latest.jar COPY startup_script.sh /home/suwayomi/startup_script.sh +COPY server.conf.template /home/suwayomi/server.conf.template EXPOSE 4567 CMD ["/bin/sh", "/home/suwayomi/startup_script.sh"] diff --git a/README.md b/README.md index 69edb88..61e14ff 100644 --- a/README.md +++ b/README.md @@ -14,75 +14,79 @@ _**Tachidesk data location - /home/suwayomi/.local/share/Tachidesk**_ Docker images are mutli-arch (linux/amd64, linux/arm/v7, linux/arm64, linux/ppc64le, linux/s390x) and has small size based on Ubuntu linux. -Legacy alpine images using the `-alpine` suffix are provided for as-needed use-cases, such as: -- Support for linux platforms linux/386 and linux/arm/v6 -- Those that need a smaller image size +Logs are sent to stdout and are not written to disk. -Log file location - /home/suwayomi/.local/share/Tachidesk/logfile.log +### Docker compose +Use the template [docker-compose.yml](./docker-compose.yml) in this repo for creating and starting tachidesk docker container. -# Docker compose -Use the template compose.yml in this repo for creating and starting tachidesk docker container. +# Environment Variables + +There are a number of environment variables available to configure Suwayomi: + +| Variable | Default | Description | +|:-:|:-:|:-:| +| **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 | +| **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. | +| **BASIC_AUTH_USERNAME** | `""` | The username to log in to Suwayomi. | +| **BASIC_AUTH_PASSWORD** | `""` | The password to log in to Suwayomi. | +| **DEBUG** | `true` | If extra logging is enabled. Useful for development and troubleshooting. | # Docker tags -### Recommended tags (Ubuntu, Java 11): +## Stable -Stable: `ghcr.io/suwayomi/tachidesk:stable` +`ghcr.io/suwayomi/tachidesk:stable` -Preview: `ghcr.io/suwayomi/tachidesk:preview` +The latest stable release of the server. -Latest: `ghcr.io/suwayomi/tachidesk:latest` +## Preview +`ghcr.io/suwayomi/tachidesk:preview` +The latest preview release of the server. Can be buggy! -### Legacy tags, should only be used as required (Alpine, Java 8): +## Latest -Stable: `ghcr.io/suwayomi/tachidesk:stable-alpine` +`ghcr.io/suwayomi/tachidesk:latest` -Preview: `ghcr.io/suwayomi/tachidesk:preview-alpine` - -Latest: `ghcr.io/suwayomi/tachidesk:latest-alpine` - - - -### Explicit Ubuntu tags (Ubuntu, Java 11) : - -Stable: `ghcr.io/suwayomi/tachidesk:stable-ubuntu` - -Preview: `ghcr.io/suwayomi/tachidesk:preview-ubuntu` - -Latest: `ghcr.io/suwayomi/tachidesk:latest-ubuntu` +The most recent container to be created, can be either the stable or preview versions. Be careful! # Docker commands Expose to localhost ip - docker run -p 127.0.0.1:4567:4567 ghcr.io/suwayomi/tachidesk + docker run -p 127.0.0.1:4567:4567 ghcr.io/suwayomi/tachidesk:stable Expose to specific ip - docker run -p 192.168.x.x:4567:4567 ghcr.io/suwayomi/tachidesk + docker run -p 192.168.x.x:4567:4567 ghcr.io/suwayomi/tachidesk:stable Expose to all ips - docker run -p 4567:4567 ghcr.io/suwayomi/tachidesk + docker run -p 4567:4567 ghcr.io/suwayomi/tachidesk:stable Change the default UTC timezone. Use TZ database name from [Timezone list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) - docker run -e "TZ=Europe/London" -p 127.0.0.1:4567:4567 ghcr.io/suwayomi/tachidesk + docker run -e "TZ=Europe/London" -p 127.0.0.1:4567:4567 ghcr.io/suwayomi/tachidesk:stable Change the logging location from a file to standard output - docker run -e "LOGGING=out" -p 127.0.0.1:4567:4567 ghcr.io/suwayomi/tachidesk - + docker run -e "LOGGING=out" -p 127.0.0.1:4567:4567 ghcr.io/suwayomi/tachidesk:stable + For Tachidesk Preview version docker run -p 127.0.0.1:4567:4567 ghcr.io/suwayomi/tachidesk:preview Persistent data of tachidesk on subsequent run - docker run -p 127.0.0.1:4567:4567 -v :/./home/suwayomi/.local/share/Tachidesk ghcr.io/suwayomi/tachidesk - + docker run -p 127.0.0.1:4567:4567 -v :/./home/suwayomi/.local/share/Tachidesk ghcr.io/suwayomi/tachidesk + For Specific Tachidesk stable version (from v0.3.9 onwards) docker run -p 127.0.0.1:4567:4567 ghcr.io/suwayomi/tachidesk:v0.3.9 diff --git a/docker-compose.yml b/docker-compose.yml index b37a8fb..1db24cc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.7' services: tachidesk-docker: - image: ghcr.io/suwayomi/tachidesk:stable + image: tachidesk:new environment: - TZ=Etc/UTC # Use TZ database name from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones volumes: diff --git a/server.conf b/server.conf deleted file mode 100644 index 711d637..0000000 --- a/server.conf +++ /dev/null @@ -1,23 +0,0 @@ -# Server ip and port bindings -server.ip = "0.0.0.0" -server.port = 4567 - -# Socks5 proxy -server.socksProxy = false -server.socksProxyHost = "" -server.socksProxyPort = "" - -# misc -server.debugLogsEnabled = true -server.systemTrayEnabled = false - -# webUI -server.webUIEnabled = true -server.initialOpenInBrowserEnabled = false -server.webUIInterface = "browser" -server.electronPath = "" - -# Auth -server.basicAuthEnabled = false -server.basicAuthUsername = "" -server.basicAuthPassword = "" diff --git a/server.conf.template b/server.conf.template new file mode 100644 index 0000000..50506dc --- /dev/null +++ b/server.conf.template @@ -0,0 +1,32 @@ +# Server ip and port bindings +server.ip = "${BIND_IP:-0.0.0.0}" +server.port = ${BIND_PORT:-4567} + +# Socks5 proxy +server.socksProxy = ${SOCKS_PROXY_ENABLED:-false} +server.socksProxyHost = "${SOCKS_PROXY_HOST}" +server.socksProxyPort = "${SOCKS_PROXY_PORT}" + +# webUI +server.webUIEnabled = true +server.webUIFlavor = "WebUI" # "WebUI" or "Custom" +server.initialOpenInBrowserEnabled = false +server.webUIInterface = "browser" # "browser" or "electron" +server.electronPath = "" + +# downloader +server.downloadAsCbz = ${DOWNLOAD_AS_CBZ:-false} +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} + +# Authentication +server.basicAuthEnabled = ${BASIC_AUTH_ENABLED:-false} +server.basicAuthUsername = "${BASIC_AUTH_USERNAME}" +server.basicAuthPassword = "${BASIC_AUTH_PASSWORD}" + +# misc +server.debugLogsEnabled = ${DEBUG:-true} +server.systemTrayEnabled = false # always disabled as we are in a headless container diff --git a/startup_script.sh b/startup_script.sh index 41d3a58..cb324e6 100755 --- a/startup_script.sh +++ b/startup_script.sh @@ -1,18 +1,11 @@ #!/bin/sh -if [ ! -f /home/suwayomi/.local/share/Tachidesk/docker_touchfile ]; then - touch /home/suwayomi/.local/share/Tachidesk/docker_touchfile - curl -s --create-dirs -L https://raw.githubusercontent.com/Suwayomi/docker-tachidesk/main/server.conf -o /home/suwayomi/.local/share/Tachidesk/server.conf; + +set -euo 'pipefail' + +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 -echo "" -echo "" -echo " ************README***********" -echo "-> It is essential that u read readme for ghcr.io/suwayomi/tachidesk before running this container" -echo "-> Readme for ghcr.io/suwayomi/tachidesk is available at https://github.com/suwayomi/docker-tachidesk " -echo " *****************************" -echo "" -echo "" -echo "Tachidesk data location inside the container -> /home/suwayomi/.local/share/Tachidesk" -echo "" -echo "The server is running by default configuration on http://localhost:4567" exec java -jar "/home/suwayomi/startup/tachidesk_latest.jar";