initial commit

This commit is contained in:
Lance Vick 2024-01-27 18:39:41 -08:00
commit cf491a2743
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
3 changed files with 102 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
out*
run*

63
Makefile Normal file
View File

@ -0,0 +1,63 @@
default: env-test
@make -f test.mk OUT=out2
@make -f test.mk OUT=out1
@printf "Docker Version: %s\n" "$(shell docker --version)"
@printf "Docker Image Store: %s\n" "$(shell docker info -f '{{ .DriverStatus }} ')"
@for f in out1 out2; do \
printf "%-35s" "$${f} - docker save archive hash: "; \
sha256sum $${f}/dockersave.tar | awk '{ print $$1 }'; \
done
@for f in out1 out2; do \
printf "%-35s" "$${f} - docker buildx archive hash: "; \
sha256sum $${f}/buildx.tar | awk '{ print $$1 }'; \
done
@for f in out1 out2; do \
printf "%-35s" "$${f} - docker save digest: "; \
tar -xf $${f}/dockersave.tar index.json -O | jq -r '.manifests[].digest | sub("sha256:";"")'; \
done
@for f in out1 out2; do \
printf "%-35s" "$${f} - docker buildx digest: "; \
tar -xf $${f}/buildx.tar index.json -O | jq -r '.manifests[].digest | sub("sha256:";"")'; \
done
@diffoscope --exclude-directory-metadata=yes out1 out2
.PHONY: clean
clean:
docker container rm -f $$(cat $(OUT)/registry.id)
docker buildx rm digest-test
rm -rf out1 out2
.PHONY: env-test
env-test:
which jq
which docker
run:
mkdir $@
run/registry.id: run
docker container create \
--publish 5000:5000 \
--restart always \
--name test-registry \
registry:2 \
> $@
run/registry.run: run/registry.id
docker container start $$(cat run/registry.id)
touch $@
run/driver.run: run
docker buildx create \
--name digest-test \
--driver docker-container \
--node digest-test
docker buildx use digest-test
touch $@
run/driver.run: run
docker buildx create \
--name digest-test \
--driver docker-container \
--node digest-test
touch $@

37
test.mk Normal file
View File

@ -0,0 +1,37 @@
OUT =: $(OUT)
default: all
.PHONY: all
all: $(OUT)/dockersave.tar $(OUT)/buildx.tar $(OUT)/metadata.json
touch -hcd "@0" $(OUT)/*
sha256sum $(OUT)/dockersave.tar
sha256sum $(OUT)/buildx.tar
$(OUT):
mkdir -p $(OUT)
$(OUT)/Dockerfile $(OUT)/noopfile: $(OUT)
printf "from scratch\nADD noopfile ." > $(OUT)/Dockerfile
printf "1" > $(OUT)/noopfile
touch -hcd "@0" $(OUT)/noopfile
$(OUT)/buildx.tar $(OUT)/buildx_metadata.json: $(OUT)/Dockerfile
DOCKER_BUILDKIT=1 \
SOURCE_DATE_EPOCH=1 \
/bin/docker buildx build \
--tag local/digest-test \
--no-cache \
--metadata-file $(OUT)/metadata.json \
--output type=oci,force-compression=true,name=local/digest-test,dest=$(OUT)/buildx.tar \
$(OUT)
$(OUT)/dockersave.tar: $(OUT)/Dockerfile
DOCKER_BUILDKIT=1 \
SOURCE_DATE_EPOCH=1 \
/bin/docker buildx build \
--tag local/digest-test \
--no-cache \
--load \
$(OUT)
docker save local/digest-test -o $@