docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.57k stars 482 forks source link

Bake seems to build an image before gha cache is imported #1706

Open bp-xiao opened 1 year ago

bp-xiao commented 1 year ago

Contributing guidelines

I've found a bug and checked that ...

Description

bake seems to start building an image while loading Github Actions caches, so layer caches in Github Actions caches aren't used.s

Expected behaviour

bake waits for Github Actions caches to be loaded before, and then it starts building images.

Actual behaviour

bake seems to start building an image while loading Github Actions caches.

Buildx version

0.10.4+azure-1 c513d34049e499c53468deac6c4267ee72948f02

Docker info

/usr/bin/docker version
  Client:
   Version:           20.10.23+azure-2
   API version:       1.41
   Go version:        go1.19.6
   Git commit:        715524332ff91d0f9ec5ab2ec95f051456ed1dba
   Built:             Wed Jan 18 20:42:16 UTC 2023
   OS/Arch:           linux/amd64
   Context:           default
   Experimental:      true

  Server:
   Engine:
    Version:          20.10.23+azure-2
    API version:      1.41 (minimum version 1.12)
    Go version:       go1.19.6
    Git commit:       6051f142912a5c06064e96b92de5e4e8f052131b
    Built:            Wed Jan 18 16:24:28 2023
    OS/Arch:          linux/amd64
    Experimental:     false
   containerd:
    Version:          1.6.19+azure-1
    GitCommit:        1e1ea6e986c6c86565bc33d52e34b81b3e2bc71f
   runc:
    Version:          1.1.4
    GitCommit:        5fd4c4d144137e991c4acebb2146ab1483a97925
   docker-init:
    Version:          0.19.0
    GitCommit:        
  /usr/bin/docker info
  Client:
   Context:    default
   Debug Mode: false
   Plugins:
    buildx: Docker Buildx (Docker Inc., 0.10.4+azure-1)
    compose: Docker Compose (Docker Inc., 2.16.0+azure-2)

  Server:
   Containers: 1
    Running: 1
    Paused: 0
    Stopped: 0
   Images: 18
   Server Version: 20.10.23+azure-2
   Storage Driver: overlay2
    Backing Filesystem: extfs
    Supports d_type: true
    Native Overlay Diff: false
    userxattr: false
   Logging Driver: json-file
   Cgroup Driver: cgroupfs
   Cgroup Version: 2
   Plugins:
    Volume: local
    Network: bridge host ipvlan macvlan null overlay
    Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
   Swarm: inactive
   Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
   Default Runtime: runc
   Init Binary: docker-init
   containerd version: 1e1ea6e986c6c86565bc33d52e34b81b3e2bc71f
   runc version: 5fd4c4d144137e991c4acebb2146ab1483a97925
   init version: 
   Security Options:
    apparmor
    seccomp
     Profile: default
    cgroupns
   Kernel Version: 5.15.0-1034-azure
   Operating System: Ubuntu 22.04.2 LTS
   OSType: linux
   Architecture: x86_64
   CPUs: 2
   Total Memory: 6.781GiB
   Name: fv-az621-916
   ID: 4G7Y:BNKF:PKAS:PXGX:7ET2:ZS6F:TMV4:HZVX:AKM4:BIOB:5PK6:THGH
   Docker Root Dir: /var/lib/docker
   Debug Mode: false
   Username: githubactions
   Registry: https://index.docker.io/v1/
   Labels:
   Experimental: false
   Insecure Registries:
    127.0.0.0/8

Builders list

n/a

Configuration

FROM python:3.11-slim as base

RUN \
    apt-get update && \
    apt-get install --no-install-recommends -y tree && \
    rm -rf /var/lib/apt/lists/*
# compose.yaml
services:
  a_service:
    build: .

Build logs

/usr/bin/docker buildx build --cache-from type=gha --cache-to type=gha,mode=max --iidfile /tmp/docker-build-push-FD7smk/iidfile --provenance mode=max,builder-id=https://github.com/bp-xiao/20230330-01-gha-cache/actions/runs/4560389515 --secret id=GIT_AUTH_TOKEN,src=/tmp/docker-build-push-FD7smk/tmp-2101-Pblv4XQptb2A --metadata-file /tmp/docker-build-push-FD7smk/metadata-file https://github.com/bp-xiao/20230330-01-gha-cache.git#f75c924dc1156e67e7e8229ddaff4b995b2b1d59
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
#1 [internal] load git source https://github.com/bp-xiao/20230330-01-gha-cache.git#f75c924dc1156e67e7e8229ddaff4b995b2b1d59
#0 0.076 Initialized empty Git repository in /var/lib/buildkit/runc-overlayfs/snapshots/snapshots/1/fs/
#1 0.151 fatal: Not a valid object name f75c924dc1156e67e7e8229ddaff4b995b2b1d59^{commit}
#1 0.769 From https://github.com/bp-xiao/20230330-01-gha-cache
#1 0.769  * [new branch]      main       -> origin/main
#1 DONE 1.0s

#2 [internal] load metadata for docker.io/library/python:3.11-slim
#2 ...

#3 [auth] library/python:pull token for registry-1.docker.io
#3 DONE 0.0s

#2 [internal] load metadata for docker.io/library/python:3.11-slim
#2 DONE 0.8s

#4 [1/2] FROM docker.io/library/python:3.11-slim@sha256:2f749ef90f54fd4b3c77cde78eec23ab5b8199d9ac84e4ced6ae523ef223ef7b
#4 resolve docker.io/library/python:3.11-slim@sha256:2f749ef90f54fd4b3c77cde78eec23ab5b8199d9ac84e4ced6ae523ef223ef7b done
#4 DONE 0.0s

#5 importing cache manifest from gha:15693311099075939781
#5 DONE 0.3s

#6 [2/2] RUN     apt-get update &&     apt-get install --no-install-recommends -y tree &&     rm -rf /var/lib/apt/lists/*
#6 CACHED

#7 exporting to GitHub cache
#7 preparing build cache for export
#7 preparing build cache for export 0.6s done
#7 DONE 0.6s

Additional info

minimal reproducible example:

mishmetall commented 1 year ago

Same issue with docker version: 20.10.25+azure-2

a11rew commented 8 months ago

Same issue with Docker v24.0.8 and Buildx v0.12.1

crazy-max commented 1 month ago

bake waits for Github Actions caches to be loaded before, and then it starts building images.

Build will still run to retrieve image metadata and solve but when a cache blob is found and match from remote GHA during build it will use it. This is what you see with

#5 importing cache manifest from gha:15693311099075939781
#5 DONE 0.3s

#6 [2/2] RUN     apt-get update &&     apt-get install --no-install-recommends -y tree &&     rm -rf /var/lib/apt/lists/*
#6 CACHED