builder/Makefile

49 lines
1.4 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)
2022-12-08 20:50:29 +00:00
YYYYMMDD := $(shell date -u +%Y-%m-%d)
2022-12-08 16:22:51 +00:00
RN := sneak/builder
export DOCKER_IMAGE_CACHE_DIR := $(HOME)/Library/Caches/Docker/$(APPNAME)-$(ARCH)
2022-12-08 20:50:29 +00:00
.PHONY: default save build
2022-12-08 16:52:38 +00:00
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 19:49:42 +00:00
build:
2022-12-08 16:22:51 +00:00
docker build \
2022-12-08 20:50:29 +00:00
-t $(RN):$(GITREV)-$(shell uname -m) \
-t $(RN):latest-$(shell uname -m) \
-t $(RN):$(YYYYMMDD)-$(shell uname -m) \
-t $(RN):$(BRANCH)-$(shell uname -m) \
2022-12-08 16:22:51 +00:00
--progress plain --build-arg GITREV=$(GITREV) .
save: $(D)/latest.tzst $(D)/$(BRANCH).tzst
2022-12-08 20:50:29 +00:00
$(D)/$(BRANCH).tzst: $(D)/$(GITREV)-$(shell uname -m).tzst
2022-12-08 16:22:51 +00:00
rm -f $@
2022-12-08 20:50:29 +00:00
ln -s $(D)/$(GITREV)-$(shell uname -m).tzst $@
2022-12-08 16:22:51 +00:00
2022-12-08 20:50:29 +00:00
$(D)/latest.tzst: $(D)/$(GITREV)-$(shell uname -m).tzst
2022-12-08 16:22:51 +00:00
rm -f $@
2022-12-08 20:50:29 +00:00
ln -s $(D)/$(GITREV)-$(shell uname -m).tzst $@
2022-12-08 16:22:51 +00:00
2022-12-08 20:50:29 +00:00
$D/$(GITREV)-$(shell uname -m).tzst: build
docker image inspect $(RN):$(GITREV)-$(shell uname -m)
2022-12-08 16:22:51 +00:00
-mkdir -p "$(D)"
2022-12-08 20:50:29 +00:00
docker save $(RN):$(GITREV)-$(shell uname -m) | pv | zstdmt -19 > $@.tmp
2022-12-08 16:22:51 +00:00
mv $@.tmp $@
push:
2022-12-08 20:50:29 +00:00
docker push $(RN):$(GITREV)-$(shell uname -m)
docker push $(RN):latest-$(shell uname -m)
docker push $(RN):$(BRANCH)-$(shell uname -m)
docker push $(RN):$(YYYYMMDD)-$(shell uname -m)