From 10cc499ab37d3fca58e3e9dc3007fb8979574667 Mon Sep 17 00:00:00 2001 From: jeanluc Date: Tue, 5 Jul 2022 23:58:48 +0200 Subject: [PATCH] Use variable for datastore in Docker entrypoint --- Dockerfile | 3 ++- docker-entrypoint.sh | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fc42e575..6b0691d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,7 +62,8 @@ RUN sed -i 's/^CipherString = .*/CipherString = DEFAULT@SECLEVEL=1/' /etc/ssl/op # Copy modules over to the final image and add their dir to PYTHONPATH COPY --from=builder /dependencies /usr/local -ENV PYTHONPATH=/usr/local +ENV PYTHONPATH=/usr/local \ + DATASTORE_DIR="/datastore" EXPOSE 5000 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index c1726f39..42ed48a1 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,9 +2,11 @@ set -eu +DATASTORE_DIR="${DATASTORE_DIR:-/datastore}" + # If the first argument looks like a flag, assume we want to run changedetection if [ "${1:0:1}" = '-' ]; then - set -- python ./changedetection.py -d /datastore "$@" + set -- python ./changedetection.py -d "$DATASTORE_DIR" "$@" fi # If we're running as root, by default make sure process uid/gid @@ -18,7 +20,7 @@ if [ "$(id -u)" = '0' -a -n "${KEEP_PRIVILEGES:-}" ]; then usermod -o -u "$PUID" changedetection # Look for files in datadir not owned by the correct user and chown them - find "/datastore" \! -user changedetection -exec chown changedetection '{}' + + find "$DATASTORE_DIR" \! -user changedetection -exec chown changedetection '{}' + # Restart this script as an unprivileged user exec gosu changedetection:changedetection "$BASH_SOURCE" "$@"