1
0
Fork 0
mirror of https://github.com/imjasonh/kontain.me synced 2026-07-08 09:04:54 +00:00
kontain.me/cmd/git
Claude b00925bf9e
git: assert objects stay packed in the layer
Guards against a regression where go-git would unpack the fetched packfile
into loose objects, which would put the repo's whole decompressed contents in
memory.

https://claude.ai/code/session_01Jfhuuwb5haNaasc9hs53jw
2026-05-12 15:28:42 +00:00
..
build_test.go git: assert objects stay packed in the layer 2026-05-12 15:28:42 +00:00
main.go git: stream worktree into the layer instead of unpacking to disk 2026-05-12 14:54:11 +00:00
README.md
test.sh

git.kontain.me

docker pull git.kontain.me/[repo]:[ref] serves an image containing a shallow clone of [repo] (fetched over HTTPS) checked out at /git/[name], including its .git directory, on top of cgr.dev/chainguard/git:latest-dev.

The image tag [ref] is a branch, a tag, or a full commit SHA. It defaults to latest, which means the remote's default branch unless a branch or tag named latest exists. A trailing .git on [repo] is optional.

Examples

Get an image with this repo's default branch checked out at /git/kontain.me:

docker pull git.kontain.me/github.com/imjasonh/kontain.me
FROM git.kontain.me/github.com/imjasonh/kontain.me AS src
FROM alpine
COPY --from=src /git /git

A specific branch, tag, or commit:

docker pull git.kontain.me/github.com/google/go-containerregistry:main
docker pull git.kontain.me/github.com/google/go-containerregistry:v0.20.0
docker pull git.kontain.me/github.com/google/go-containerregistry:8a28419ab6b35f06f7148f3b5fc9e75b663f7e2c

Since the base image is cgr.dev/chainguard/git, the git CLI works inside the checkout:

docker run --rm git.kontain.me/github.com/imjasonh/kontain.me git log -1

Caveats

  • Branch and tag clones are shallow (--depth=1), so history isn't available. Pulling by commit SHA does a full clone first.
  • Refs with / in them (e.g. feature/foo) can't be expressed as an OCI tag; pull by commit SHA instead.
  • The image ships an /etc/gitconfig with safe.directory = * so git works in the checkout regardless of which user the container runs as.