Skip to content

Commit

Permalink
Merge pull request #582 from kiwix/simpler-dockerfile
Browse files Browse the repository at this point in the history
Simpler dockerfile
  • Loading branch information
kelson42 committed Oct 26, 2022
2 parents 4137d9f + cf6d66b commit 252e3bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 43 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
name: Deploy kiwix-tools Docker Image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0
- name: build and publish kiwix-tools
uses: openzim/docker-publish-action@v5
uses: openzim/docker-publish-action@v9
with:
image-name: kiwix/kiwix-tools
credentials: |
Expand All @@ -33,15 +33,17 @@ jobs:
linux/arm64
restrict-to: kiwix/kiwix-tools
manual-tag: ${{ github.event.inputs.version }}
repo_description: auto
repo_overview: Kiwix command line tools

build-and-push-kiwix-serve:
name: Deploy kiwix-serve Docker Image
runs-on: ubuntu-20.04
needs: build-and-push-kiwix-tools
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0
- name: build and publish kiwix-serve
uses: openzim/docker-publish-action@v5
uses: openzim/docker-publish-action@v9
with:
image-name: kiwix/kiwix-serve
credentials: |
Expand All @@ -59,3 +61,5 @@ jobs:
linux/arm64
restrict-to: kiwix/kiwix-tools
manual-tag: ${{ github.event.inputs.version }}
repo_description: auto
repo_overview: Kiwix web-server
50 changes: 11 additions & 39 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,18 @@
# dumb-init to use as entrypoint so it can forward signals to our CMD
FROM debian:bullseye-slim as builder
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential ca-certificates musl-tools wget unzip make \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# compile dumb-init
RUN wget -nv https://github.com/Yelp/dumb-init/archive/refs/tags/v1.2.5.zip && \
unzip v1.2.5.zip && cd dumb-init-1.2.5 && CC=musl-gcc make

# declare build option ARCH if not using buildx
ARG ARCH=
# declare version to build image for
ARG VERSION=

# alpine is a multi-arch image
FROM alpine:3
FROM alpine:3.16
LABEL org.opencontainers.image.source https://github.com/openzim/kiwix-tools

# TARGETARCH is injected by buildx
ARG TARGETARCH
ARG VERSION
ARG ARCH

# copy built dumb-init
COPY --from=builder /dumb-init-1.2.5/dumb-init /usr/bin/dumb-init

# find and store arch in image, using (in this order):
# $TARGETARCH || --build-arg ARCH (not using buildx) || amd64
RUN echo "amd64" > /etc/docker_arch && \
if [ ! -z "$ARCH" ] ; then echo "$ARCH" > /etc/docker_arch ; fi && \
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

# Install kiwix-tools
RUN url="http://mirror.download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-$(cat /etc/kiwix_arch)-$VERSION.tar.gz" && \
RUN apk --no-cache add dumb-init curl && \
ARCH=$(cat /etc/apk/arch) && \
if [ "$ARCH" = "x86" ]; then ARCH="i586"; \
elif [ "$ARCH" = "aarch64" ]; then ARCH="armhf"; \
elif [ "$ARCH" = "armv7" ]; then ARCH="armhf"; fi && \
# download requested kiwix-tools version
url="http://mirror.download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-$ARCH-$VERSION.tar.gz" && \
echo "URL: $url" && \
wget -q -O - $url | tar -xz && \
mv kiwix-tools*/kiwix-* /usr/local/bin && \
rm -r kiwix-tools*
curl -k -L $url | tar -xz -C /usr/local/bin/ --strip-components 1 && \
# only needed in dockerfile
apk del curl

# expose kiwix-serve default port
EXPOSE 80
Expand Down

0 comments on commit 252e3bc

Please sign in to comment.