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

using gha cache with docker-container #20748

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions content/build/cache/backends/gha.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ exposed. Consider using the
[`crazy-max/ghaction-github-runtime`](https://github.com/crazy-max/ghaction-github-runtime),
GitHub Action as a helper for exposing the variables.

If you are using the `docker-container` driver, `ACTIONS_RUNTIME_TOKEN` and `ACTIONS_RUNTIME_URL` environment variables must be passed into the container.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed, Buildx already sets token and url attributes for gha exporter during build: https://github.com/docker/buildx/blob/96eb69aea4e03baf516f29ec36aa93a9c284f085/util/buildflags/cache.go#L69-L84

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh cool. I wonder why we were having an issue getting this to work. Maybe an older buildx not using the controller api?

Copy link
Member

@crazy-max crazy-max Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you run docker buildx in a run step? If that's the case then ACTIONS_RUNTIME_TOKEN and ACTIONS_RUNTIME_URL envs are not exposed: https://docs.docker.com/build/cache/backends/gha/#authentication

You would need smth like https://github.com/crazy-max/ghaction-github-runtime?tab=readme-ov-file#usage

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we're definitely using that. Will have to take a closer look.


```console
docker buildx create --driver=docker-container --use --bootstrap \
--driver-opt=env.ACTIONS_RUNTIME_TOKEN=$ACTIONS_RUNTIME_TOKEN \
--driver-opt=env.ACTIONS_RUNTIME_URL=$ACTIONS_RUNTIME_URL
```

## Scope

Scope is a key used to identify the cache object. By default, it is set to
Expand Down
Loading