builder/Makefile

48 lines
1.2 KiB
Makefile
Raw Normal View History

2022-12-08 16:22:51 +00:00
export DOCKER_BUILDKIT := 1
export PROGRESS_NO_TRUNC := 1
APPNAME := builder
ARCH := $(shell uname -m)
GITREV := $(shell git describe --always --dirty=-dirty)
D := $(HOME)/Documents/_SYSADMIN/docker/sneak/$(APPNAME)
BRANCH := $(shell git branch --show-current)
RN := sneak/builder
export DOCKER_IMAGE_CACHE_DIR := $(HOME)/Library/Caches/Docker/$(APPNAME)-$(ARCH)
2022-12-08 16:52:38 +00:00
.PHONY: default save build
2022-12-08 16:22:51 +00:00
default: save
2022-12-08 16:52:38 +00:00
clean:
rm -v $(D)/*.tzst
2022-12-08 16:22:51 +00:00
build: deps/modcache.tar
docker build \
-t $(RN):$(GITREV) \
-t $(RN):latest \
-t $(RN):$(shell git branch --show-current) \
--progress plain --build-arg GITREV=$(GITREV) .
save: $(D)/latest.tzst $(D)/$(BRANCH).tzst
$(D)/$(BRANCH).tzst: $(D)/$(GITREV).tzst
rm -f $@
ln -s $(D)/$(GITREV).tzst $@
$(D)/latest.tzst: $(D)/$(GITREV).tzst
rm -f $@
ln -s $(D)/$(GITREV).tzst $@
2022-12-08 16:52:38 +00:00
$D/$(GITREV).tzst: build
docker image inspect $(RN):$(GITREV)
2022-12-08 16:22:51 +00:00
-mkdir -p "$(D)"
docker save $(RN):$(GITREV) | pv | zstdmt -19 > $@.tmp
mv $@.tmp $@
push:
docker push $(RN):$(GITREV)
docker push $(RN):latest
docker push $(RN):$(shell git branch --show-current)
deps/modcache.tar:
2022-12-08 18:30:14 +00:00
cd $(shell go env GOMODCACHE)/ && tar -c . | pv > $(PWD)/deps/modcache.tar