github.com/abayer/test-infra@v0.0.5/images/kubekins-test/Makefile (about)

     1  # Copyright 2016 The Kubernetes Authors.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  IMG = gcr.io/k8s-testimages/kubekins-test
    16  TAG := $(shell date +v%Y%m%d)-$(shell git describe --tags --always --dirty)
    17  VERSIONS := $(wildcard ./Dockerfile-*)
    18  
    19  do_build = \
    20  	$(eval VERSION := $(subst ./Dockerfile-,,$(v)))\
    21  	docker build -f ./Dockerfile-$(VERSION) -t $(IMG):$(VERSION)-$(TAG) . ;\
    22  	docker tag $(IMG):$(VERSION)-$(TAG) $(IMG):$(VERSION)-latest ;\
    23  	echo Built $(IMG):$(VERSION)-$(TAG) and tagged with $(IMG):$(VERSION)-latest ;
    24  
    25  do_push = \
    26  	$(eval VERSION := $(subst ./Dockerfile-,,$(v)))\
    27  	docker push $(IMG):$(VERSION)-$(TAG);\
    28  	docker push $(IMG):$(VERSION)-latest;\
    29  	echo Pushed $(IMG):$(VERSION)-latest and $(IMG):$(VERSION)-$(TAG);
    30  
    31  .PHONY: all build push help
    32  
    33  all: build
    34  
    35  build:
    36  	@$(foreach v,$(VERSIONS),$(do_build))
    37  
    38  push: build
    39  	@$(foreach v,$(VERSIONS),$(do_push))
    40  
    41  help:
    42  	@echo "VARIABLES:"
    43  	@echo " VERSIONS:       Dockerfile to be built/pushed, can be either full file name or a tag"
    44  	@echo " 				- make build VERSIONS=./Dockerfile-1.4"
    45  	@echo " 				- make build VERSIONS=1.4"
    46  	@echo " 				are equivalent and both valid."
    47  	@echo ""
    48  	@echo "TARGETS:"
    49  	@echo " all:            build"
    50  	@echo " build:      	builds all the Dockerfile-* in VERSIONS"
    51  	@echo " push:       	builds all the Dockerfile-* in VERSIONS and pushes to k8s-testimages"
    52