agones.dev/agones@v1.54.0/build/includes/build-image.mk (about)

     1  # Copyright 2019 Google LLC All Rights Reserved.
     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  #   ____        _ _     _   ___
    16  #  | __ ) _   _(_) | __| | |_ _|_ __ ___   __ _  __ _  ___
    17  #  |  _ \| | | | | |/ _` |  | || '_ ` _ \ / _` |/ _` |/ _ \
    18  #  | |_) | |_| | | | (_| |  | || | | | | | (_| | (_| |  __/
    19  #  |____/ \__,_|_|_|\__,_| |___|_| |_| |_|\__,_|\__, |\___|
    20  #                                               |___/
    21  
    22  build_remote_tag = $(REGISTRY)/$(build_tag)
    23  
    24  # Creates the build docker image
    25  build-build-image:
    26  	docker build --tag=$(build_tag) $(build_path)/build-image $(DOCKER_BUILD_ARGS)
    27  
    28  # Deletes the local build docker image
    29  clean-build-image:
    30  	docker rmi $(build_tag)
    31  
    32  ensure-arm-builder:
    33  	 docker run --privileged --rm tonistiigi/binfmt:qemu-v6.2.0 --install arm64
    34  	 
    35  ensure-build-config:
    36  	-mkdir -p $(kubeconfig_path)
    37  	-mkdir -p $(build_path)/.gocache
    38  	-mkdir -p $(build_path)/.config/gcloud
    39  	-mkdir -p $(helm_config)
    40  	-mkdir -p $(helm_cache)
    41  
    42  # create the build image if it doesn't exist
    43  ensure-build-image: ensure-build-config
    44  	$(MAKE) ensure-image IMAGE_TAG=$(build_tag) BUILD_TARGET=build-build-image
    45  ifeq ($(WITH_ARM64), 1) 
    46  ensure-build-image: ensure-arm-builder
    47  endif
    48  
    49  # attempt to pull the image, if it exists and rename it to the local tag
    50  # exit's clean if it doesn't exist, so can be used on CI
    51  pull-build-image:
    52  	$(MAKE) pull-remote-build-image REMOTE_TAG=$(build_remote_tag) LOCAL_TAG=$(build_tag)
    53  
    54  tag-build-image:
    55  	docker tag $(build_tag) $(CUSTOM_LOCAL_TAG)
    56  
    57  # push the local build image up to your repository
    58  push-build-image:
    59  	$(MAKE) push-remote-build-image REMOTE_TAG=$(build_remote_tag) LOCAL_TAG=$(build_tag)
    60  
    61  # ensure passed in image exists, if not, run the target
    62  ensure-image:
    63  	@if [ -z $$(docker images -q $(IMAGE_TAG)) ]; then\
    64  		echo "Could not find $(IMAGE_TAG) image. Building...";\
    65  		$(MAKE) $(BUILD_TARGET);\
    66  	fi
    67  
    68  # push a local build image up to a remote repository
    69  push-remote-build-image:
    70  	docker tag $(LOCAL_TAG) $(REMOTE_TAG)
    71  	docker push $(REMOTE_TAG)
    72  
    73  # pull a local image that may exist on a remote repository, to a local image
    74  pull-remote-build-image:
    75  	-docker pull $(REMOTE_TAG) && docker tag $(REMOTE_TAG) $(LOCAL_TAG)
    76  
    77  ensure-agones-sdk-image:
    78  	$(MAKE) ensure-image IMAGE_TAG=$(sidecar_linux_amd64_tag) BUILD_TARGET=build-agones-sdk-image