github.com/almightyhelp/blockbook@v0.4.2-0.20210524123154-8697b01c4af9/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  ARGS ?=
     8  
     9  TARGETS=$(subst .json,, $(shell ls configs/coins))
    10  
    11  .PHONY: build build-debug test deb
    12  
    13  build: .bin-image
    14  	docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(BIN_IMAGE) make build ARGS="$(ARGS)"
    15  
    16  build-debug: .bin-image
    17  	docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(BIN_IMAGE) make build-debug ARGS="$(ARGS)"
    18  
    19  test: .bin-image
    20  	docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test ARGS="$(ARGS)"
    21  
    22  test-integration: .bin-image
    23  	docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-integration ARGS="$(ARGS)"
    24  
    25  test-all: .bin-image
    26  	docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" --network="host" $(BIN_IMAGE) make test-all ARGS="$(ARGS)"
    27  
    28  deb-backend-%: .deb-image
    29  	docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh backend $* $(ARGS)
    30  
    31  deb-blockbook-%: .deb-image
    32  	docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh blockbook $* $(ARGS)
    33  
    34  deb-%: .deb-image
    35  	docker run -t --rm -e PACKAGER=$(PACKAGER) -v "$(CURDIR):/src" -v "$(CURDIR)/build:/out" $(DEB_IMAGE) /build/build-deb.sh all $* $(ARGS)
    36  
    37  deb-blockbook-all: clean-deb $(addprefix deb-blockbook-, $(TARGETS))
    38  
    39  $(addprefix all-, $(TARGETS)): all-%: clean-deb build-images deb-%
    40  
    41  all: clean-deb build-images $(addprefix deb-, $(TARGETS))
    42  
    43  build-images: clean-images
    44  	$(MAKE) .bin-image .deb-image
    45  
    46  .bin-image:
    47  	@if [ $$(build/tools/image_status.sh $(BIN_IMAGE):latest build/docker) != "ok" ]; then \
    48  		echo "Building image $(BIN_IMAGE) from $(BASE_IMAGE)"; \
    49  		docker build --no-cache=$(NO_CACHE) --build-arg TCMALLOC=$(TCMALLOC) --build-arg BASE_IMAGE=$(BASE_IMAGE) -t $(BIN_IMAGE) build/docker/bin; \
    50  	else \
    51  		echo "Image $(BIN_IMAGE) is up to date"; \
    52  	fi
    53  
    54  .deb-image: .bin-image
    55  	@if [ $$(build/tools/image_status.sh $(DEB_IMAGE):latest build/docker) != "ok" ]; then \
    56  		echo "Building image $(DEB_IMAGE)..."; \
    57  		docker build --no-cache=$(NO_CACHE) -t $(DEB_IMAGE) build/docker/deb; \
    58  	else \
    59  		echo "Image $(DEB_IMAGE) is up to date"; \
    60  	fi
    61  
    62  clean: clean-bin clean-deb
    63  
    64  clean-all: clean clean-images
    65  
    66  clean-bin:
    67  	find build -maxdepth 1 -type f -executable -delete
    68  
    69  clean-deb:
    70  	rm -rf build/pkg-defs
    71  	rm -f build/*.deb
    72  
    73  clean-images: clean-bin-image clean-deb-image
    74  	rm -f .bin-image .deb-image  # remove obsolete tag files
    75  
    76  clean-bin-image:
    77  	- docker rmi $(BIN_IMAGE)
    78  
    79  clean-deb-image:
    80  	- docker rmi $(DEB_IMAGE)