Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ FROM scratch AS release
COPY --link --from=releaser /out/ /

FROM alpine:${ALPINE_VERSION} AS buildkit-export
RUN apk add --no-cache fuse3 git openssh pigz xz iptables ip6tables \
RUN apk add --no-cache fuse3 git git-lfs openssh pigz xz iptables ip6tables \
&& ln -s fusermount3 /usr/bin/fusermount
COPY --link examples/buildctl-daemonless/buildctl-daemonless.sh /usr/bin/
VOLUME /var/lib/buildkit
Expand Down
12 changes: 12 additions & 0 deletions source/git/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,14 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out
if err != nil {
return nil, err
}
_, err = checkoutGit.Run(ctx, "lfs", "install", "--local")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check if lfs is supported (git >= 1.8.3.1): https://github.com/git-lfs/git-lfs/wiki/Installation#requirements

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check if there are files being tracked by LFS first?

git lfs ls-files

Or maybe look for .gitattributes with filter=lfs like:

*.png filter=lfs diff=lfs merge=lfs -text

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe git lfs status?

if err != nil {
return nil, errors.Wrapf(err, "failed to install lfs for repo at %s", checkoutDir)
}
_, err = checkoutGit.Run(ctx, "config", "lfs.url", gs.src.Remote+"/info/lfs")
if err != nil {
return nil, errors.Wrapf(err, "failed to set lfs.url for remote %s", urlutil.RedactCredentials(gs.src.Remote))
}

gitCatFileBuf, err := git.Run(ctx, "cat-file", "-t", ref)
if err != nil {
Expand Down Expand Up @@ -587,6 +595,10 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out
}
}
checkoutGit := git.New(gitutil.WithWorkTree(cd), gitutil.WithGitDir(gitDir))
_, err = checkoutGit.Run(ctx, "lfs", "install", "--local")
if err != nil {
return nil, errors.Wrapf(err, "failed to install lfs for repo at %s", cd)
}
_, err = checkoutGit.Run(ctx, "checkout", ref, "--", ".")
if err != nil {
return nil, errors.Wrapf(err, "failed to checkout remote %s", urlutil.RedactCredentials(gs.src.Remote))
Expand Down