github.com/cryptohub-digital/blockbook@v0.3.5-0.20240403155730-99ab40b9104c/Makefile (about) 1 BIN_IMAGE = blockbook-build 2 DEB_IMAGE = blockbook-build-deb 3 PACKAGER = $(shell id -u):$(shell id -g) 4 BASE_IMAGE = $$(awk -F= '$$1=="ID" { print $$2 ;}' /etc/os-release):$$(awk -F= '$$1=="VERSION_ID" { print $$2 ;}' /etc/os-release | tr -d '"') 5 NO_CACHE = false 6 TCMALLOC = 7 PORTABLE = 0 8 ARGS ?= 9 10 TARGETS=$(subst .json,, $(shell ls configs/coins)) 11 12 .PHONY: build build-debug test deb 13 14 build: .bin-image 15 docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(BIN_IMAGE) make build ARGS="$(ARGS)" 16 17 build-debug: .bin-image 18 docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(BIN_IMAGE) make build-debug ARGS="$(ARGS)" 19 20 test: .bin-image 21 docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test ARGS="$(ARGS)" 22 23 test-integration: .bin-image 24 docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-integration ARGS="$(ARGS)" 25 26 test-all: .bin-image 27 docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-all ARGS="$(ARGS)" 28 29 deb-backend-%: .deb-image 30 docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh backend $* $(ARGS) 31 32 deb-blockbook-%: .deb-image 33 docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh blockbook $* $(ARGS) 34 35 deb-%: .deb-image 36 docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh all $* $(ARGS) 37 38 deb-blockbook-all: clean-deb $(addprefix deb-blockbook-, $(TARGETS)) 39 40 $(addprefix all-, $(TARGETS)): all-%: clean-deb build-images deb-% 41 42 all: clean-deb build-images $(addprefix deb-, $(TARGETS)) 43 44 build-images: clean-images 45 $(MAKE) .bin-image .deb-image 46 47 .bin-image: 48 @if [ $$(build/tools/image_status.sh $(BIN_IMAGE):latest build/docker) != "ok" ]; then \ 49 echo "Building image $(BIN_IMAGE) from $(BASE_IMAGE)"; \ 50 docker build --no-cache=$(NO_CACHE) --build-arg TCMALLOC=$(TCMALLOC) --build-arg BASE_IMAGE=$(BASE_IMAGE) --build-arg PORTABLE_ROCKSDB=$(PORTABLE) -t $(BIN_IMAGE) build/docker/bin; \ 51 else \ 52 echo "Image $(BIN_IMAGE) is up to date"; \ 53 fi 54 55 .deb-image: .bin-image 56 @if [ $$(build/tools/image_status.sh $(DEB_IMAGE):latest build/docker) != "ok" ]; then \ 57 echo "Building image $(DEB_IMAGE)..."; \ 58 docker build --no-cache=$(NO_CACHE) -t $(DEB_IMAGE) build/docker/deb; \ 59 else \ 60 echo "Image $(DEB_IMAGE) is up to date"; \ 61 fi 62 63 clean: clean-bin clean-deb 64 65 clean-all: clean clean-images 66 67 clean-bin: 68 find build -maxdepth 1 -type f -executable -delete 69 70 clean-deb: 71 rm -rf build/pkg-defs 72 rm -f build/*.deb 73 74 clean-images: clean-bin-image clean-deb-image 75 rm -f .bin-image .deb-image # remove obsolete tag files 76 77 clean-bin-image: 78 - docker rmi $(BIN_IMAGE) 79 80 clean-deb-image: 81 - docker rmi $(DEB_IMAGE)