docker-library / golang

Docker Official Image packaging for golang
https://golang.org
BSD 3-Clause "New" or "Revised" License
1.48k stars 510 forks source link

Install git-lfs to support Go modules with large-files #492

Closed danielorbach closed 9 months ago

danielorbach commented 1 year ago

This pull-request installs git-lfs on the Linux images to support the download of Go modules from private repositories. The following is true even for public repositories that are downloaded directly (as opposed to downloading from a module-proxy).

The Go toolchain uses the local git installation to fetch archives of modules from Git servers directly. My company commits large files using Git LFS which happen to be part of our Go module source tree. Without git-lfs installed, the local git installation does not automatically resolve those files which causes "checksum mismatch" against the committed go.sum.

@yosifkit I have tested that the generated images in-fact resolve the Issue. I'd appreciate your review. Looking for your guidance on getting this enhancement to the community,

LaurentGoderre commented 1 year ago

We usually explicitly avoid doing this and let downstream images add those. We had similar requests in the Node image for git to support package manager but if it's added in the base image it can't be removed in subsequent layers.

yosifkit commented 1 year ago

We appreciate your contribution ❤️🙇

I agree with @LaurentGoderre that the added size would not acceptable for all users of the images. While useful, git-lfs isn't a core feature of git but an extension, and as such is not expected to be installed wherever git is.

For users that need git-lfs it is as simple as apt-get (or apk) installing it or downloading it from https://github.com/git-lfs/git-lfs/releases in their custom image.

FROM golang:1.21
RUN apt-get update && apt-get install -y git-lfs && rm -rf /var/lib/apt/lists/*

Similar issue/request: https://github.com/docker-library/buildpack-deps/issues/112

danielorbach commented 1 year ago

Thank you for your response @LaurentGoderre @yosifkit !

Would you like me to amend the Docker image documentation or just leave it as is?

danielorbach commented 10 months ago

@LaurentGoderre @yosifkit Waiting on you instructions to close this pull-request...

LaurentGoderre commented 10 months ago

@danielorbach documentation on how to do this would be very welcome!

danielorbach commented 10 months ago

@LaurentGoderre I'd be glad to extend the documentation!

Can you point me to the appropriate repository? I am a bit lost regarding the many repositories involved.

LaurentGoderre commented 10 months ago

@yosifkit correct me if im wrong but I think it's this file here: https://github.com/docker-library/docs/blob/master/golang/content.md