k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cluster/images/etcd-version-monitor/Makefile (about)

     1  # Copyright 2017 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  # Build the etcd-version-monitor image
    16  #
    17  # Usage:
    18  # 	[GOLANG_VERSION=1.19.9] [REGISTRY=staging-k8s.gcr.io] [TAG=test] make (build|push)
    19  # TODO(shyamjvs): Support architectures other than amd64 if needed.
    20  ARCH:=amd64
    21  GOLANG_VERSION?=1.19.9
    22  REGISTRY?=staging-k8s.gcr.io
    23  TAG?=0.1.3
    24  IMAGE:=$(REGISTRY)/etcd-version-monitor:$(TAG)
    25  CURRENT_DIR:=$(pwd)
    26  TEMP_DIR:=$(shell mktemp -d)
    27  
    28  build:
    29  	# Copy the necessary files for building the image to TEMP_DIR.
    30  	cp etcd-version-monitor.go Dockerfile $(TEMP_DIR)
    31  
    32  	# Compile etcd-version-monitor.
    33  	docker run --rm -it \
    34  	    -v $(shell pwd)/../../../:/go/src/k8s.io/kubernetes \
    35  	    -v $(TEMP_DIR):/build \
    36  	    -e GOARCH=$(ARCH) \
    37  	    golang:$(GOLANG_VERSION) \
    38  	    /bin/bash -c "CGO_ENABLED=0 go build -o /build/etcd-version-monitor k8s.io/kubernetes/cluster/images/etcd-version-monitor"
    39  
    40  	docker build -t $(IMAGE) $(TEMP_DIR)
    41  
    42  push: build
    43  	docker push $(IMAGE)
    44  
    45  all: build
    46  
    47  .PHONY: build push