Merge pull request #861 from eikek/multi-arch-docker

Docker buildx setup
This commit is contained in:
eikek 2021-06-08 21:46:31 +02:00 committed by GitHub
commit ba35caa523
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 49 deletions

View File

@ -11,12 +11,17 @@ jobs:
fetch-depth: 0
- name: Set current version
run: echo "DOCSPELL_VERSION=$(cat version.sbt | grep version | cut -d= -f2 | xargs)" >> $GITHUB_ENV
- name: Build Docker Images (${{ env.DOCSPELL_VERSION }})
run: ./docker/dockerfiles/build.sh ${{ env.DOCSPELL_VERSION }}
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish Images (${{ env.DOCSPELL_VERSION }})
run: ./docker/dockerfiles/push.sh ${{ env.DOCSPELL_VERSION }}
- name: Build and push Docker Images (${{ env.DOCSPELL_VERSION }})
run: ./docker/dockerfiles/build.sh ${{ env.DOCSPELL_VERSION }} --push

View File

@ -10,27 +10,52 @@ if [[ $version == v* ]]; then
version="${version:1}"
fi
push=""
if [ -z "$2" ] || [ "$2" == "--push" ]; then
push="$2"
if [ ! -z "$push" ]; then
echo "Running with $push !"
fi
else
echo "Don't understand second argument: $2"
exit 1
fi
if ! docker buildx version > /dev/null; then
echo "The docker buildx command is required."
echo "See: https://github.com/docker/buildx#binary-release"
exit 1
fi
set -e
cd "$(dirname "$0")"
trap "{ docker buildx rm docspell-builder; }" EXIT
platforms="linux/amd64,linux/aarch64,linux/arm/v7"
docker buildx create --name docspell-builder --use
if [[ $version == *SNAPSHOT* ]]; then
echo ">>>> Building nightly images for $version <<<<<"
url_base="https://github.com/eikek/docspell/releases/download/nightly"
echo "============ Building Tools ============"
docker build \
docker buildx build \
--platform="$platforms" $push \
--build-arg tools_url="$url_base/docspell-tools-$version.zip" \
--tag docspell/tools:nightly \
-f tools.dockerfile .
echo "============ Building Restserver ============"
docker build \
docker buildx build \
--platform="$platforms" $push \
--build-arg restserver_url="$url_base/docspell-restserver-$version.zip" \
--tag docspell/restserver:nightly \
-f restserver.dockerfile .
echo "============ Building Joex ============"
docker build \
docker buildx build \
--platform="$platforms" $push \
--build-arg joex_url="$url_base/docspell-joex-$version.zip" \
--tag docspell/joex:nightly \
-f joex.dockerfile .
@ -38,6 +63,7 @@ else
echo ">>>> Building release images for $version <<<<<"
echo "============ Building Tools ============"
docker build \
--platform="$platforms" $push \
--build-arg version=$version \
--tag docspell/tools:v$version \
--tag docspell/tools:latest \
@ -45,6 +71,7 @@ else
echo "============ Building Restserver ============"
docker build \
--platform="$platforms" $push \
--build-arg version=$version \
--tag docspell/restserver:v$version \
--tag docspell/restserver:latest \
@ -52,6 +79,7 @@ else
echo "============ Building Joex ============"
docker build \
--platform="$platforms" $push \
--build-arg version=$version \
--tag docspell/joex:v$version \
--tag docspell/joex:latest \

View File

@ -3,10 +3,13 @@ FROM alpine:latest
ARG version=
ARG joex_url=
ARG UNO_URL=https://raw.githubusercontent.com/unoconv/unoconv/0.9.0/unoconv
ARG TARGETPLATFORM
ENV JAVA_OPTS="-Xmx1536M"
RUN apk add --no-cache openjdk11 \
RUN JDKPKG="openjdk11"; \
if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then JDKPKG="openjdk8"; fi; \
apk add --no-cache $JDKPKG \
tzdata \
bash \
curl \
@ -61,7 +64,7 @@ RUN wget ${joex_url:-https://github.com/eikek/docspell/releases/download/v$versi
COPY joex-entrypoint.sh /opt/joex-entrypoint.sh
ENTRYPOINT ["/opt/joex-entrypoint.sh"]
ENTRYPOINT ["/opt/joex-entrypoint.sh", "-J-XX:+UseG1GC"]
EXPOSE 7878
HEALTHCHECK --interval=1m --timeout=10s --retries=2 --start-period=10s \

View File

@ -1,38 +0,0 @@
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Please specify a version"
exit 1
fi
version="$1"
if [[ $version == v* ]]; then
version="${version:1}"
fi
set -e
cd "$(dirname "$0")"
if [[ $version == *SNAPSHOT* ]]; then
echo "============ Push Tools ============"
docker push docspell/tools:nightly
echo "============ Push Restserver ============"
docker push docspell/restserver:nightly
echo "============ Push Joex ============"
docker push docspell/joex:nightly
else
echo "============ Push Tools ============"
docker push docspell/tools:v$version
docker push docspell/tools:latest
echo "============ Push Restserver ============"
docker push docspell/restserver:v$version
docker push docspell/restserver:latest
echo "============ Push Joex ============"
docker push docspell/joex:v$version
docker push docspell/joex:latest
fi

View File

@ -2,8 +2,11 @@ FROM alpine:latest
ARG version=
ARG restserver_url=
ARG TARGETPLATFORM
RUN apk add --no-cache openjdk11 bash tzdata
RUN JDKPKG="openjdk11"; \
if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then JDKPKG="openjdk8"; fi; \
apk add --no-cache $JDKPKG bash tzdata
WORKDIR /opt
RUN wget ${restserver_url:-https://github.com/eikek/docspell/releases/download/v$version/docspell-restserver-$version.zip} && \
@ -11,7 +14,7 @@ RUN wget ${restserver_url:-https://github.com/eikek/docspell/releases/download/v
rm docspell-restserver-*.zip && \
ln -snf docspell-restserver-* docspell-restserver
ENTRYPOINT ["/opt/docspell-restserver/bin/docspell-restserver"]
ENTRYPOINT ["/opt/docspell-restserver/bin/docspell-restserver", "-J-XX:+UseG1GC"]
EXPOSE 7880
HEALTHCHECK --interval=1m --timeout=10s --retries=2 --start-period=30s \