From 7ec23080536a7ca1915ba566d1e6915d53a5c01f Mon Sep 17 00:00:00 2001 From: Kelson Date: Thu, 16 Jan 2020 14:03:33 +0100 Subject: [PATCH] Add ability to download a file at container start --- docker/server/Dockerfile | 5 ++++- docker/server/README.md | 17 +++++++++++++++-- docker/server/start.sh | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100755 docker/server/start.sh diff --git a/docker/server/Dockerfile b/docker/server/Dockerfile index 2174f53..4beb956 100644 --- a/docker/server/Dockerfile +++ b/docker/server/Dockerfile @@ -12,4 +12,7 @@ RUN curl -kL https://download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-x8 EXPOSE 80 VOLUME /data WORKDIR /data -ENTRYPOINT ["/usr/local/bin/kiwix-serve", "--port", "80"] + +COPY ./start.sh /usr/local/bin/ + +ENTRYPOINT ["/usr/local/bin/start.sh"] diff --git a/docker/server/README.md b/docker/server/README.md index 9e3d148..05ed109 100644 --- a/docker/server/README.md +++ b/docker/server/README.md @@ -1,13 +1,26 @@ -kiwix-serve Docker image +Kiwix serve Docker image ======================== +Use with local ZIM file +----------------------- + * Download a ZIM file from * Given `wikipedia.zim` resides in `/tmp/zim/`, execute the following: -``` +```bash docker run -v /tmp/zim:/data -p 8080:80 kiwix/kiwix-serve wikipedia.zim ``` +Use with remote ZIM file +------------------------ + +```bash +docker run -e "DOWNLOAD=https://download.kiwix.org/zim/wikipedia/wikipedia_bm_all.zim" -p 8080:80 kiwix/kiwix-serve +``` + +Screenshots +----------- + ![screenshot_1.png](https://github.com/kiwix/kiwix-tools/raw/master/docker/server/pictures/screenshot_1.png) ![screenshot_2.png](https://github.com/kiwix/kiwix-tools/raw/master/docker/server/pictures/screenshot_2.png) diff --git a/docker/server/start.sh b/docker/server/start.sh new file mode 100755 index 0000000..571ce73 --- /dev/null +++ b/docker/server/start.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Download if necessary a file +if [ ! -z "$DOWNLOAD" ] +then + ZIM=`basename $DOWNLOAD` + wget $DOWNLOAD -O "$ZIM" + + # Set arguments + if [ "$#" -eq "0" ] + then + set -- "$@" $ZIM + fi +fi + +/usr/local/bin/kiwix-serve --port=80 $@