From 13a146a98547d7a1e77ca0a9c3d29dd9016e20b0 Mon Sep 17 00:00:00 2001 From: Colin Hebert Date: Mon, 26 Dec 2022 15:29:01 +0100 Subject: [PATCH] Add entrypoint to gotify/data --- mounts/.gitignore | 1 + mounts/gotify/data/.gitignore | 1 + mounts/gotify/data/entrypoint.sh | 28 ++++++++++++++++++++++++++++ notifications.docker-compose.yml | 9 +-------- 4 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 mounts/gotify/data/.gitignore create mode 100755 mounts/gotify/data/entrypoint.sh diff --git a/mounts/.gitignore b/mounts/.gitignore index f959920..9c53395 100644 --- a/mounts/.gitignore +++ b/mounts/.gitignore @@ -2,3 +2,4 @@ !*/data/README.md */secrets/* !*/secrets/README.md +!.gitignore diff --git a/mounts/gotify/data/.gitignore b/mounts/gotify/data/.gitignore new file mode 100644 index 0000000..260859d --- /dev/null +++ b/mounts/gotify/data/.gitignore @@ -0,0 +1 @@ +!entrypoint.sh \ No newline at end of file diff --git a/mounts/gotify/data/entrypoint.sh b/mounts/gotify/data/entrypoint.sh new file mode 100755 index 0000000..784aeca --- /dev/null +++ b/mounts/gotify/data/entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# 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 85dc28c..d9e1ee8 100644 --- a/notifications.docker-compose.yml +++ b/notifications.docker-compose.yml @@ -3,15 +3,12 @@ name: Notifications services: gotify: image: gotify/server - entrypoint: ./entrypoint.sh + entrypoint: ./data/entrypoint.sh networks: - gotify - traefik volumes: - gotify:/app/data - configs: - - source: gotify_entrypoint - target: /app/entrypoint.sh secrets: - admin_password restart: unless-stopped @@ -32,10 +29,6 @@ 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