github.com/grupokindynos/coins-explorer@v0.0.0-20210507172551-fa8983d19250/Makefile (about)

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