Skip to content

Commit

Permalink
Fixed #482: use dumb-init in docker for signal forwarding
Browse files Browse the repository at this point in the history
Following-up on discussion in #488, now using https://github.com/Yelp/dumb-init
as entrypoint so our kiwix-* tools properly receives signals
  • Loading branch information
rgaudin committed Oct 13, 2021
1 parent 3df4a94 commit ca8369b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 forward signals to PID=1
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/"]
2 changes: 1 addition & 1 deletion docker/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit ca8369b

Please sign in to comment.