Skip to content

Commit

Permalink
ci: Update buildx
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Sep 2, 2020
1 parent feb6b30 commit 8a5e467
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
58 changes: 36 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,42 @@ jobs:
cd config/release
kustomize edit set image fluxcd/notification-controller=fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}
kustomize build . > notification-controller.yaml
- uses: crazy-max/ghaction-docker-buildx@v1
- name: Publish image
run: |
echo "${{ secrets.DOCKER_FLUXCD_PASSWORD }}" | docker login --username fluxcdbot --password-stdin
echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io --username fluxcdbot --password-stdin
docker buildx build --platform "linux/amd64" \
--output "type=image,push=true" \
--build-arg "REVISION=${GITHUB_SHA}" \
--build-arg "VERSION=${{ steps.get_version.outputs.VERSION }}" \
--build-arg "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--tag "ghcr.io/fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}" \
--tag "docker.io/fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}" \
--file Dockerfile .
docker buildx build --platform "linux/arm64" \
--output "type=image,push=true" \
--build-arg "REVISION=${GITHUB_SHA}" \
--build-arg "VERSION=${{ steps.get_version.outputs.VERSION }}" \
--build-arg "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
--tag "ghcr.io/fluxcd/notification-controller-arm64:${{ steps.get_version.outputs.VERSION }}" \
--file Dockerfile .
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up 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 }}
- 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/notification-controller:${{ steps.get_version.outputs.VERSION }},docker.io/fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}

This comment has been minimized.

Copy link
@crazy-max

crazy-max Sep 2, 2020

@stefanprodan If you want something more readable you can also use a newline-delimiter for tags:

          tags: |
            ghcr.io/fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}
            docker.io/fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}

This comment has been minimized.

Copy link
@stefanprodan

stefanprodan Sep 2, 2020

Author Member

@crazy-max thanks!

This comment has been minimized.

This comment has been minimized.

Copy link
@stefanprodan

stefanprodan Sep 2, 2020

Author Member

It would be great if the action would inject org.opencontainers.image.source using the GH repo url, this way GHCR will link the image to the repo automatically. I guess for now I'll add that label to the Dockerfile.

This comment has been minimized.

Copy link
@crazy-max

crazy-max Sep 2, 2020

We have thought about this but for the moment we prefer to be as generic as possible. But it's something that will definitely interest us after the release of v2!

This comment has been minimized.

Copy link
@stefanprodan

stefanprodan Sep 2, 2020

Author Member

Cool, thanks a lot for your work 🥇

This comment has been minimized.

Copy link
@crazy-max

crazy-max Sep 2, 2020

See also my notes on docker/build-push-action#92 about OCI Image Format Specification

This comment has been minimized.

Copy link
@crazy-max

crazy-max Sep 4, 2020

@stefanprodan Mutable tag created: https://github.com/docker/build-push-action/tree/v2
Please use docker/build-push-action@v2. (v2-build-push will be deleted as the PR has been merged)

This comment has been minimized.

Copy link
@stefanprodan

stefanprodan Sep 4, 2020

Author Member

Awesome! I'll switch to v2 before the next controller release.

- 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/notification-controller-arm64:${{ steps.get_version.outputs.VERSION }}
- name: Create release
id: create_release
uses: actions/create-release@latest
Expand Down
12 changes: 0 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ RUN CGO_ENABLED=0 go build -a -o notification-controller main.go

FROM alpine:3.12

ARG BUILD_DATE
ARG VERSION
ARG REVISION

LABEL org.opencontainers.image.created=$BUILD_DATE \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.revision=$REVISION \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.source="https://github.com/fluxcd/notification-controller" \
org.opencontainers.image.documentation="https://toolkit.fluxcd.io" \
org.opencontainers.image.authors="Flux CD"

RUN apk add --no-cache ca-certificates tini

COPY --from=builder /workspace/notification-controller /usr/local/bin/
Expand Down

0 comments on commit 8a5e467

Please sign in to comment.