diff --git a/install/docker/.dockerignore b/install/docker/.dockerignore index 62ed4a05..f474ef49 100644 --- a/install/docker/.dockerignore +++ b/install/docker/.dockerignore @@ -1,4 +1,4 @@ -!target/airsonic.war .gitignore pom.xml target/ +!target/dependency/* diff --git a/install/docker/Dockerfile b/install/docker/Dockerfile index 77be01af..965a0540 100644 --- a/install/docker/Dockerfile +++ b/install/docker/Dockerfile @@ -3,25 +3,27 @@ FROM alpine:3.6 LABEL description="Airsonic is a free, web-based media streamer, providing ubiquitious access to your music." \ url="https://github.com/airsonic/airsonic" -ENV UID=1001 GID=1001 AIRSONIC_PORT=4040 AIRSONIC_DIR=/airsonic +ENV AIRSONIC_PORT=4040 AIRSONIC_DIR=/airsonic WORKDIR $AIRSONIC_DIR -COPY dockerfiles/run.sh /usr/local/bin/run.sh -COPY target/dependency/airsonic-main-6.3-SNAPSHOT.war airsonic.war - RUN apk --no-cache add \ ffmpeg \ lame \ - su-exec \ + bash \ libressl \ ca-certificates \ tini \ - openjdk8-jre \ - && chmod +x /usr/local/bin/run.sh + openjdk8-jre + +COPY run.sh /usr/local/bin/run.sh + +RUN chmod +x /usr/local/bin/run.sh + +COPY target/dependency/airsonic-main-6.3-SNAPSHOT.war airsonic.war EXPOSE $AIRSONIC_PORT VOLUME $AIRSONIC_DIR/data $AIRSONIC_DIR/music $AIRSONIC_DIR/playlists $AIRSONIC_DIR/podcasts -ENTRYPOINT ["run.sh"] +ENTRYPOINT ["tini", "--", "run.sh"] diff --git a/install/docker/pom.xml b/install/docker/pom.xml index 5d22b330..892c1288 100644 --- a/install/docker/pom.xml +++ b/install/docker/pom.xml @@ -39,6 +39,7 @@ airsonic/airsonic ${project.version} + 0 diff --git a/install/docker/run.sh b/install/docker/run.sh index 1c40268b..21fc3bfd 100755 --- a/install/docker/run.sh +++ b/install/docker/run.sh @@ -1,13 +1,18 @@ -#!/bin/sh +#!/bin/bash + +set -e mkdir -p $AIRSONIC_DIR/data/transcode -ln -s /usr/bin/ffmpeg $AIRSONIC_DIR/data/transcode/ffmpeg -ln -s /usr/bin/lame $AIRSONIC_DIR/data/transcode/lame +ln -fs /usr/bin/ffmpeg $AIRSONIC_DIR/data/transcode/ffmpeg +ln -fs /usr/bin/lame $AIRSONIC_DIR/data/transcode/lame -chown -R $UID:$GID $AIRSONIC_DIR/data $AIRSONIC_DIR/playlists $AIRSONIC_DIR/podcasts +if [[ $# -lt 1 ]] || [[ ! "$1" == "java"* ]]; then -exec su-exec $UID:$GID tini -- \ - java -Xmx256m \ + java_opts_array=() + while IFS= read -r -d '' item; do + java_opts_array+=( "$item" ) + done < <([[ $JAVA_OPTS ]] && xargs printf '%s\0' <<<"$JAVA_OPTS") + exec java -Xmx256m \ -Dserver.host=0.0.0.0 \ -Dserver.port=$AIRSONIC_PORT \ -Dserver.contextPath=/ \ @@ -16,4 +21,8 @@ exec su-exec $UID:$GID tini -- \ -Dairsonic.defaultPodcastFolder=$AIRSONIC_DIR/podcasts \ -Dairsonic.defaultPlaylistFolder=$AIRSONIC_DIR/playlists \ -Djava.awt.headless=true \ - -jar airsonic.war + "${java_opts_array[@]}" \ + -jar airsonic.war "$@" +fi + +exec "$@"