1
0
Fork 0
mirror of https://github.com/imjasonh/kontain.me synced 2026-07-10 09:53:29 +00:00
kontain.me/cmd/git
Jason Hall 2b7bb23ae2 git: annotate the checkout layer with the resolved commit, source, and ref
gitLayer now returns the commit it checked out (dereferencing annotated
tags). build records it, the clone URL, and the ref name as
me.kontain.git.{commit,source,ref} annotations on the checkout layer's
manifest descriptor, so the commit a :branch / :tag / :latest pull
resolved to is visible from the image manifest. The test now also checks
gitLayer's returned commit matches what resolveRef resolved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 13:05:51 -04:00
..
build_test.go git: annotate the checkout layer with the resolved commit, source, and ref 2026-05-12 13:05:51 -04:00
main.go git: annotate the checkout layer with the resolved commit, source, and ref 2026-05-12 13:05:51 -04:00
README.md
test.sh git: own the checkout as the image's user so git can write to it 2026-05-12 12:45:50 -04:00

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.