Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations not working as expected to add descriptions #3277

Closed
arya062000 opened this issue Nov 11, 2022 · 6 comments · Fixed by #3283
Closed

Annotations not working as expected to add descriptions #3277

arya062000 opened this issue Nov 11, 2022 · 6 comments · Fixed by #3283

Comments

@arya062000
Copy link

👋🏼 I came across this document on adding annotations to images pushed via buildkit for the index manifest https://github.com/moby/buildkit/blob/master/docs/annotations.md. I tried using this to add descriptions to an image but was not able to.

@jedevc
Copy link
Member

jedevc commented Nov 11, 2022

Heya, thanks for the report! 🎉

Could you explain what you're trying to do, and what you're expecting to happen? If you could also share what version of buildkit you're using, that would be great as well!

Annotations haven't made it into a release yet, so unless you're using the master or nightly builds, the feature isn't yet available - though it will be in 0.11 when we release soon.

@arya062000
Copy link
Author

I'm using : https://github.com/docker/setup-buildx-action i.e. GitHub Action to set up Docker Buildx. Annotations are being added like this in the github actions. And passing annotations to the output param.

@arya062000
Copy link
Author

And passing annotations as:

outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=DESCRIPTION

@jedevc
Copy link
Member

jedevc commented Nov 11, 2022

Can you share your GitHub workflow? At least the part that contains your setup-buildx-action step?

@arya062000
Copy link
Author

name: CI

on:
  push:
    branches: [ master ]
  workflow_dispatch:
  # schedule:
  #  - cron:  '0,15,30,45 * * * *'

env:
  # Use docker.io for Docker Hub if empty
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository_owner }}/example-buildx-push

jobs:
  build:  
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    strategy:
      matrix:
        number: [0, 1]
        include:
          - driver-opts: ""
          - number: 0
            platforms: ""
            tag: single-platform
          - number: 1
            platforms: "linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le"
            tag: multi-platform

    timeout-minutes: 5

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
        with:
          buildkitd-flags: --debug
          driver-opts: |
            image=moby/buildkit:master
            ${{ matrix.driver-opts }}
      - name: Log into registry ${{ env.REGISTRY }}
        uses: docker/login-action@v1
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      # Build and push Docker image with Buildx (don't push on PR)
      # https://github.com/docker/build-push-action@v2
      - name: Build and push Docker image
        uses: docker/build-push-action@v2
        with:
          context: .
          file: ./Dockerfile
          platforms: ${{ matrix.platforms }}
          push: true
          tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.tag }}
          outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=DESCRIPTION

@jedevc
Copy link
Member

jedevc commented Nov 14, 2022

So I think this is probably an issue with the single-platform in your matrix - if its also occurring with multi-platform in that same matrix, I'm not quite sure what the problem is. If you could share the results of docker buildx imagetools inspect --raw <registry>/<image>:<tag> for the images that you expect to have the index annotation, I can confirm.

Annotations for single platforms generate a manifest, so the annotation is silently discarded. That's weird behavior, so we should probably explicitly errored - I've linked a PR that will cause this to explicitly (instead of silently) fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants