Open
Description
Behaviour
I'm trying to do docker build -t something .
and use the github actions cache for caching.
Steps to reproduce this issue
FROM rust:1-alpine3.16
ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN apk add --no-cache musl-dev
WORKDIR /app
COPY ./ /app
RUN --mount=type=cache,target=/var/cache/buildkit \
CARGO_HOME=/var/cache/buildkit/cargo \
CARGO_TARGET_DIR=/var/cache/buildkit/target \
cargo build --release --locked && \
cp -v /var/cache/buildkit/target/release/something .
RUN strip something
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- name: Build Docker image
uses: docker/build-push-action@v3
with:
tags: something
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
Expected behaviour
The cache is written to and read from github actions cache, the build finishes quickly.
Actual behaviour
It seems the cache is partially used, the RUN apk ...
layer seems to be read from cache but after COPY ./ /app
it's a cache miss and cargo build
hangs on Updating crates.io index
for a long time even though it should be read from cache because of RUN --mount=type=cache,target=/var/cache/buildkit CARGO_HOME=/var/cache/buildkit/cargo ...
.
Possibly related to #741, #735.
Configuration
- Repository URL (if public): https://github.com/kpcyrd/sh4d0wup
- Build URL (if public): https://github.com/kpcyrd/sh4d0wup/actions/runs/3652932149/jobs/6171852402
name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- name: Build Docker image
uses: docker/build-push-action@v3
with:
tags: sh4d0wup
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test the Docker image
run: docker run --rm sh4d0wup --help
- name: Login to github container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push the image to `edge`
if: github.event_name != 'pull_request'
run: |
docker tag sh4d0wup ghcr.io/kpcyrd/sh4d0wup:edge
docker push ghcr.io/kpcyrd/sh4d0wup:edge