From f61d9f148906e96841d673809e7f93fb274e3d76 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Sat, 22 Jul 2017 17:04:31 +0200 Subject: [PATCH 1/5] Add project official docker image. Tag for docker image is set from project version. To build docker image for the project run: - mvn package - mvn -N dockerfile:build Created docker image can be uploaded to the docker hub: - mvn -N dockerfile:push Signed-off-by: Yahor Berdnikau --- .dockerignore | 15 +++++++++++++++ Dockerfile | 27 +++++++++++++++++++++++++++ dockerfiles/run.sh | 19 +++++++++++++++++++ pom.xml | 10 ++++++++++ 4 files changed, 71 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 dockerfiles/run.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..82f10424 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +*.md +*.xml +*.yml +*.txt +*.html + +.gitignore +.git/ +contrib/ +airsonic-main/ +!airsonic-main/target/airsonic.war +subsonic-rest-api/ +airsonic-sonos-api/ +repo/ +target/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..333b094e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,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 + +WORKDIR $AIRSONIC_DIR + +COPY dockerfiles/run.sh /usr/local/bin/run.sh +COPY airsonic-main/target/airsonic.war airsonic.war + +RUN apk --no-cache add \ + ffmpeg \ + lame \ + su-exec \ + libressl \ + ca-certificates \ + tini \ + openjdk8-jre \ + && chmod +x /usr/local/bin/run.sh + +EXPOSE $AIRSONIC_PORT + +VOLUME $AIRSONIC_DIR/data $AIRSONIC_DIR/music $AIRSONIC_DIR/playlists $AIRSONIC_DIR/podcasts + +ENTRYPOINT ["run.sh"] diff --git a/dockerfiles/run.sh b/dockerfiles/run.sh new file mode 100755 index 00000000..1c40268b --- /dev/null +++ b/dockerfiles/run.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +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 + +chown -R $UID:$GID $AIRSONIC_DIR/data $AIRSONIC_DIR/playlists $AIRSONIC_DIR/podcasts + +exec su-exec $UID:$GID tini -- \ + java -Xmx256m \ + -Dserver.host=0.0.0.0 \ + -Dserver.port=$AIRSONIC_PORT \ + -Dserver.contextPath=/ \ + -Dairsonic.home=$AIRSONIC_DIR/data \ + -Dairsonic.defaultMusicFolder=$AIRSONIC_DIR/musics \ + -Dairsonic.defaultPodcastFolder=$AIRSONIC_DIR/podcasts \ + -Dairsonic.defaultPlaylistFolder=$AIRSONIC_DIR/playlists \ + -Djava.awt.headless=true \ + -jar airsonic.war diff --git a/pom.xml b/pom.xml index eecf0c0c..c4c59c82 100644 --- a/pom.xml +++ b/pom.xml @@ -169,6 +169,16 @@ + + com.spotify + dockerfile-maven-plugin + 1.3.4 + false + + airsonic/airsonic + ${project.version} + + From 86345a9c2c2305c90ea4aae88ac6dcf3d0b6716e Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Thu, 3 Aug 2017 17:01:21 -0600 Subject: [PATCH 2/5] Moved docker to its own module Signed-off-by: Andrew DeMaria --- .dockerignore | 15 ------ install/docker/.dockerignore | 4 ++ Dockerfile => install/docker/Dockerfile | 2 +- install/docker/pom.xml | 61 +++++++++++++++++++++++++ {dockerfiles => install/docker}/run.sh | 0 pom.xml | 11 +---- 6 files changed, 67 insertions(+), 26 deletions(-) delete mode 100644 .dockerignore create mode 100644 install/docker/.dockerignore rename Dockerfile => install/docker/Dockerfile (90%) create mode 100644 install/docker/pom.xml rename {dockerfiles => install/docker}/run.sh (100%) diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 82f10424..00000000 --- a/.dockerignore +++ /dev/null @@ -1,15 +0,0 @@ -*.md -*.xml -*.yml -*.txt -*.html - -.gitignore -.git/ -contrib/ -airsonic-main/ -!airsonic-main/target/airsonic.war -subsonic-rest-api/ -airsonic-sonos-api/ -repo/ -target/ diff --git a/install/docker/.dockerignore b/install/docker/.dockerignore new file mode 100644 index 00000000..62ed4a05 --- /dev/null +++ b/install/docker/.dockerignore @@ -0,0 +1,4 @@ +!target/airsonic.war +.gitignore +pom.xml +target/ diff --git a/Dockerfile b/install/docker/Dockerfile similarity index 90% rename from Dockerfile rename to install/docker/Dockerfile index 333b094e..77be01af 100644 --- a/Dockerfile +++ b/install/docker/Dockerfile @@ -8,7 +8,7 @@ ENV UID=1001 GID=1001 AIRSONIC_PORT=4040 AIRSONIC_DIR=/airsonic WORKDIR $AIRSONIC_DIR COPY dockerfiles/run.sh /usr/local/bin/run.sh -COPY airsonic-main/target/airsonic.war airsonic.war +COPY target/dependency/airsonic-main-6.3-SNAPSHOT.war airsonic.war RUN apk --no-cache add \ ffmpeg \ diff --git a/install/docker/pom.xml b/install/docker/pom.xml new file mode 100644 index 00000000..5d22b330 --- /dev/null +++ b/install/docker/pom.xml @@ -0,0 +1,61 @@ + + + + 4.0.0 + + ../../pom.xml + airsonic + 6.3-SNAPSHOT + org.airsonic.player + + pom + airsonic-docker + Airsonic Docker Image + + + + org.airsonic.player + airsonic-main + 6.3-SNAPSHOT + war + + + + + + + com.spotify + dockerfile-maven-plugin + 1.3.4 + + + default + + build + + package + + + + airsonic/airsonic + ${project.version} + + + + maven-dependency-plugin + org.apache.maven.plugins + 3.0.1 + + + copy + generate-sources + + copy-dependencies + + + + + + + + diff --git a/dockerfiles/run.sh b/install/docker/run.sh similarity index 100% rename from dockerfiles/run.sh rename to install/docker/run.sh diff --git a/pom.xml b/pom.xml index c4c59c82..910d636b 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,7 @@ subsonic-rest-api airsonic-sonos-api airsonic-main + install/docker @@ -169,16 +170,6 @@ - - com.spotify - dockerfile-maven-plugin - 1.3.4 - false - - airsonic/airsonic - ${project.version} - - From 615f7eb1c4e85aa8ccbb79766214bcf6eb145f95 Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Thu, 3 Aug 2017 17:19:29 -0600 Subject: [PATCH 3/5] Moved docker to profile Signed-off-by: Andrew DeMaria --- pom.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 910d636b..f53ff7bc 100644 --- a/pom.xml +++ b/pom.xml @@ -78,7 +78,6 @@ subsonic-rest-api airsonic-sonos-api airsonic-main - install/docker @@ -222,4 +221,16 @@ + + + + docker + + subsonic-rest-api + airsonic-sonos-api + airsonic-main + install/docker + + + From e1ecc2444cb120c6c5cafe0a4c2926fa14368fe5 Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Thu, 3 Aug 2017 21:20:23 -0600 Subject: [PATCH 4/5] Refactored dockerfile Signed-off-by: Andrew DeMaria --- install/docker/.dockerignore | 2 +- install/docker/Dockerfile | 18 ++++++++++-------- install/docker/pom.xml | 1 + install/docker/run.sh | 23 ++++++++++++++++------- 4 files changed, 28 insertions(+), 16 deletions(-) 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 "$@" From 3132227590ee2f7699903a5a5e18ac905b41deaf Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Fri, 4 Aug 2017 14:11:56 -0600 Subject: [PATCH 5/5] Made dockerfile non version specific Signed-off-by: Andrew DeMaria --- install/docker/Dockerfile | 2 +- install/docker/pom.xml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/install/docker/Dockerfile b/install/docker/Dockerfile index 965a0540..dea28398 100644 --- a/install/docker/Dockerfile +++ b/install/docker/Dockerfile @@ -20,7 +20,7 @@ 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 +COPY target/dependency/airsonic-main.war airsonic.war EXPOSE $AIRSONIC_PORT diff --git a/install/docker/pom.xml b/install/docker/pom.xml index 892c1288..bea30e32 100644 --- a/install/docker/pom.xml +++ b/install/docker/pom.xml @@ -46,6 +46,10 @@ maven-dependency-plugin org.apache.maven.plugins 3.0.1 + + true + true + copy