github.com/whamcloud/lemur@v0.0.0-20190827193804-4655df8a52af/packaging/docker/go-el7/Makefile (about)

     1  FEDORA_GOLANG ?= $(shell curl -s http://mirrors.kernel.org/fedora/development/rawhide/Everything/source/tree/Packages/g/ | awk '/>golang-1.*\.src\.rpm</ {print $2}' | sed -E 's/.*golang-(1.*)\.src\.rpm.*/\1/')
     2  FEDORA_GOLANG_MACROS ?= $(shell curl -s http://mirrors.kernel.org/fedora/development/rawhide/Everything/x86_64/os/Packages/g/ | awk '/>go-srpm-macros.*\.noarch\.rpm</ {print $2}' | sed -E 's/.*go-srpm-macros-(.*)\.noarch\.rpm.*/\1/')
     3  REPO ?= $(notdir $(CURDIR))
     4  
     5  IMAGE := $(shell latest=$$(docker images | awk "/$(REPO).*$(FEDORA_GOLANG)/ {print \$$2}"); if [ "$$latest" == $(FEDORA_GOLANG) ]; then true; else echo $(REPO)/$(FEDORA_GOLANG); fi)
     6  
     7  RPM_OUT := $(dir $(dir $(CURDIR)))output-go-$(FEDORA_GOLANG)
     8  
     9  $(FEDORA_GOLANG): $(IMAGE)
    10  
    11  rpms: $(RPM_OUT)
    12  	@echo "Copying built RPMs to $(RPM_OUT)..."
    13  	@docker run --rm -v $(RPM_OUT):/out:z $(REPO):latest sh -c 'cp -a /root/rpmbuild/RPMS/* /out'
    14  	@echo "Copied go-$(FEDORA_GOLANG) RPMs to $(RPM_OUT)"
    15  
    16  $(RPM_OUT): $(IMAGE)
    17  	@rm -fr $@ && mkdir -p $@
    18  
    19  $(IMAGE): Dockerfile
    20  	@echo "Building $(IMAGE) for $(FEDORA_GOLANG)"
    21  	docker build -t $(subst /,:,$(IMAGE)) -t $(REPO):latest --build-arg=go_version=$(FEDORA_GOLANG) --build-arg=go_macros_version=$(FEDORA_GOLANG_MACROS) $(BUILD_VARS) .
    22  
    23  clean:
    24  	docker rmi $(subst /,:,$(IMAGE)) $(REPO):latest
    25  
    26  .PHONY: $(FEDORA_GOLANG) $(IMAGE)