Entrypoint for the auto-conf

This commit is contained in:
Colin Hebert
2022-12-26 15:02:28 +01:00
parent 5a4fea851f
commit d9f7f506b8
2 changed files with 37 additions and 3 deletions

View File

@@ -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 "$@"

View File

@@ -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
file: ${MOUNT_DIR?}/gotify/secrets/admin_password