Merge pull request #489 from kiwix/docker-signals

This commit is contained in:
Matthieu Gautier 2021-10-14 14:12:23 +02:00 committed by GitHub
commit 01430603b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -12,22 +12,29 @@ ARG TARGETARCH
ARG VERSION
ARG ARCH
# if we had no TARGETARCH (not buildx), use --build-arg ARCH. default to amd64
# defaulting to amd64
RUN echo "amd64" > /etc/docker_arch
# use --build-arg ARCH if it was provided (not using buildx)
RUN if [ ! -z "$ARCH" ] ; then echo "$ARCH" > /etc/docker_arch ; fi
# use $TARGETARCH if provided.
RUN if [ ! -z "$TARGETARCH" ] ; then echo "$TARGETARCH" > /etc/docker_arch ; fi
# decide which kiwix arch to download later (`armhf` for all arm* and x86_64 otherwise)
RUN if [ $(cut -c 1-3 /etc/docker_arch) = "arm" ] ; then echo "armhf" > /etc/kiwix_arch ; else echo "x86_64" > /etc/kiwix_arch ; fi
# dumb-init to use as entrypoint so it can forward signals to our CMD
RUN wget -q -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64 && \
chmod +x /usr/bin/dumb-init
# Install kiwix-tools
RUN url="http://mirror.download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-$(cat /etc/kiwix_arch)-$VERSION.tar.gz" && \
echo "URL: $url" && \
wget -O - $url | tar -xz && \
wget -q -O - $url | tar -xz && \
mv kiwix-tools*/kiwix-* /usr/local/bin && \
rm -r kiwix-tools*
# expose kiwix-serve default port
EXPOSE 80
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
CMD ["/bin/sh", "-c", "echo 'Welcome to kiwix-tools! The following binaries are available:' && ls /usr/local/bin/"]

View File

@ -11,4 +11,4 @@ WORKDIR /data
COPY ./start.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/start.sh"]
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/start.sh"]