Skip to content

RUN --mount=type=cache causes the whole build context to be loaded in #1072

@hach-que

Description

@hach-que

We're using buildkit because it drastically reduces the size of the build context that needs to be copied across during builds. However, it looks like RUN --mount=type=cache causes the entire build context to be copied for some reason.

Before:

COPY something /something
WORKDIR /something/
RUN go build
=> [internal] load build context                                                                                                                                                 0.1s  
=> => transferring context: 1.27MB                                                                                                                                               0.0s

After:

COPY something /something
WORKDIR /something/
RUN --mount=type=cache,target=/.cache go build
=> [internal] load build context                                                                                                                                               103.3s  
=> => transferring context: 5.28GB                                                                                                                                             103.3s
...

This is on Windows 10 with experimental features enabled in Docker.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions