From d9f7f506b863f4cb9aeabf829313c571070358a5 Mon Sep 17 00:00:00 2001 From: Colin Hebert Date: Mon, 26 Dec 2022 15:02:28 +0100 Subject: [PATCH] Entrypoint for the auto-conf --- mounts/gotify/config/entrypoint.sh | 28 ++++++++++++++++++++++++++++ notifications.docker-compose.yml | 12 +++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100755 mounts/gotify/config/entrypoint.sh diff --git a/mounts/gotify/config/entrypoint.sh b/mounts/gotify/config/entrypoint.sh new file mode 100755 index 0000000..8e38800 --- /dev/null +++ b/mounts/gotify/config/entrypoint.sh @@ -0,0 +1,28 @@ +#/bin/sh + +# usage: file_env VAR [DEFAULT] +# ie: file_env 'XYZ_DB_PASSWORD' 'example' +# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of +# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + mysql_error "Both $var and $fileVar are set (but are exclusive)" + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + +cd /app + +file_env 'GOTIFY_DEFAULTUSER_PASS' + +./gotify-app "$@" diff --git a/notifications.docker-compose.yml b/notifications.docker-compose.yml index 93e9a21..85dc28c 100644 --- a/notifications.docker-compose.yml +++ b/notifications.docker-compose.yml @@ -3,13 +3,15 @@ name: Notifications services: gotify: image: gotify/server - # Hack to get around the lack of secret support in Gotify - entrypoint: ['/bin/sh', '-c', 'GOTIFY_DEFAULTUSER_PASS=$(cat /run/secrets/admin_password) ./gotify-app'] + entrypoint: ./entrypoint.sh networks: - gotify - traefik volumes: - gotify:/app/data + configs: + - source: gotify_entrypoint + target: /app/entrypoint.sh secrets: - admin_password restart: unless-stopped @@ -30,6 +32,10 @@ volumes: o: bind device: ${MOUNT_DIR?}/gotify/data/ +configs: + gotify_entrypoint: + file: ${MOUNT_DIR?}/gotify/config/entrypoint.sh + secrets: admin_password: - file: ${MOUNT_DIR?}/gotify/secrets/admin_password \ No newline at end of file + file: ${MOUNT_DIR?}/gotify/secrets/admin_password