-
Notifications
You must be signed in to change notification settings - Fork 36
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
Stored cache is empty #33
Comments
same here. |
I cannot reproduce this, but there are a few reasons why this can happen:
|
I'm also experiencing this issue. Some relevant code... Relevant parts of GitHub Actions Workflow: - run: docker context create builders
- uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # [email protected]
with:
endpoint: builders
- name: Ensure cache directories exists
run: |
mkdir -p ~/.nuget/packages
mkdir -p ~/dist
- name: 'Cache intermediate build artifacts'
id: cache
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # pin@v4
with:
path: |
~/.nuget/packages
~/dist
key: ${{ runner.os }}-intermediate-${{ matrix.project }}-${{ hashFiles('src/**/Directory.Packages.props') }}
- name: Show cache contents
run: |
ls -al ~/.nuget/packages
ls -al ~/dist
- name: inject cache into docker build
uses: reproducible-containers/buildkit-cache-dance@5b6db76d1da5c8b307d5d2e0706d266521b710de # v3.1.2
with:
cache-map: |
{
"~/.nuget/packages": {
"target": "/root/.nuget/packages",
"id": "nuget"
},
"~/dist": {
"target": "/dist",
"id": "dist"
}
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Build and push
uses: docker/[email protected]
with:
context: ./src
cache-from: type=gha
cache-to: type=gha,mode=max
file: src/Location/ZapMiddleware.Location.Api/Dockerfile
push: false
tags: test Relevant parts of Dockerfile: ###################################################
# Build image #
###################################################
FROM mcr.microsoft.com/dotnet/sdk:8.0.201-bookworm-slim AS build
WORKDIR /src
# Check cache mounts
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages ls -al /root/.nuget/packages
RUN --mount=type=cache,id=dist,target=/dist ls -al /dist
# Copy csproj and restore as distinct layers
COPY ["Location/ZapMiddleware.Location.Api/ZapMiddleware.Location.Api.csproj", "Location/ZapMiddleware.Location.Api/"]
COPY "Directory.Build.props" .
COPY "Directory.Packages.props" .
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
--mount=type=cache,id=dist,target=/dist \
dotnet restore "Location/ZapMiddleware.Location.Api"
# Check cache mounts
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages ls -al /root/.nuget/packages
RUN --mount=type=cache,id=dist,target=/dist ls -al /dist/intermediates/src
# Copy everything else and build app
COPY . .
WORKDIR "/src/Location/ZapMiddleware.Location.Api"
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
--mount=type=cache,id=dist,target=/dist \
dotnet publish -c Release -o /app
RUN rm /app/appsettings*.json
# Check cache mounts
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages ls -al /root/.nuget/packages
RUN --mount=type=cache,id=dist,target=/dist ls -al /dist/intermediates/src ![]() Relevant parts of docker build logs: The cache directories are populated with the expected package and build stage artefacts
Extracting cache: Extraction seems to happen, but the resulting cache that gets uploaded to GHA is empty ![]() |
I resolved my issue by ensuring that the local directory doesn't exist before running the cache dance, and changing the path to something relative to the checkout. |
I'm also experiencing same issue. Relevant parts of GitHub Actions Workflow:
|
try disabling job summary generated by build-push-action |
I tried disabling job summary, and it had no effect. Then I tried invalidating the layer cache, and all of a sudden it started working. I always delete the cache from Hypothesis: If you try to introduce this action after a layer cache has been produced, you might get unexpected results? Aside: Using a generic cache key with this action seems risky since it'll waste time running even when there's already a layer cache. The cache key should probably match however layer caching works to avoid this. |
I am probably missing something, but doing the same as the example results in an empty cache :
Dockerfile snippet using this cache :
I have the same issue with other caches I tried (pnpm store, build dist folders, etc), so that's not related specifically to this path but to the way I implement the action (according to the documentation).
The text was updated successfully, but these errors were encountered: