From f3295b99ef549ba69dead2eeb88b84c82e1ec61d Mon Sep 17 00:00:00 2001 From: David Shay Date: Wed, 12 Jan 2022 10:31:26 -0500 Subject: [PATCH] Added support for multi-arch image build --- .github/workflows/on-main-push.yaml | 26 ++++++++++++++++++++------ .github/workflows/on-tag.yaml | 20 +++++++++++++++++--- cmd/kured/Dockerfile.multi | 9 +++++++++ 3 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 cmd/kured/Dockerfile.multi diff --git a/.github/workflows/on-main-push.yaml b/.github/workflows/on-main-push.yaml index 23db1d8..ff7b3cd 100644 --- a/.github/workflows/on-main-push.yaml +++ b/.github/workflows/on-main-push.yaml @@ -36,10 +36,24 @@ jobs: username: weave-ghcr-bot password: ${{ secrets.KURED_WEAVE_GHCR_BOT_TOKEN }} - - name: Build image - run: | - make DH_ORG="${{ github.repository_owner }}" image + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 - - name: Publish image - run: | - make DH_ORG="${{ github.repository_owner }}" publish-image + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Find current tag version + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + id: tags + + - name: Build image + uses: docker/build-push-action@v2 + with: + context: . + file: cmd/kured/Dockerfile.multi + platforms: linux/arm64, linux/amd64 + push: true + tags: | + docker.io/${{ GITHUB.REPOSITORY }}:main-${{ steps.tags.outputs.sha_short }} + ghcr.io/${{ GITHUB.REPOSITORY }}:main-${{ steps.tags.outputs.sha_short }} diff --git a/.github/workflows/on-tag.yaml b/.github/workflows/on-tag.yaml index fd8bea2..4e23ebd 100644 --- a/.github/workflows/on-tag.yaml +++ b/.github/workflows/on-tag.yaml @@ -44,6 +44,20 @@ jobs: username: weave-ghcr-bot password: ${{ secrets.KURED_WEAVE_GHCR_BOT_TOKEN }} - - name: Publish image - run: | - make DH_ORG="${{ github.repository_owner }}" VERSION="${{ steps.tags.outputs.version }}" publish-image + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Build image + uses: docker/build-push-action@v2 + with: + context: . + file: cmd/kured/Dockerfile.multi + platforms: linux/arm64, linux/amd64 + push: true + tags: | + docker.io/${{ GITHUB.REPOSITORY }}:${{ steps.tags.outputs.version }} + ghcr.io/${{ GITHUB.REPOSITORY }}:${{ steps.tags.outputs.version }} diff --git a/cmd/kured/Dockerfile.multi b/cmd/kured/Dockerfile.multi new file mode 100644 index 0000000..98bdc8e --- /dev/null +++ b/cmd/kured/Dockerfile.multi @@ -0,0 +1,9 @@ +FROM golang:bullseye AS build +WORKDIR /src +COPY . . +RUN go list -f '{{join .Deps "\n"}}' ./cmd/kured | grep -v /vendor/ | xargs go list -f '{{if not .Standard}}{{ $dep := . }}{{range .GoFiles}}{{$dep.Dir}}/{{.}} {{end}}{{end}}' +RUN CGO_ENABLED=0 GOOS=linux go build -o cmd/kured/kured cmd/kured/*.go +FROM alpine:latest as bin +RUN apk update --no-cache && apk upgrade --no-cache && apk add --no-cache ca-certificates tzdata +COPY --from=build /src/cmd/kured/kured /usr/bin/kured +ENTRYPOINT ["/usr/bin/kured"]