diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..30a37e0e
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,7 @@
+.git
+.gitignore
+
+.dockerignore
+Dockerfile
+
+target
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..ad970576
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,22 @@
+# Use a multistage build to first build the pipeline using maven. Then
+# copy the artifacts into a final image which exposes the port and
+# starts the pipeline.
+
+# Build the pipeline first
+FROM maven:3.5-jdk-8 as builder
+ADD . /usr/src/daisy-pipeline2
+WORKDIR /usr/src/daisy-pipeline2
+RUN mvn clean package
+
+# then use the build artifacts to create an image where the pipeline is installed
+FROM openjdk:8-jre
+LABEL maintainer="DAISY Consortium (http://www.daisy.org/)"
+COPY --from=builder /usr/src/daisy-pipeline2/target/pipeline2-*_linux/daisy-pipeline /opt/daisy-pipeline2
+ENV PIPELINE2_LOCAL=false \
+ PIPELINE2_AUTH=true \
+ PIPELINE2_WS_AUTHENTICATION_KEY=clientid \
+ PIPELINE2_WS_AUTHENTICATION_SECRET=sekret
+EXPOSE 8181
+# for the healthcheck use PIPELINE2_HOST if defined. Otherwise use localhost
+HEALTHCHECK --interval=30s --timeout=10s --start-period=1m CMD curl --fail http://${PIPELINE2_WS_HOST-localhost}:${PIPELINE2_WS_PORT:-8181}/${PIPELINE2_WS_PATH:-ws}/alive || exit 1
+ENTRYPOINT ["/opt/daisy-pipeline2/bin/pipeline2"]
diff --git a/Dockerfile.without_builder b/Dockerfile.without_builder
new file mode 100644
index 00000000..fcd6d952
--- /dev/null
+++ b/Dockerfile.without_builder
@@ -0,0 +1,9 @@
+FROM openjdk:8-jre
+LABEL maintainer="DAISY Consortium (http://www.daisy.org/)"
+ADD target/pipeline2-*_linux/daisy-pipeline /opt/daisy-pipeline2
+ENV PIPELINE2_LOCAL=false \
+ PIPELINE2_AUTH=true \
+ PIPELINE2_WS_AUTHENTICATION_KEY=clientid \
+ PIPELINE2_WS_AUTHENTICATION_SECRET=sekret
+EXPOSE 8181
+ENTRYPOINT ["/opt/daisy-pipeline2/bin/pipeline2"]
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..ab7b531c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,15 @@
+help :
+ echo "make docker:" >&2
+ echo " Build a Docker image" >&2
+ echo "make check-docker:" >&2
+ echo " Test the Docker image" >&2
+
+docker :
+ gtar -cz \
+ target/pipeline2-*_linux \
+ Dockerfile.without_builder \
+ --transform='s/Dockerfile.without_builder/Dockerfile/' \
+ | docker build -t daisyorg/pipeline2 -
+
+check-docker :
+ bash src/test/resources/test-docker-image.sh
diff --git a/pom.xml b/pom.xml
index 9996e62b..14f1f47d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
org.daisy.pipeline
framework-bom
- 1.10.4
+ 1.10.5-SNAPSHOT
pom
import
@@ -2821,102 +2821,6 @@ rm -rf /opt/daisy-pipeline2/cli
-
- webui
-
-
-
- maven-dependency-plugin
-
-
- unpack
- package
-
- unpack
-
-
-
-
- org.daisy.pipeline
- webui-desktop
- 1.8.1
- zip
- true
- target/webui
-
-
- false
- true
-
-
-
-
-
- maven-assembly-plugin
-
-
- dist-webui-mac
- package
-
- single
-
-
- false
-
- src/main/assembly/webui-mac.xml
-
-
- src/main/assembly/dist.properties
- src/main/assembly/dist-nix.properties
-
- false
- pipeline2-${project.version}-webui_mac
-
-
-
- dist-webui-linux
- package
-
- single
-
-
- false
-
- src/main/assembly/webui-linux.xml
-
-
- src/main/assembly/dist.properties
- src/main/assembly/dist-nix.properties
-
- false
- pipeline2-${project.version}-webui_linux
-
-
-
- dist-webui-win
- package
-
- single
-
-
- false
-
- src/main/assembly/webui-win.xml
-
-
- src/main/assembly/dist.properties
- src/main/assembly/dist-win.properties
-
- false
- pipeline2-${project.version}-webui_windows
-
-
-
-
-
-
-
-
-
- target/webui/daisy-pipeline-webui
-
- uninstall
- uninstall.bat
- start
- start.bat
-
- /webui
-
-
-
-
- target/webui/daisy-pipeline-webui
-
- uninstall
- uninstall.bat
- start
- start.bat
-
- 0755
- /webui
-
-
-
-
diff --git a/src/main/assembly/webui-linux.xml b/src/main/assembly/webui-linux.xml
deleted file mode 100644
index e2be257c..00000000
--- a/src/main/assembly/webui-linux.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- webui-linux
-
- zip
- dir
-
- daisy-pipeline
-
- src/main/assembly/components/base.xml
- src/main/assembly/components/framework.xml
- src/main/assembly/components/cli-linux.xml
- src/main/assembly/components/modules-linux.xml
- src/main/assembly/components/webui.xml
-
-
diff --git a/src/main/assembly/webui-mac.xml b/src/main/assembly/webui-mac.xml
deleted file mode 100644
index 0756f958..00000000
--- a/src/main/assembly/webui-mac.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- webui-mac
-
- zip
- dir
-
- daisy-pipeline
-
- src/main/assembly/components/base.xml
- src/main/assembly/components/framework.xml
- src/main/assembly/components/cli-mac.xml
- src/main/assembly/components/modules-mac.xml
- src/main/assembly/components/webui.xml
-
-
diff --git a/src/main/assembly/webui-win.xml b/src/main/assembly/webui-win.xml
deleted file mode 100644
index ce91c019..00000000
--- a/src/main/assembly/webui-win.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- webui-win
-
- zip
- dir
-
- daisy-pipeline
-
- src/main/assembly/components/base.xml
- src/main/assembly/components/framework.xml
- src/main/assembly/components/cli-win.xml
- src/main/assembly/components/modules-win.xml
- src/main/assembly/components/webui.xml
-
-
diff --git a/src/main/deb/etc/default/daisy-pipeline2 b/src/main/deb/etc/default/daisy-pipeline2
index 7a37b001..b40d2fe5 100644
--- a/src/main/deb/etc/default/daisy-pipeline2
+++ b/src/main/deb/etc/default/daisy-pipeline2
@@ -1,7 +1,8 @@
# Configuration file for /etc/init.d/daisy-pipeline2
-# Execute pipeline in remote mode
-#REMOTE=true
+# Execute pipeline in remote mode and with authentication
+#export PIPELINE2_WS_LOCALFS=true
+#export PIPELINE2_WS_AUTHENTICATION=false
# Java heap size
#export JAVA_MIN_MEM=256M
diff --git a/src/main/deb/etc/init.d/daisy-pipeline2 b/src/main/deb/etc/init.d/daisy-pipeline2
index 4f69c9b0..da3f31fd 100755
--- a/src/main/deb/etc/init.d/daisy-pipeline2
+++ b/src/main/deb/etc/init.d/daisy-pipeline2
@@ -27,11 +27,6 @@ SCRIPTNAME=/etc/init.d/$NAME
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
-# Set daemon argument list
-if [ "$REMOTE" = "true" ]; then
- DAEMON_ARGS="remote"
-fi
-
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
diff --git a/src/main/resources/bin/pipeline2 b/src/main/resources/bin/pipeline2
index c1c07005..cccaf878 100755
--- a/src/main/resources/bin/pipeline2
+++ b/src/main/resources/bin/pipeline2
@@ -354,24 +354,11 @@ init() {
}
run() {
- if [ "x$PIPELINE2_AUTH" = "x" ]; then
- PIPELINE2_AUTH="-Dorg.daisy.pipeline.ws.authentication=false"
- export PIPELINE2_AUTH
- else
- PIPELINE2_AUTH="-Dorg.daisy.pipeline.ws.authentication=$PIPELINE2_AUTH"
- export PIPELINE2_AUTH
-
- fi
- if [ "x$PIPELINE2_LOCAL" = "x" ]; then
- PIPELINE2_LOCAL="-Dorg.daisy.pipeline.ws.localfs=true"
- export PIPELINE2_LOCAL
- else
- PIPELINE2_LOCAL="-Dorg.daisy.pipeline.ws.localfs=$PIPELINE2_LOCAL"
- export PIPELINE2_LOCAL
+ # set defaults
+ PIPELINE2_WS_LOCALFS=true
+ PIPELINE2_WS_AUTHENTICATION=false
- fi
MAIN=org.apache.felix.main.Main
- OPTS="$PIPELINE2_LOCAL $PIPELINE2_AUTH"
MODE=" -Dorg.daisy.pipeline.main.mode=webservice"
case "$1" in
@@ -383,11 +370,13 @@ run() {
# shift
# ;;
'remote')
- OPTS="-Dorg.daisy.pipeline.ws.localfs=false -Dorg.daisy.pipeline.ws.authentication=true"
+ PIPELINE2_LOCALFS=false
+ PIPELINE2_AUTH=true
shift
;;
'local')
- OPTS="-Dorg.daisy.pipeline.ws.localfs=true -Dorg.daisy.pipeline.ws.authentication=false"
+ PIPELINE2_LOCALFS=true
+ PIPELINE2_AUTH=false
shift
;;
'clean')
@@ -437,7 +426,13 @@ run() {
fi
cd "$PIPELINE2_BASE"
- eval exec "\"$JAVA"\" "$JAVA_OPTS" -Djava.endorsed.dirs="\"${JAVA_ENDORSED_DIRS}"\" -Djava.ext.dirs="\"${JAVA_EXT_DIRS}"\" -Dorg.daisy.pipeline.home="\"$PIPELINE2_HOME"\" -Dorg.daisy.pipeline.base="\"$PIPELINE2_BASE"\" -Dorg.daisy.pipeline.data="\"$PIPELINE2_DATA"\" -Dfelix.config.properties="\"file:$PIPELINE2_HOME/etc/config.properties"\" -Dfelix.system.properties="\"file:$PIPELINE2_CONFIG/system.properties"\" $FELIX_OPTS $PIPELINE2_OPTS $OPTS $MODE -classpath "\"$CLASSPATH"\" $MAIN "\"$@"\"
+ export PIPELINE2_HOME
+ export PIPELINE2_BASE
+ export PIPELINE2_DATA
+ export PIPELINE2_WS_LOCALFS
+ export PIPELINE2_WS_AUTHENTICATION
+
+ eval exec "\"$JAVA"\" "$JAVA_OPTS" -Djava.endorsed.dirs="\"${JAVA_ENDORSED_DIRS}"\" -Djava.ext.dirs="\"${JAVA_EXT_DIRS}"\" -Dfelix.config.properties="\"file:$PIPELINE2_HOME/etc/config.properties"\" -Dfelix.system.properties="\"file:$PIPELINE2_CONFIG/system.properties"\" $FELIX_OPTS $MODE -classpath "\"$CLASSPATH"\" $MAIN "\"$@"\"
}
main() {
diff --git a/src/test/resources/test-docker-image.sh b/src/test/resources/test-docker-image.sh
new file mode 100755
index 00000000..80308f66
--- /dev/null
+++ b/src/test/resources/test-docker-image.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+
+# This test starts the pipeline inside a Docker container and then
+# starts the dtbook-to-epub3 script using the cli inside a second
+# container
+
+set -e
+cd $(dirname "$0")
+
+# download test DTBook from https://github.com/daisy/pipeline-samples
+DATA_DIR=../../../target/test-docker/data
+mkdir -p $DATA_DIR
+cd $DATA_DIR
+DTBOOK=hauy_valid.xml
+DATA=$(basename $DTBOOK).zip
+rm -f $DATA
+for f in \
+ $DTBOOK \
+ dtbook.2005.basic.css \
+ valentin.jpg
+do
+ curl https://raw.githubusercontent.com/daisy/pipeline-samples/10bbb8e/dtbook/$f 2>/dev/null >$f
+ zip $DATA $f
+done
+
+CLIENTKEY=clientid
+CLIENTSECRET=sekret
+MOUNT_POINT=/mnt
+
+# run the pipeline
+docker run --name pipeline --detach \
+ -e PIPELINE2_WS_HOST=0.0.0.0 \
+ -e PIPELINE2_AUTH=true \
+ -e PIPELINE2_WS_AUTHENTICATION_KEY=$CLIENTKEY \
+ -e PIPELINE2_WS_AUTHENTICATION_SECRET=$CLIENTSECRET \
+ -p 8181:8181 daisyorg/pipeline2
+
+# wait for the pipeline to start
+sleep 5
+while ! curl localhost:8181/ws/alive >/dev/null 2>/dev/null; do
+ echo "Waiting for web service to be up..." >&2
+ sleep 2
+done
+
+# run the cli
+docker run --name cli --rm -it --link pipeline \
+ --entrypoint /opt/daisy-pipeline2/cli/dp2 \
+ --volume="$(pwd):$MOUNT_POINT:rw" \
+ daisyorg/pipeline2 \
+ --host http://pipeline \
+ --starting false \
+ --client_key $CLIENTKEY \
+ --client_secret $CLIENTSECRET \
+ dtbook-to-epub3 --source $DTBOOK --output $MOUNT_POINT --data $MOUNT_POINT/$DATA --persistent
+# help dtbook-to-epub3
+# dtbook-validator --input-dtbook $DTBOOK --output $MOUNT_POINT --data $MOUNT_POINT/$DATA
+
+docker stop pipeline
+docker rm pipeline
+