From 3372cec31cf735eb416da7fc4a303d5899f10370 Mon Sep 17 00:00:00 2001 From: Tuschl Date: Sun, 8 Jan 2023 23:33:03 +0100 Subject: [PATCH 1/2] Fix shellcheck warning SC2027 about mis-quoted var --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 12d7ab7..5b54a6a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -50,7 +50,7 @@ exec /bin/su -s /bin/bash -c "${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \ -Dsubsonic.port=${SUBSONIC_PORT} \ -Dsubsonic.httpsPort=${SUBSONIC_HTTPS_PORT} \ -Dsubsonic.contextPath=${SUBSONIC_CONTEXT_PATH} \ - -Dsubsonic.db="${SUBSONIC_DB}" \ + -Dsubsonic.db=\"${SUBSONIC_DB}\" \ -Dsubsonic.defaultMusicFolder=${SUBSONIC_DEFAULT_MUSIC_FOLDER} \ -Dsubsonic.defaultPodcastFolder=${SUBSONIC_DEFAULT_PODCAST_FOLDER} \ -Dsubsonic.defaultPlaylistFolder=${SUBSONIC_DEFAULT_PLAYLIST_FOLDER} \ From e67862db13c5bd3b902c330f994016fa6769b42f Mon Sep 17 00:00:00 2001 From: Tuschl Date: Sun, 8 Jan 2023 23:25:41 +0100 Subject: [PATCH 2/2] Move env var definitions to Dockerfile Moving the env var definitions into the Dockerfile makes it IMHO clearer that these variables are in fact part of the image's "API". This also enables discovering the vars with `docker inspect`, without looking into the image's entrypoint script. Another side effect is, that we can avoid code duplication of default values (e.g. port). This is not a big deal, but could help with future additions. --- Dockerfile | 16 +++++++++++++--- entrypoint.sh | 13 ------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 75b9530..e47113f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,19 @@ FROM ubuntu:latest -LABEL version="1.1" maintainer="John Stucklen " +LABEL version="1.2" maintainer="John Stucklen " ENV LC_ALL en_US.UTF-8 ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en +ENV SUBSONIC_HOME /var/subsonic +ENV SUBSONIC_HOST 0.0.0.0 +ENV SUBSONIC_PORT 4040 +ENV SUBSONIC_HTTPS_PORT 0 +ENV SUBSONIC_CONTEXT_PATH / +ENV SUBSONIC_DB "" +ENV SUBSONIC_MAX_MEMORY 150 +ENV SUBSONIC_DEFAULT_MUSIC_FOLDER /var/music +ENV SUBSONIC_DEFAULT_PODCAST_FOLDER /var/music/Podcast +ENV SUBSONIC_DEFAULT_PLAYLIST_FOLDER /var/playlists ENV SUBSONIC_UID 1000 ENV SUBSONIC_GID 1000 @@ -29,8 +39,8 @@ COPY entrypoint.sh /opt/subsonic/entrypoint.sh WORKDIR /opt/subsonic -VOLUME [ "/var/music", "/var/playlists", "/var/subsonic" ] +VOLUME $SUBSONIC_DEFAULT_MUSIC_FOLDER $SUBSONIC_DEFAULT_PLAYLIST_FOLDER $SUBSONIC_HOME -EXPOSE 4040/tcp +EXPOSE $SUBSONIC_PORT/tcp ENTRYPOINT [ "/opt/subsonic/entrypoint.sh" ] diff --git a/entrypoint.sh b/entrypoint.sh index 5b54a6a..b686126 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,19 +5,6 @@ set -e # This is a replacement for subsonic.sh that comes with subsonic as it is not docker friendly # This will properly NOT daemonize the java process and will log to stdout / stderr. -# Note: default to environment variables, if set. - -SUBSONIC_HOME=${SUBSONIC_HOME:-/var/subsonic} -SUBSONIC_HOST=${SUBSONIC_HOST:-0.0.0.0} -SUBSONIC_PORT=${SUBSONIC_PORT:-4040} -SUBSONIC_HTTPS_PORT=${SUBSONIC_HTTPS_PORT:-0} -SUBSONIC_CONTEXT_PATH=${SUBSONIC_CONTEXT_PATH:-/} -SUBSONIC_DB=${SUBSONIC_DB} -SUBSONIC_MAX_MEMORY=${SUBSONIC_MAX_MEMORY:-150} -SUBSONIC_DEFAULT_MUSIC_FOLDER=${SUBSONIC_DEFAULT_MUSIC_FOLDER:-/var/music} -SUBSONIC_DEFAULT_PODCAST_FOLDER=${SUBSONIC_DEFAULT_PODCAST_FOLDER:-/var/music/Podcast} -SUBSONIC_DEFAULT_PLAYLIST_FOLDER=${SUBSONIC_DEFAULT_PLAYLIST_FOLDER:-/var/playlists} - # Create subsonic user, taking uid, gid and homedir from (Docker) environment if ! id -g subsonic > /dev/null 2>&1; then groupadd --system -o --gid "$SUBSONIC_GID" subsonic