Cache does not seem to be used
See original GitHub issueBehaviour
Hi ! Thank you for your great peace of work here !
It looks like the cache feature is not used during docker build
.
Or I may have misunderstood something ! 🤷♂️ (I’ve never used buildx yet, only Buildkit but without thinking about the caching part).
Thank you for your help !
Expected behaviour
I think Golang and Alpine images should almost always be retrieved by cache
Regarding the
setup-buildx
action, it would be great to use caching too so that we don’t loose around 13s on every action trigger
Actual behaviour
At this time it is not
Cache works well if I relaunch the action without making any changes
Configuration
name: ci
on: [pull_request,release]
jobs:
docker-build-and-push:
runs-on: ubuntu-latest
steps:
-
name: Checkout repository
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Login to Azure Container Registry
uses: docker/login-action@v1
with:
registry: ${{ secrets.CONTAINER_REGISTRY_NAME }}
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
-
name: Build and push docker image
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.CONTAINER_REGISTRY_NAME }}/${{ github.event.repository.name }}:${{ github.head_ref }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
here is the Dockerfile:
FROM golang:1.15-alpine AS builder
WORKDIR /project
COPY . .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o backend-ads-api ./cmd/...
FROM alpine:3.12
COPY --from=builder /project/backend-ads-api .
ENTRYPOINT ["/backend-ads-api"]
and the .dockerignore if it helps:
.git
.gitignore
.dockerignore
.github
.idea
Dockerfile
*test.go
README.md
LICENSE
Logs
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How Do I Fix My Caching Problems Or Clear Web ...
How to clear the cache in commonly used browsers · Open your browser and and got to Tools > Safety menu. · Click...
Read more >Github Actions restored cache is not being used
The node_modules seems to be cached but then the next job immediately fails due to missing dependencies. I ended up using this GitHub...
Read more >[Cache] Somehow it doesn't seem to hit the cache #4166
However, the cache files seem to be generated properly, and it's likely that the cache was not hit or used properly.
Read more >Help! I Don't See My Changes! - Clear the Cache
If you don't see your changes after updating your website, you may need to refresh by clearing your cache. Press Ctrl + F5...
Read more >Isn't caching
Error on dynamic page: Seem that your website is not behind Cloudflare. If you have recently enabled the cache or it is your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rmasclef
Can you open an issue on buildkit repo? WDYT @tonistiigi?
This is perfectly understandable. Perhaps there is some room for caching the
moby/buildkit
image. Can you open an issue on setup-buildx repo about that? Thanks.thank you for your answers 👍
So why using buildx/buildkit when a “basic”
docker **build**
allows base image caching ?Well, in our case, we are on a
Github Team plan
so we have3000 minutes
available every month. And as we have about 30 projects, every gained build second is clearly welcome don’t you think ?I know that, most of the time, we can optimize build time by optimizing the Dockerfile, but I don’t think I can optimize more in the case of a Go project though I’m really welcome to get advises on what I’ve done so far ! 😄