Build for ARM (ARM64 + ARMv7) (#109)

Co-authored-by: William Boman <william@redwill.se>
This commit is contained in:
Kristian Klausen 2020-08-07 00:01:02 +02:00 committed by GitHub
parent 51a43bf952
commit cc6bc2c0c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 2 deletions

58
.github/workflows/docker-image-push.yml vendored Normal file
View file

@ -0,0 +1,58 @@
name: Build (and push) multi-arch Docker image
on: [push, pull_request]
jobs:
build:
name: Build
# We want a newer version of qemu: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1815100
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
dockerfile: [Dockerfile, alpine/Dockerfile]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Docker login
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin docker.io
- name: Setup buildx
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
docker buildx create --use
- name: Build Docker image
env:
PLATFORMS: linux/amd64,linux/arm64/v8,linux/arm/v7
DOCKER_REPOSITORY: thelounge/thelounge
run: |
TAG="$(git rev-parse --short HEAD)"
EXTRA_ARG=()
# Only push on regular push (!= pull_request)
if [ "${GITHUB_EVENT_NAME}" = "push" ] && grep -q "^refs/tags/" <<< "${GITHUB_REF}"; then
EXTRA_ARG+=("--push")
VERSION="$(git describe --exact-match --tags)"
TAG="${VERSION}"
LATEST_TAG="latest"
if grep -q "^alpine/" <<< "${{ matrix.dockerfile }}"; then
TAG="${TAG}-alpine"
LATEST_TAG="alpine"
fi
# If not a pre-release push LATEST_TAG
if grep -qE "^[0-9]*\.[0-9]*\.[0-9]*$" <<< "${VERSION}"; then
EXTRA_ARG+=("--tag" "${DOCKER_REPOSITORY}:${LATEST_TAG}")
fi
fi
docker buildx build \
--platform "${PLATFORMS}" \
--tag "${DOCKER_REPOSITORY}:${TAG}" \
"${EXTRA_ARG[@]}" \
--file "${{ matrix.dockerfile }}" \
.

View file

@ -16,5 +16,7 @@ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# Install thelounge.
ARG THELOUNGE_VERSION=4.2.0-pre.2
RUN yarn --non-interactive --frozen-lockfile global add thelounge@${THELOUNGE_VERSION} && \
yarn --non-interactive cache clean
RUN apk --update --no-cache add python build-base && \
yarn --non-interactive --frozen-lockfile global add thelounge@${THELOUNGE_VERSION} && \
yarn --non-interactive cache clean && \
apk del python build-base