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

[QUESTION] Is it possible to use the layers to make this GHA reuse previously published image versions? #90

Open
webknjaz opened this issue Dec 17, 2021 · 7 comments
Labels
question Further information is requested

Comments

@webknjaz
Copy link

webknjaz commented Dec 17, 2021

Question

Hi, I've seen an interesting trick at https://github.com/pyca/infra/blob/d52c449/.github/workflows/build-docker-images.yml#L58 where they use docker build --cache-from=... to have Docker reuse some of the layer cache from an earlier image version IIUC.

When I saw #43 / #42, I thought — would it be possible to do the same with podman/buildah? What would be required? Would podman pull coupled with layers: true be enough? Is there something I'm misunderstanding in how buildah works? (there probably is)

I know that podman's --cache-from is no-op but I thought maybe it is possible to achieve somehow on the buildah level?

@webknjaz webknjaz added the question Further information is requested label Dec 17, 2021
@webknjaz
Copy link
Author

@divyansh42 @tetchel @lstocchi any comments?

@divyansh42
Copy link
Member

Hey @webknjaz, apologies for the delayed response.
I've checked this, buildah doesn't support --cache-from yet. However, there is an open issue for that.

@webknjaz
Copy link
Author

Yeah, I've seen some related issues but I still don't understand if that is something that direct invocations of buildah maybe support.

@webknjaz
Copy link
Author

In particular, I was curious if that layers option does this.

@AdrianBalcan
Copy link

Can I use this GitHub Action and have a newer buildah version, in order to use --cache-to and --cache-from?
I've noticed that it has not been updated anymore since Version: 1.23.1.

@np22-jpg
Copy link

np22-jpg commented Apr 8, 2023

Can I use this GitHub Action and have a newer buildah version

GitHub Actions Images all use whatever is in the Ubuntu repos. When Lunar Lobster drops in a month, we'll get a newer version of buildah/podman/etc. If you'd like, you can use quay.io/buildah/stable:latest. I use something like this:

    runs-on: ubuntu-latest
    container:
      image: quay.io/buildah/stable:latest
      options: --privileged

Although it's finicky, it gives you the latest version of buildah and dnf (but not podman?).

@lectrician1
Copy link

lectrician1 commented Mar 17, 2024

hhh well you can specify cache-to and cache-from now, but you need a system to make the right calls to the GitHub cache API (which i was trying to do) https://github.com/tonistiigi/go-actions-cache/blob/master/api.md and that system does not exist in buildah-build like it does in Docker's https://docs.docker.com/build/ci/github-actions/cache/#github-cache , so you might as well just use Docker's if you want caching

A near attempt:

name: 

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
      push-store-image:
        runs-on: ubuntu-latest
        defaults:
          run:
            working-directory: '.'
        steps:
          - name: 'Checkout GitHub Action'
            uses: actions/checkout@main

          - name: Buildah Build
            uses: redhat-actions/buildah-build@v2
            with:
              containerfiles: |
                ./Containerfile
              image: yay
              layers: true
              build-args: |
                cache-to=NEED SPECIFIC CACHE URL WITH KEY
                cache-from=NEED SPECIFIC CACHE URL WITH KEY
              
          - name: Push To ghcr
            uses: redhat-actions/push-to-registry@v2
            with:
              image: ${{ steps.build-image.outputs.image }}
              tags: ${{ steps.build-image.outputs.tags }}
              registry: ghcr.io/${{ github.repository_owner }}
              username: ${{github.actor}}
              password: ${{secrets.GITHUB_TOKEN}}
              extra-args: |
                --disable-content-trust

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

No branches or pull requests

5 participants