diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a08a1f49..87a6e721 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,13 +21,44 @@ jobs: cd config/release kustomize edit set image fluxcd/source-controller=fluxcd/source-controller:${{ steps.get_version.outputs.VERSION }} kustomize build . > source-controller.yaml - - name: Push image - uses: docker/build-push-action@v1 + - name: Setup QEMU + uses: docker/setup-qemu-action@master with: - username: ${{ secrets.DOCKER_FLUXCD_USER }} + platforms: all + - name: Setup Docker Buildx + id: buildx + uses: docker/setup-buildx-action@master + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: fluxcdbot + password: ${{ secrets.GHCR_TOKEN }} + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: fluxcdbot password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }} - repository: fluxcd/source-controller - tag_with_ref: true + - name: Publish amd64 image + uses: docker/build-push-action@v2-build-push + with: + push: ${{ github.event_name != 'pull_request' }} + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + platforms: linux/amd64 + tags: | + ghcr.io/fluxcd/source-controller:${{ steps.get_version.outputs.VERSION }} + docker.io/fluxcd/source-controller:${{ steps.get_version.outputs.VERSION }} + - name: Publish arm64 image + uses: docker/build-push-action@v2-build-push + with: + push: ${{ github.event_name != 'pull_request' }} + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + platforms: linux/arm64 + tags: ghcr.io/fluxcd/source-controller-arm64:${{ steps.get_version.outputs.VERSION }} - name: Create release id: create_release uses: actions/create-release@latest diff --git a/Dockerfile b/Dockerfile index 46f60e1e..1f741f7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM golang:1.14 as builder +# Docker buildkit multi-arch build requires golang alpine +FROM golang:1.14-alpine as builder WORKDIR /workspace @@ -18,11 +19,14 @@ COPY controllers/ controllers/ COPY pkg/ pkg/ COPY internal/ internal/ -# build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-controller main.go +# build without specifing the arch +RUN CGO_ENABLED=0 go build -a -o source-controller main.go FROM alpine:3.12 +# link repo to the GitHub Container Registry image +LABEL org.opencontainers.image.source="https://github.com/fluxcd/source-controller" + RUN apk add --no-cache ca-certificates tini COPY --from=builder /workspace/source-controller /usr/local/bin/