From 7d2bc4905a467b7491e6fab1c85df85f2041c85f Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Wed, 20 May 2020 16:41:32 +0300 Subject: [PATCH] Push releases to Docker Hub for ARM64 and ARM v6/v7 --- .github/workflows/{build.yml => push.yml} | 13 +++++++------ Dockerfile | 4 ++-- README.md | 1 + e2e/build.sh | 4 +++- 4 files changed, 13 insertions(+), 9 deletions(-) rename .github/workflows/{build.yml => push.yml} (63%) diff --git a/.github/workflows/build.yml b/.github/workflows/push.yml similarity index 63% rename from .github/workflows/build.yml rename to .github/workflows/push.yml index cf1f90a..85f4b5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/push.yml @@ -1,20 +1,21 @@ -name: build +name: multi-arch-build on: push: - branches: '*' + tags: '*' jobs: - build: + build-push: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: crazy-max/ghaction-docker-buildx@v1 - - name: build + - name: buildx run: | echo "${{ secrets.DOCKER_PASSWORD }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin docker buildx build --platform "linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64" \ --output "type=image,push=true" \ - --build-arg "REVISION=${GITHUB_SHA::8}" \ - --tag "docker.io/stefanprodan/podinfo:multiarch" \ + --build-arg "REVISION=${GITHUB_SHA}" \ + --tag "docker.io/stefanprodan/podinfo:${GITHUB_REF#refs/tags/}" \ + --tag "docker.io/stefanprodan/podinfo:latest" \ --file Dockerfile . diff --git a/Dockerfile b/Dockerfile index 1760d6c..becd468 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:1.14-alpine as builder +FROM golang:1.14-alpine as builder ARG REVISION @@ -18,7 +18,7 @@ RUN CGO_ENABLED=0 go build -ldflags "-s -w \ -X github.com/stefanprodan/podinfo/pkg/version.REVISION=${REVISION}" \ -a -o bin/podcli cmd/podcli/* -FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.11 +FROM alpine:3.11 RUN addgroup -S app \ && adduser -S -g app app \ diff --git a/README.md b/README.md index 581b7cb..2cd0008 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Specifications: * Helm and Kustomize installers * End-to-End testing with Kubernetes Kind and Helm * Kustomize testing with GitHub Actions and Open Policy Agent +* Multi-arch container image with Docker buildx and Github Actions Web API: diff --git a/e2e/build.sh b/e2e/build.sh index 9b6523c..ed856e8 100755 --- a/e2e/build.sh +++ b/e2e/build.sh @@ -2,5 +2,7 @@ set -o errexit -docker build -t test/podinfo:latest . +GIT_COMMIT=$(git rev-list -1 HEAD) + +docker build -t test/podinfo:latest --build-arg "REVISION=${GIT_COMMIT}" .