From 1374ae61837da164b9c7c107607208908ab951b1 Mon Sep 17 00:00:00 2001 From: Tim Brust Date: Sun, 7 Jun 2020 00:53:23 +0200 Subject: [PATCH] feat: enable multi arch building --- .github/workflows/buildx.yml | 76 ++++++++++++++++++++++++++++++++++++ 10/Dockerfile | 4 +- 12/Dockerfile | 4 +- README.md | 11 ++++++ hooks/build | 2 - renovate.json | 3 +- 6 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/buildx.yml delete mode 100644 hooks/build diff --git a/.github/workflows/buildx.yml b/.github/workflows/buildx.yml new file mode 100644 index 0000000..2f8e4cc --- /dev/null +++ b/.github/workflows/buildx.yml @@ -0,0 +1,76 @@ +name: buildx + +on: + schedule: + - cron: '37 06 * * *' + pull_request: + push: + +jobs: + buildx: + runs-on: ubuntu-latest + strategy: + matrix: + docker-file: + - path: 10 + tags: 10,dubnium + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 + - path: 12 + tags: 12,erbium,latest + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Prepare + id: prepare + run: | + DOCKER_IMAGE=timbru31/node-alpine-git + + TAGZ=$(echo ${{ matrix.docker-file.tags }} | tr "," "\n") + VERSION=${TAGZ[0]} + + for tag in $TAGZ + do + TAGS="${TAGS} --tag ${DOCKER_IMAGE}:${tag}" + done + + echo ::set-output name=docker_image::${DOCKER_IMAGE} + echo ::set-output name=version::${VERSION} + echo ::set-output name=buildx_args::--platform ${{ matrix.docker-file.platforms }} \ + --build-arg REFRESHED_AT=$(date +%Y-%m-%d) \ + ${TAGS} --file ./${{ matrix.docker-file.path }}/Dockerfile ./${{ matrix.docker-file.path }} + + - name: Set up Docker Buildx + id: buildx + uses: crazy-max/ghaction-docker-buildx@v2 + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} + + - name: Docker Buildx (build) + run: | + docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} + + - name: Docker Login + if: success() && github.event_name != 'pull_request' + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Docker Buildx (push) + if: success() && github.event_name != 'pull_request' + run: | + docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} + + - name: Docker Check Manifest + if: always() && github.event_name != 'pull_request' + run: | + docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} + + - name: Clear + if: always() && github.event_name != 'pull_request' + run: | + rm -f ${HOME}/.docker/config.json diff --git a/10/Dockerfile b/10/Dockerfile index bd4f259..5158723 100644 --- a/10/Dockerfile +++ b/10/Dockerfile @@ -1,5 +1,5 @@ -FROM node:dubnium-alpine@sha256:2c2645270fb31946300e7e0c3f69f01d556f8fc4484d1d3de6cac412e1714ebe -LABEL maintainer "Tim Brust " +FROM node:dubnium-alpine +LABEL maintainer "Tim Brust " ARG REFRESHED_AT ENV REFRESHED_AT $REFRESHED_AT diff --git a/12/Dockerfile b/12/Dockerfile index 1972a8d..195afbb 100644 --- a/12/Dockerfile +++ b/12/Dockerfile @@ -1,5 +1,5 @@ -FROM node:erbium-alpine@sha256:7d7ad9b819f7064e215aa68a925f22b6a4417598bf017132201f9f1c6f2f0f62 -LABEL maintainer "Tim Brust " +FROM node:erbium-alpine +LABEL maintainer "Tim Brust " ARG REFRESHED_AT ENV REFRESHED_AT $REFRESHED_AT diff --git a/README.md b/README.md index 719fe17..a580bb5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,17 @@ A minimal Dockerfile based on Node.js 10 LTS (Dubnium) or Node.js 12 LTS (Erbium - Git - ssh +## Available platforms + +These Dockerfiles leverage the new `buildx` functionality and offer the following platforms: +- linux/amd64 +- linux/arm64 +- linux/arm/v7 +- linux/arm/v6 +- linux/ppc64le +- linux/s390x +- linux/386 + --- Built by (c) Tim Brust and contributors. Released under the MIT license. diff --git a/hooks/build b/hooks/build deleted file mode 100644 index 6b61d1c..0000000 --- a/hooks/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -docker build --build-arg REFRESHED_AT="$(date +%Y-%m-%d)" -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" . diff --git a/renovate.json b/renovate.json index 01386c3..747b758 100644 --- a/renovate.json +++ b/renovate.json @@ -1,7 +1,8 @@ { "extends": [ "config:base", - ":automergeDigest", + ":disableRenovate", + ":pinDigestsDisabled", ":automergePatch", ":automergeMinor", ":automergePr",