agones.dev/agones@v1.53.0/build/Makefile (about)

     1  # Copyright 2017 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  # Makefile for building, testing and developing Agones
    17  #
    18  
    19  #  __     __         _       _     _
    20  #  \ \   / /_ _ _ __(_) __ _| |__ | | ___ ___
    21  #   \ \ / / _` | '__| |/ _` | '_ \| |/ _ \ __|
    22  #    \ V / (_| | |  | | (_| | |_) | |  __\__ \
    23  #     \_/ \__,_|_|  |_|\__,_|_.__/|_|\___|___/
    24  #
    25  
    26  # base version target. This is usually the next release.
    27  base_version = 1.53.0
    28  
    29  #
    30  # All of the following can be overwritten with environment variables
    31  # or passed through directly when invoking the relevent Make targets
    32  #
    33  
    34  # Version defaults to the short hash of the latest commit
    35  VERSION ?= $(base_version)-dev-$(shell git rev-parse --short=7 HEAD)
    36  
    37  # kubectl configuration to use
    38  KUBECONFIG ?= ~/.kube/config
    39  # The (gcloud) test cluster that is being worked against
    40  GCP_CLUSTER_NAME ?= test-cluster
    41  GCP_CLUSTER_ZONE ?= us-west1-c
    42  GCP_CLUSTER_LOCATION ?= $(GCP_CLUSTER_ZONE)
    43  GCP_BUCKET_CHARTS ?= agones-chart
    44  # the profile to use when developing on minikube
    45  MINIKUBE_PROFILE ?= agones
    46  GO_BUILD_TAGS ?= none
    47  BUILDX_WINDOWS_BUILDER = windows-builder
    48  BUILDX_ARM64_BUILDER = arm64-builder
    49  WINDOWS_DOCKER_PUSH_ARGS =
    50  # Versions of Windows Server to support, default is Windows Server 2019.
    51  # For the full list of tags see https://hub.docker.com/_/microsoft-windows-servercore.
    52  # GKE-Windows version map: https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows#version_mapping
    53  WINDOWS_VERSIONS = ltsc2019 ltsc2022
    54  
    55  # https://github.com/microsoft/Windows-Containers/issues/493: Pin the LTSC2019 image to an older sha
    56  LTSC2019_IMAGE_TAG = "@sha256:6fdf140282a2f809dae9b13fe441635867f0a27c33a438771673b8da8f3348a4"
    57  
    58  BASE.windows := mcr.microsoft.com/windows/servercore
    59  
    60  # Specify stress test level 1..100
    61  # STRESS_TEST_LEVEL=n requires capacity between 50*n up to 100*n simple-game-server Game Servers.
    62  STRESS_TEST_LEVEL ?= 20
    63  
    64  # kind cluster name to use
    65  KIND_PROFILE ?= agones
    66  KIND_CONTAINER_NAME=$(KIND_PROFILE)-control-plane
    67  
    68  # Game Server image to use while doing end-to-end tests
    69  GS_TEST_IMAGE ?= us-docker.pkg.dev/agones-images/examples/simple-game-server:0.39
    70  
    71  # Enable all beta feature gates. Keep in sync with `true` (beta) entries in pkg/util/runtime/features.go:featureDefaults
    72  BETA_FEATURE_GATES ?= "AutopilotPassthroughPort=true&CountsAndLists=true&GKEAutopilotExtendedDurationPods=true&PortPolicyNone=true&PortRanges=true&RollingUpdateFix=true&ScheduledAutoscaler=true"
    73  
    74  
    75  # Enable all alpha feature gates. Keep in sync with `false` (alpha) entries in pkg/util/runtime/features.go:featureDefaults
    76  ALPHA_FEATURE_GATES ?= "PlayerAllocationFilter=true&FleetAutoscaleRequestMetaData=true&PlayerTracking=true&SidecarContainers=true&WasmAutoscaler=true&Example=true"
    77  
    78  # Build with Windows support
    79  WITH_WINDOWS=1
    80  # Build with arm64support
    81  WITH_ARM64=1
    82  
    83  # Directory that this Makefile is in.
    84  mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
    85  build_path := $(dir $(mkfile_path))
    86  agones_path := $(realpath $(build_path)/..)
    87  site_path := $(agones_path)/site
    88  
    89  kubeconfig_path := $(dir $(KUBECONFIG))
    90  kubeconfig_file := $(notdir $(KUBECONFIG))
    91  
    92  helm_config := ~/.config/helm
    93  helm_cache := ~/.cache/helm
    94  
    95  agones_package = agones.dev/agones
    96  mount_path = /go/src/$(agones_package)
    97  common_mounts = -v $(build_path)/.config/gcloud:/root/.config/gcloud \
    98  				-v $(kubeconfig_path):/root/.kube \
    99  				-v $(helm_config):/root/.config/helm \
   100  				-v $(helm_cache):/root/.cache/helm \
   101  				-v $(agones_path):$(mount_path) \
   102  				-v $(build_path)/.gomod:/go/pkg/mod
   103  
   104  # Its possible for this to change in the future, so it gets its own variable.
   105  REGISTRY ?= local
   106  CHARTS_REGISTRY ?=
   107  workdir_path = $(mount_path)
   108  
   109  build_version = $(call sha,$(build_path)/build-image/Dockerfile)
   110  build_tag = agones-build:$(build_version)
   111  controller_tag = $(REGISTRY)/agones-controller:$(VERSION)
   112  extensions_tag = $(REGISTRY)/agones-extensions:$(VERSION)
   113  sidecar_tag = $(REGISTRY)/agones-sdk:$(VERSION)
   114  allocator_tag = $(REGISTRY)/agones-allocator:$(VERSION)
   115  ping_tag = $(REGISTRY)/agones-ping:$(VERSION)
   116  processor_tag = $(REGISTRY)/agones-processor:$(VERSION)
   117  
   118  ifeq ($(WITH_WINDOWS), 1)
   119  sidecar_linux_amd64_tag = $(REGISTRY)/agones-sdk:$(VERSION)-linux-amd64
   120  sidecar_linux_arm64_tag = $(REGISTRY)/agones-sdk:$(VERSION)-linux-arm64
   121  else
   122  sidecar_linux_amd64_tag = $(REGISTRY)/agones-sdk:$(VERSION)-amd64
   123  sidecar_linux_arm64_tag = $(REGISTRY)/agones-sdk:$(VERSION)-arm64
   124  endif
   125  
   126  allocator_amd64_tag = $(allocator_tag)-amd64
   127  allocator_arm64_tag = $(allocator_tag)-arm64
   128  controller_amd64_tag = $(controller_tag)-amd64
   129  controller_arm64_tag = $(controller_tag)-arm64
   130  extensions_amd64_tag = $(extensions_tag)-amd64
   131  extensions_arm64_tag = $(extensions_tag)-arm64
   132  ping_amd64_tag = $(ping_tag)-amd64
   133  ping_arm64_tag = $(ping_tag)-arm64
   134  processor_amd64_tag = $(processor_tag)-amd64
   135  processor_arm64_tag = $(processor_tag)-arm64
   136  
   137  # build list of images to include in the manifest for the sidecar image.
   138  push_sidecar_manifest = $(sidecar_linux_amd64_tag)
   139  push_allocator_manifest = $(allocator_amd64_tag)
   140  push_controller_manifest = $(controller_amd64_tag)
   141  push_extensions_manifest = $(extensions_amd64_tag)
   142  push_ping_manifest = $(ping_amd64_tag)
   143  push_processor_manifest = $(processor_amd64_tag)
   144  
   145  gomod_on = GO111MODULE=on
   146  
   147  go_version_flags = -ldflags "-X agones.dev/agones/pkg.Version=$(VERSION)"
   148  DOCKER_RUN ?= docker run --rm $(common_mounts) -e "KUBECONFIG=/root/.kube/$(kubeconfig_file)" -e "$(gomod_on)" -w $(workdir_path) $(DOCKER_RUN_ARGS) $(build_tag)
   149  
   150  ifdef DOCKER_RUN
   151  	ensure-build-image += ensure-build-image
   152  endif
   153  
   154  git_safe = git config --global --add safe.directory $(mount_path)
   155  
   156  # When performing full build, always rebuild go packages and compress more
   157  ifdef FULL_BUILD
   158  	go_rebuild_flags = -a
   159  	zip_flags = -9
   160  endif
   161  
   162  ifndef FULL_BUILD
   163  	# keep a cache of files built by Go across docker invocations in a local directory.
   164  	common_mounts += -v $(build_path)/.gocache:/root/.cache/go-build
   165  	go_rebuild_flags =
   166  
   167  	# do not compress files in zips, slightly faster
   168  	zip_flags = -0
   169  endif
   170  
   171  go_build_cmd = go build -mod=vendor -buildvcs=false
   172  GO_BUILD_LINUX_AMD64=docker run --rm -e "CGO_ENABLED=0" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd)
   173  GO_BUILD_LINUX_ARM64=docker run --rm -e "CGO_ENABLED=0" -e "GOOS=linux" -e "GOARCH=arm64" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd)
   174  GO_BUILD_DARWIN_AMD64=docker run --rm -e "GOOS=darwin" -e "GOARCH=amd64" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd)
   175  GO_BUILD_DARWIN_ARM64=docker run --rm -e "GOOS=darwin" -e "GOARCH=arm64" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd)
   176  GO_BUILD_WINDOWS_AMD64=docker run --rm -e "GOOS=windows" -e "GOARCH=amd64" -e "$(gomod_on)" -w $(workdir_path) $(common_mounts) $(build_tag) $(go_build_cmd)
   177  
   178  RACE_DETECTOR_ARGS=-race
   179  
   180  ifdef NO_RACE_DETECTOR
   181    RACE_DETECTOR_ARGS=
   182  endif
   183  
   184  go_test_args = -mod=vendor $(RACE_DETECTOR_ARGS)
   185  go_test_cmd = go test $(go_test_args)
   186  GO_TEST=$(DOCKER_RUN) $(go_test_cmd)
   187  GO_E2E_TEST_ARGS=--kubeconfig /root/.kube/$(kubeconfig_file)
   188  
   189  gotestsum_json=/tmp/agones.gotestsum.json
   190  ifdef GOTESTSUM_VERBOSE
   191  gotestsum_format=--format=testname \
   192    --post-run-command="sh -c 'echo; echo --- RAW VERBOSE OUTPUT ---; jq -j \"select(.Output != null) | (\\\"VERBOSE: \\\" + .Output)\" < $(gotestsum_json); echo --- END RAW VERBOSE OUTPUT ---'"
   193  else
   194  gotestsum_format=--format=standard-quiet
   195  endif
   196  gotestsum_cmd=gotestsum $(gotestsum_format) --jsonfile=$(gotestsum_json) --hide-summary=skipped --rerun-fails=2 $(GOTESTSUM_ARGS)
   197  GOTESTSUM=$(DOCKER_RUN) $(gotestsum_cmd)
   198  
   199  PERF_OUTPUT_DIR=$(mount_path)/build/.perf
   200  
   201  go_build_base_path=$(mount_path)
   202  
   203  ifdef LOCAL_GO
   204  	# use local Go tooling, which greatly speeds up incremental rebuilds, in particular on macOS
   205  	# Note that agones.dev must be in GOPATH
   206  	GO_BUILD_LINUX_AMD64=CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(gomod_on) $(go_build_cmd)
   207  	GO_BUILD_WINDOWS_AMD64=GOOS=windows GOARCH=amd64 $(gomod_on) $(go_build_cmd)
   208  	GO_BUILD_DARWIN_AMD64=GOOS=darwin GOARCH=amd64 $(gomod_on) $(go_build_cmd)
   209  	GO_TEST=$(go_test_cmd) -v
   210  	GOTESTSUM=$(gotestsum_cmd)
   211  	GO_E2E_TEST_ARGS=
   212  	PERF_OUTPUT_DIR=$(build_path)/.perf
   213  	go_build_base_path=$(agones_path)
   214  endif
   215  
   216  ZIP_SDK=docker run --rm $(common_mounts) -w $(workdir_path)/cmd/sdk-server/bin/ $(build_tag) zip $(zip_flags)
   217  ifdef LOCAL_ZIP
   218  	ZIP_SDK=cd $(agones_path)/cmd/sdk-server/bin && zip -0
   219  endif
   220  
   221  unameprocessor := $(shell uname -p)
   222  ifeq ($(unameprocessor),arm)
   223  	DOCKER_BUILD_ARGS += --platform linux/x86_64
   224  	DOCKER_RUN_ARGS += --platform linux/x86_64
   225  endif
   226  
   227  #    ___  ____    ___            _           _
   228  #   / _ \/ ___|  |_ _|_ __   ___| |_   _  __| | ___
   229  #  | | | \___ \   | || '_ \ / __| | | | |/ _` |/ _ \
   230  #  | |_| |___) |  | || | | | (__| | |_| | (_| |  __/
   231  #   \___/|____/  |___|_| |_|\___|_|\__,_|\__,_|\___|
   232  #
   233  
   234  uname := $(shell uname -s)
   235  ifneq ($(findstring Microsoft,$(shell uname -r)),)
   236  	osinclude := windows.mk
   237  else ifeq ($(uname),Linux)
   238  	osinclude := linux.mk
   239  else ifeq ($(uname),Darwin)
   240  	osinclude := macos.mk
   241  endif
   242  
   243  include ./includes/$(osinclude)
   244  
   245  #   ___            _           _
   246  #  |_ _|_ __   ___| |_   _  __| | ___ ___
   247  #   | || '_ \ / __| | | | |/ _` |/ _ \ __|
   248  #   | || | | | (__| | |_| | (_| |  __\__ \
   249  #  |___|_| |_|\___|_|\__,_|\__,_|\___|___/
   250  #
   251  
   252  # personal includes, excluded from the git repository
   253  -include ./local-includes/*.mk
   254  
   255  include ./includes/build-image.mk
   256  include ./includes/release.mk
   257  include ./includes/google-cloud.mk
   258  include ./includes/minikube.mk
   259  include ./includes/kind.mk
   260  include ./includes/website.mk
   261  include ./includes/sdk.mk
   262  include ./includes/allocation.mk
   263  include ./includes/examples.mk
   264  
   265  #   _____                    _
   266  #  |_   _|_ _ _ __ __ _  ___| |_ ___
   267  #    | |/ _` | '__/ _` |/ _ \ __/ __|
   268  #    | | (_| | | | (_| |  __/ |_\__ \
   269  #    |_|\__,_|_|  \__, |\___|\__|___/
   270  #                 |___/
   271  
   272  # Dynamic variables that impact targets below.
   273  # Do not move as these need to be evaluated after the `local-includes` folder to allow for local override.
   274  
   275  ifeq ($(WITH_WINDOWS), 1)
   276  push_sidecar_manifest += $(foreach windows_version, $(WINDOWS_VERSIONS), $(sidecar_tag)-windows_amd64-$(windows_version))
   277  endif
   278  ifeq ($(WITH_ARM64), 1)
   279  push_sidecar_manifest += $(sidecar_linux_arm64_tag)
   280  push_allocator_manifest += $(allocator_arm64_tag)
   281  push_controller_manifest += $(controller_arm64_tag)
   282  push_extensions_manifest += $(extensions_arm64_tag)
   283  push_ping_manifest += $(ping_arm64_tag)
   284  push_processor_manifest += $(processor_arm64_tag)
   285  endif
   286  
   287  # build all
   288  build: build-images build-sdks
   289  
   290  # build the docker images
   291  build-images: build-controller-image build-extensions-image build-agones-sdk-image build-ping-image build-allocator-image build-processor-image
   292  
   293  # package the current agones helm chart
   294  build-chart: RELEASE_VERSION ?= $(base_version)
   295  build-chart: CHART_DIR ?= install/helm/agones/
   296  build-chart: $(ensure-build-image)
   297  	docker run --rm $(common_mounts) -w $(workdir_path) $(build_tag) bash -c \
   298  		"mkdir -p install/helm/bin/ && rm -rf install/helm/bin/* && \
   299  			helm package -d install/helm/bin/ --version $(RELEASE_VERSION) $(CHART_DIR)"
   300  
   301  # push a specific release useful to push previous missing release
   302  push-release-chart: RELEASE_VERSION ?= $(base_version)
   303  push-release-chart: $(ensure-build-image)
   304  	rm -rf /tmp/agones $(agones_path)/install/.helm-$(RELEASE_VERSION)/
   305  	mkdir -p $(agones_path)/install/.helm-$(RELEASE_VERSION)/
   306  	cd /tmp && git clone --single-branch -b release-$(RELEASE_VERSION) git@github.com:googleforgames/agones.git
   307  	mv /tmp/agones/install/helm/agones $(agones_path)/install/.helm-$(RELEASE_VERSION)/
   308  	CHART_DIR=install/.helm-$(RELEASE_VERSION)/agones $(MAKE) push-chart
   309  
   310  # Run all tests
   311  test: $(ensure-build-image) test-go test-sdks test-install-yaml site-test helm-lint test-build-scripts
   312  
   313  # Run go tests
   314  test-go: $(ensure-build-image)
   315  	$(GO_TEST) $(agones_package)/pkg/... \
   316  	    $(agones_package)/sdks/... $(agones_package)/cmd/...
   317  
   318  # Run unit tests for all build scripts. Run script tests that have their own Go module separately.
   319  test-build-scripts: $(ensure-build-image)
   320  	$(GO_TEST) $(agones_package)/build/scripts/...
   321  	$(DOCKER_RUN) bash -c "cd build/scripts/previousversion && go test -v ."
   322  	$(DOCKER_RUN) bash -c "cd build/scripts/site-config-update-version && go test -v ."
   323  
   324  # Runs end-to-end tests on the current configured cluster
   325  # For minikube user the minikube-test-e2e targets
   326  test-e2e:
   327  	$(MAKE) DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS)" test-e2e-integration
   328  	$(MAKE) DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS)" test-e2e-failure
   329  	$(MAKE) DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS)" test-e2e-ha-extensions
   330  	$(MAKE) DOCKER_RUN_ARGS="$(DOCKER_RUN_ARGS)" test-e2e-allocator-crash
   331  
   332  
   333  # e2e test args:
   334  # - Use ARGS to pass args to `go test` (but not the test binary itself)
   335  # - Use GO_E2E_TEST_ARGS to pass args to the test binary
   336  # - When E2E_USE_GOTESTSUM is enabled, use GOTESTSUM_ARGS to pass args to gotestsum
   337  # If GAMESERVERS_NAMESPACE is empty - random namespace will be created
   338  test-e2e-integration: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES)
   339  test-e2e-integration: CLOUD_PRODUCT ?= generic
   340  test-e2e-integration: GAMESERVERS_NAMESPACE ?= ""
   341  test-e2e-integration: GO_E2E_TEST_INTEGRATION_ARGS ?=\
   342    --cloud-product=$(CLOUD_PRODUCT) \
   343    --gameserver-image=$(GS_TEST_IMAGE) \
   344    --pullsecret=$(IMAGE_PULL_SECRET) \
   345    --feature-gates=$(FEATURE_GATES) \
   346    --namespace=$(GAMESERVERS_NAMESPACE)
   347  test-e2e-integration: $(ensure-build-image)
   348  	echo "Starting e2e integration test!"
   349  ifdef E2E_USE_GOTESTSUM
   350  	$(GOTESTSUM) --packages=$(agones_package)/test/e2e -- $(go_test_args) -timeout=45m $(ARGS) -args \
   351  		$(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS)
   352  else
   353  	$(GO_TEST) -timeout=30m $(ARGS) $(agones_package)/test/e2e -args \
   354  	    $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS)
   355  endif
   356  	echo "Finishing e2e integration test!"
   357  
   358  test-e2e-failure: CLOUD_PRODUCT ?= generic
   359  test-e2e-failure: GO_E2E_TEST_INTEGRATION_ARGS ?=\
   360  	--cloud-product=$(CLOUD_PRODUCT) \
   361  	--gameserver-image=$(GS_TEST_IMAGE) \
   362  	--pullsecret=$(IMAGE_PULL_SECRET)
   363  test-e2e-failure: $(ensure-build-image)
   364  	echo "Starting e2e controller failure test!"
   365  ifdef E2E_USE_GOTESTSUM
   366  	$(GOTESTSUM) --packages=$(agones_package)/test/e2e/controller -- $(go_test_args) $(ARGS) -parallel=1 -args \
   367  		$(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS)
   368  else
   369  	$(GO_TEST) $(ARGS) -parallel=1 $(agones_package)/test/e2e/controller -args \
   370  	    $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS)
   371  endif
   372  	echo "Finishing e2e controller failure test!"
   373  
   374  test-e2e-ha-extensions: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES)
   375  test-e2e-ha-extensions: CLOUD_PRODUCT ?= generic
   376  test-e2e-ha-extensions: GO_E2E_TEST_INTEGRATION_ARGS ?=\
   377  	--cloud-product=$(CLOUD_PRODUCT) \
   378  	--gameserver-image=$(GS_TEST_IMAGE) \
   379  	--feature-gates=$(FEATURE_GATES) \
   380  	--pullsecret=$(IMAGE_PULL_SECRET)
   381  test-e2e-ha-extensions: $(ensure-build-image)
   382  	echo "Starting e2e extensions high availability test!"
   383  ifdef E2E_USE_GOTESTSUM
   384  	$(GOTESTSUM) --packages=$(agones_package)/test/e2e/extensions -- $(go_test_args) $(ARGS) -parallel=1 -args \
   385  		$(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS)
   386  else
   387  	$(GO_TEST) $(ARGS) -parallel=1 $(agones_package)/test/e2e/extensions -args \
   388  	    $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS)
   389  endif
   390  	echo "Finishing e2e extensions high availability test!"
   391  
   392  test-e2e-allocator-crash: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES)
   393  test-e2e-allocator-crash: CLOUD_PRODUCT ?= generic
   394  test-e2e-allocator-crash: GO_E2E_TEST_INTEGRATION_ARGS ?=\
   395  	--cloud-product=$(CLOUD_PRODUCT) \
   396  	--gameserver-image=$(GS_TEST_IMAGE) \
   397  	--feature-gates=$(FEATURE_GATES) \
   398  	--pullsecret=$(IMAGE_PULL_SECRET)
   399  test-e2e-allocator-crash: $(ensure-build-image)
   400  	echo "Starting e2e allocation pod deletion test!"
   401  ifdef E2E_USE_GOTESTSUM
   402  	$(GOTESTSUM) --packages=$(agones_package)/test/e2e/allocator -- $(go_test_args) $(ARGS) -parallel=1 -args \
   403  		$(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS)
   404  else
   405  	$(GO_TEST) $(ARGS) -parallel=1 $(agones_package)/test/e2e/allocator -args \
   406  	    $(GO_E2E_TEST_ARGS) $(GO_E2E_TEST_INTEGRATION_ARGS)
   407  endif
   408  	echo "Finishing e2e allocation pod deletion test!"
   409  
   410  # Runs end-to-end stress tests on the current configured cluster
   411  # For minikube user the minikube-stress-test-e2e targets
   412  stress-test-e2e: $(ensure-build-image)
   413  	$(GO_TEST) $(agones_package)/test/e2e $(ARGS) \
   414  		-timeout 1h \
   415  		-run '.*StressTest.*' \
   416  		-args \
   417  		$(GO_E2E_TEST_ARGS) \
   418  		--gameserver-image=$(GS_TEST_IMAGE) \
   419  		--pullsecret=$(IMAGE_PULL_SECRET) \
   420  		--stress $(STRESS_TEST_LEVEL) \
   421  		--perf-output $(PERF_OUTPUT_DIR) \
   422  		--version $(VERSION)
   423  
   424  # Run test on install yaml - make sure there is no change
   425  # mostly this is for CI
   426  test-install-yaml:
   427  	-mkdir -p /tmp/agones-install
   428  	cp $(agones_path)/install/yaml/install.yaml /tmp/agones-install/install.yaml
   429  	sort /tmp/agones-install/install.yaml > /tmp/agones-install/install.yaml.sorted
   430  	$(MAKE) gen-install
   431  	sort $(agones_path)/install/yaml/install.yaml > /tmp/agones-install/install.current.yaml.sorted
   432  	diff /tmp/agones-install/install.yaml.sorted /tmp/agones-install/install.current.yaml.sorted
   433  
   434  # Push all the images up to $(REGISTRY)
   435  push: push-controller-image push-extensions-image push-agones-sdk-image push-ping-image push-allocator-image push-processor-image
   436  
   437  # Installs the current development version of Agones into the Kubernetes cluster
   438  install: ALWAYS_PULL_SIDECAR := true
   439  install: IMAGE_PULL_POLICY := "Always"
   440  install: PING_SERVICE_TYPE := "LoadBalancer"
   441  install: ALLOCATOR_SERVICE_TYPE := "LoadBalancer"
   442  install: CRD_CLEANUP := true
   443  install: LOG_LEVEL := "debug"
   444  install: EXTERNAL_IP ?= $(shell $(DOCKER_RUN) kubectl get services agones-allocator -n agones-system -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
   445  install: FEATURE_GATES ?= $(ALPHA_FEATURE_GATES)
   446  install: SERVICE_MONITOR := false
   447  install: HELM_ARGS ?=
   448  install: $(ensure-build-image) install-custom-pull-secret
   449  	-$(DOCKER_RUN) bash -c '[[ $$(helm status agones -n agones-system --output json | jq -r ".info.status") =~ (failed|pending-.*) ]] && helm uninstall agones --namespace=agones-system || true'
   450  	$(DOCKER_RUN) \
   451  		helm upgrade --install --atomic --wait --timeout 10m --namespace=agones-system \
   452  		--create-namespace \
   453  		--set agones.image.tag=$(VERSION),agones.image.registry=$(REGISTRY) \
   454  		--set agones.image.controller.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.controller.pullSecret=$(IMAGE_PULL_SECRET) \
   455  		--set agones.image.extensions.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.allocator.pullPolicy=$(IMAGE_PULL_POLICY) \
   456  		--set agones.image.ping.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.sdk.alwaysPull=$(ALWAYS_PULL_SIDECAR) \
   457  		--set agones.ping.http.serviceType=$(PING_SERVICE_TYPE),agones.ping.udp.serviceType=$(PING_SERVICE_TYPE) \
   458  		--set agones.allocator.service.serviceType=$(ALLOCATOR_SERVICE_TYPE) \
   459  		--set agones.controller.logLevel=$(LOG_LEVEL) \
   460  		--set agones.crds.cleanupOnDelete=$(CRD_CLEANUP) \
   461  		--set agones.featureGates=$(FEATURE_GATES) \
   462  		--set agones.allocator.service.loadBalancerIP=$(EXTERNAL_IP) \
   463  		--set agones.metrics.serviceMonitor.enabled=$(SERVICE_MONITOR) \
   464  		$(HELM_ARGS) \
   465  		agones $(mount_path)/install/helm/agones/
   466  
   467  update-allocation-certs: NAMESPACE ?= default
   468  update-allocation-certs: install
   469  update-allocation-certs:
   470  	-mkdir -p $(agones_path)/build/allocation
   471  	$(DOCKER_RUN) bash -c 'kubectl get secret allocator-client.default -n $(NAMESPACE) -ojsonpath="{.data.tls\.crt}" | base64 -d > $(mount_path)/build/allocation/client.crt'
   472  	$(DOCKER_RUN) bash -c 'kubectl get secret allocator-client.default -n $(NAMESPACE) -ojsonpath="{.data.tls\.key}" | base64 -d > $(mount_path)/build/allocation/client.key'
   473  	$(DOCKER_RUN) bash -c 'kubectl get secret allocator-tls-ca -n agones-system -ojsonpath="{.data.tls-ca\.crt}" | base64 -d > $(mount_path)/build/allocation/ca.crt'
   474  
   475  uninstall: $(ensure-build-image)
   476  	$(DOCKER_RUN) \
   477  		helm uninstall agones --namespace=agones-system
   478  
   479  # Build a static binary for the gameserver controller
   480  ifeq ($(WITH_ARM64), 1)
   481  build-controller-binary: $(ensure-build-image) build-controller-binary-linux-amd64 build-controller-binary-linux-arm64
   482  else
   483  build-controller-binary: $(ensure-build-image) build-controller-binary-linux-amd64
   484  endif
   485  
   486  build-controller-binary-linux-amd64: $(ensure-build-image)
   487  	$(GO_BUILD_LINUX_AMD64) \
   488  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/controller/bin/controller.linux.amd64 \
   489  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/controller
   490  build-controller-binary-linux-arm64: $(ensure-build-image)
   491  	$(GO_BUILD_LINUX_ARM64) \
   492  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/controller/bin/controller.linux.arm64 \
   493  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/controller
   494  
   495  # Build a static binary for the gamerserver extensions
   496  ifeq ($(WITH_ARM64), 1)
   497  build-extensions-binary: $(ensure-build-image) build-extensions-binary-linux-amd64 build-extensions-binary-linux-arm64
   498  else
   499  build-extensions-binary: $(ensure-build-image) build-extensions-binary-linux-amd64
   500  endif
   501  
   502  build-extensions-binary-linux-amd64: $(ensure-build-image)
   503  	$(GO_BUILD_LINUX_AMD64) \
   504  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/extensions/bin/extensions.linux.amd64 \
   505  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/extensions
   506  build-extensions-binary-linux-arm64: $(ensure-build-image)
   507  	$(GO_BUILD_LINUX_ARM64) \
   508  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/extensions/bin/extensions.linux.arm64 \
   509  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/extensions
   510  
   511  # Lint the go source code and yaml files.
   512  # use LINT_TIMEOUT to manipulate the linter timeout
   513  lint: LINT_TIMEOUT ?= 15m
   514  lint: $(ensure-build-image)
   515  	docker run -t -e "TERM=xterm-256color" -e "$(gomod_on)" --rm $(common_mounts) -w $(workdir_path) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
   516  		"$(git_safe) && \
   517  		golangci-lint run ./examples/... && \
   518  		golangci-lint run --timeout $(LINT_TIMEOUT) ./... && \
   519  		yamllint ."
   520  
   521  # Extract licenses from source tree
   522  build-licenses:
   523  	docker run --rm $(common_mounts) $(build_tag) $(mount_path)/build/extract-licenses.sh
   524  
   525  # Tarball source for dependencies that are required to be distributed with the image (MPL)
   526  build-required-src-dist:
   527  	docker run --rm $(common_mounts) $(build_tag) $(mount_path)/build/build-required-src-dist.sh
   528  
   529  # Create docker builder used in creating arm64 images
   530  # According to the docker documentation, to build the images for ARM64 arch CPU
   531  # we would need to use buildx command which uses builder https://docs.docker.com/desktop/multi-arch/
   532  # We primarily need this for M1 Macs, see: https://medium.com/geekculture/docker-build-with-mac-m1-d668c802ab96
   533  create-arm64-builder:
   534  	docker buildx use $(BUILDX_ARM64_BUILDER) || docker buildx create --name $(BUILDX_ARM64_BUILDER) --use
   535  
   536  # Build the image for the gameserver controller
   537  build-controller-image: build-controller-image-amd64
   538  ifeq ($(WITH_ARM64), 1)
   539  build-controller-image: build-controller-image-arm64
   540  endif
   541  
   542  build-controller-image-amd64: $(ensure-build-image) build-controller-binary build-licenses build-required-src-dist
   543  	docker build $(agones_path)/cmd/controller/ --tag=$(controller_amd64_tag) $(DOCKER_BUILD_ARGS)
   544  # creating docker builder and then using that builder to build controller image in buildx command
   545  build-controller-image-arm64: $(ensure-build-image) build-controller-binary create-arm64-builder
   546  	docker buildx build --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/controller/ --tag=$(controller_arm64_tag) $(DOCKER_BUILD_ARGS)
   547  
   548  # push the gameservers controller image
   549  push-controller-image: push-controller-image-amd64
   550  ifeq ($(WITH_ARM64), 1)
   551  push-controller-image: push-controller-image-arm64
   552  endif
   553  	# Docker >=24.0.6
   554  	docker buildx imagetools create --tag $(controller_tag) $(push_controller_manifest)
   555  
   556  push-controller-image-amd64: build-controller-image-amd64
   557  	docker push $(controller_amd64_tag)
   558  push-controller-image-arm64: build-controller-image-arm64
   559  	$(MAKE) DOCKER_BUILD_ARGS=--push build-controller-image-arm64
   560  
   561  # build the static binary for the gameserver sidecar
   562  build-agones-sdk-binary: $(ensure-build-image) build-agones-sdk-binary-linux-amd64 build-agones-sdk-binary-linux-arm64 build-agones-sdk-binary-windows build-agones-sdk-binary-darwin-amd64 build-agones-sdk-binary-darwin-arm64
   563  	$(ZIP_SDK) \
   564  		agonessdk-server-$(VERSION).zip sdk-server.darwin.amd64 sdk-server.darwin.arm64 sdk-server.linux.amd64 sdk-server.linux.arm64 sdk-server.windows.amd64.exe
   565  
   566  # build the static binary for the gameserver sidecar for Linux
   567  build-agones-sdk-binary-linux-amd64: $(ensure-build-image)
   568  	$(GO_BUILD_LINUX_AMD64) \
   569  		-o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.linux.amd64 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/sdk-server
   570  build-agones-sdk-binary-linux-arm64: $(ensure-build-image)
   571  	$(GO_BUILD_LINUX_ARM64) \
   572  		-o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.linux.arm64 $(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/sdk-server
   573  
   574  
   575  # build the static binary for the gameserver sidecar for Darwin (macOS)
   576  build-agones-sdk-binary-darwin-amd64: $(ensure-build-image)
   577  	$(GO_BUILD_DARWIN_AMD64) \
   578  		-o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.darwin.amd64 $(go_rebuild_flags) $(go_version_flags) $(agones_package)/cmd/sdk-server
   579  build-agones-sdk-binary-darwin-arm64: $(ensure-build-image)
   580  	$(GO_BUILD_DARWIN_ARM64) \
   581  		-o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.darwin.arm64 $(go_rebuild_flags) $(go_version_flags) $(agones_package)/cmd/sdk-server
   582  
   583  # build the windows binary for the gameserver sidecar for Windows
   584  build-agones-sdk-binary-windows: $(ensure-build-image)
   585  	$(GO_BUILD_WINDOWS_AMD64) \
   586  		-o $(go_build_base_path)/cmd/sdk-server/bin/sdk-server.windows.amd64.exe $(go_rebuild_flags) $(go_version_flags) $(agones_package)/cmd/sdk-server
   587  
   588  ensure-windows-buildx:
   589  	docker buildx use $(BUILDX_WINDOWS_BUILDER) || docker buildx create --platform windows/amd64 --name $(BUILDX_WINDOWS_BUILDER) --use
   590  
   591  # Build the image for the gameserver extensions
   592  build-extensions-image: build-extensions-image-amd64
   593  ifeq ($(WITH_ARM64), 1)
   594  build-extensions-image: build-extensions-image-arm64
   595  endif
   596  
   597  build-extensions-image-amd64: $(ensure-build-image) build-extensions-binary build-licenses build-required-src-dist
   598  	docker build $(agones_path)/cmd/extensions/ --tag=$(extensions_amd64_tag) $(DOCKER_BUILD_ARGS)
   599  # creating docker builder and then using that builder to build extensions image in buildx command
   600  build-extensions-image-arm64: $(ensure-build-image) build-extensions-binary create-arm64-builder
   601  	docker buildx build --provenance false --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/extensions/ --tag=$(extensions_arm64_tag) $(DOCKER_BUILD_ARGS)
   602  
   603  # push the gameservers extensions image
   604  push-extensions-image: push-extensions-image-amd64
   605  ifeq ($(WITH_ARM64), 1)
   606  push-extensions-image: push-extensions-image-arm64
   607  endif
   608  	# Docker >=24.0.6
   609  	docker buildx imagetools create --tag $(extensions_tag) $(push_extensions_manifest)
   610  
   611  # push extensions image
   612  push-extensions-image-amd64: build-extensions-image-amd64
   613  	docker push $(extensions_amd64_tag)
   614  push-extensions-image-arm64: build-extensions-image-arm64
   615  	$(MAKE) DOCKER_BUILD_ARGS=--push build-extensions-image-arm64
   616  
   617  # Build the image for the gameserver sidecar and SDK binaries
   618  build-agones-sdk-image: $(ensure-build-image) build-agones-sdk-binary build-licenses build-required-src-dist build-agones-sdk-image-amd64
   619  ifeq ($(WITH_ARM64), 1)
   620  build-agones-sdk-image: build-agones-sdk-image-arm64
   621  endif
   622  ifeq ($(WITH_WINDOWS), 1)
   623  build-agones-sdk-image: build-agones-sdk-image-windows
   624  endif
   625  
   626  build-agones-sdk-image-amd64: $(ensure-build-image) build-agones-sdk-binary-linux-amd64
   627  	docker build $(agones_path)/cmd/sdk-server/ --tag=$(sidecar_linux_amd64_tag) $(DOCKER_BUILD_ARGS)
   628  # creating docker builder and then using that builder to build sdk image in buildx command
   629  build-agones-sdk-image-arm64: $(ensure-build-image) build-agones-sdk-binary-linux-arm64 create-arm64-builder
   630  	docker buildx build --provenance false --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/sdk-server/ --tag=$(sidecar_linux_arm64_tag) $(DOCKER_BUILD_ARGS)
   631  
   632  build-agones-sdk-image-windows: build-agones-sdk-binary
   633  build-agones-sdk-image-windows: $(foreach winver, $(WINDOWS_VERSIONS), build-agones-sdk-image-windows-$(winver))
   634  
   635  # Build the image for the gameserver sidecar and SDK binaries
   636  build-agones-sdk-image-windows-%: $(ensure-build-image) build-agones-sdk-binary build-licenses build-required-src-dist ensure-windows-buildx
   637  	docker buildx build --provenance false --platform windows/amd64 --builder $(BUILDX_WINDOWS_BUILDER) -f $(agones_path)/cmd/sdk-server/Dockerfile.windows --tag=$(sidecar_tag)-windows_amd64-$* --build-arg WINDOWS_VERSION=$* --build-arg IMAGE_TAG=$(if $(filter ltsc2019,$*),$(LTSC2019_IMAGE_TAG)) $(DOCKER_BUILD_ARGS) $(agones_path)/cmd/sdk-server/ $(WINDOWS_DOCKER_PUSH_ARGS)
   638  
   639  # Build a static binary for the ping service
   640  build-ping-binary: build-ping-binary-amd64
   641  ifeq ($(WITH_ARM64), 1)
   642  build-ping-binary: build-ping-binary-arm64
   643  endif
   644  
   645  build-ping-binary-amd64: $(ensure-build-image)
   646  	$(GO_BUILD_LINUX_AMD64) \
   647  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/ping/bin/ping.linux.amd64 \
   648  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/ping
   649  build-ping-binary-arm64: $(ensure-build-image)
   650  	$(GO_BUILD_LINUX_ARM64) \
   651  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/ping/bin/ping.linux.arm64 \
   652  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/ping
   653  
   654  # Pushes up the ping image
   655  push-ping-image: push-ping-image-amd64
   656  ifeq ($(WITH_ARM64), 1)
   657  push-ping-image: push-ping-image-arm64
   658  endif
   659  	# Docker >=24.0.6
   660  	docker buildx imagetools create --tag $(ping_tag) $(push_ping_manifest)
   661  
   662  
   663  push-ping-image-amd64: $(ensure-build-image) build-ping-image-amd64
   664  	docker push $(ping_amd64_tag)
   665  push-ping-image-arm64:
   666  	$(MAKE) DOCKER_BUILD_ARGS=--push build-ping-image-arm64
   667  
   668  # Build the image for the ping service
   669  build-ping-image: build-ping-image-amd64
   670  ifeq ($(WITH_ARM64), 1)
   671  build-ping-image: build-ping-image-arm64
   672  endif
   673  
   674  build-ping-image-amd64: $(ensure-build-image) build-ping-binary build-licenses build-required-src-dist
   675  	docker build $(agones_path)/cmd/ping/ --tag=$(ping_amd64_tag) $(DOCKER_BUILD_ARGS)
   676  # creating docker builder and then using that builder to build ping image in buildx command
   677  build-ping-image-arm64: $(ensure-build-image) build-ping-binary create-arm64-builder
   678  	docker buildx build --provenance false --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/ping/ --tag=$(ping_arm64_tag) $(DOCKER_BUILD_ARGS)
   679  
   680  # Build a static binary for the allocator service
   681  build-allocator-binary: $(ensure-build-image) build-allocator-binary-linux-amd64
   682  ifeq ($(WITH_ARM64), 1)
   683  build-allocator-binary: build-allocator-binary-linux-arm64
   684  endif
   685  
   686  build-allocator-binary-linux-amd64: $(ensure-build-image)
   687  	$(GO_BUILD_LINUX_AMD64) \
   688  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/allocator/bin/allocator.linux.amd64 \
   689  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/allocator
   690  build-allocator-binary-linux-arm64:
   691  	$(GO_BUILD_LINUX_ARM64) \
   692  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/allocator/bin/allocator.linux.arm64 \
   693  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/allocator
   694  
   695  # Pushes up the allocator image
   696  push-allocator-image: push-allocator-image-amd64
   697  ifeq ($(WITH_ARM64), 1)
   698  push-allocator-image: push-allocator-image-arm64
   699  endif
   700  	# Docker >=24.0.6
   701  	docker buildx imagetools create --tag $(allocator_tag) $(push_allocator_manifest)
   702  
   703  push-allocator-image-amd64: build-allocator-image-amd64
   704  	docker push $(allocator_amd64_tag)
   705  push-allocator-image-arm64: build-allocator-image-arm64
   706  	$(MAKE) DOCKER_BUILD_ARGS=--push build-allocator-image-arm64
   707  
   708  # Build the image for the allocator service
   709  build-allocator-image: build-allocator-image-amd64
   710  ifeq ($(WITH_ARM64), 1)
   711  build-allocator-image: build-allocator-image-arm64
   712  endif
   713  
   714  build-allocator-image-amd64: $(ensure-build-image) build-allocator-binary build-licenses build-required-src-dist
   715  	docker build $(agones_path)/cmd/allocator/ --tag=$(allocator_amd64_tag) $(DOCKER_BUILD_ARGS)
   716  # creating docker builder and then using that builder to build allocator image in buildx command
   717  build-allocator-image-arm64: $(ensure-build-image) build-allocator-binary create-arm64-builder
   718  	docker buildx build --provenance false $(agones_path)/cmd/allocator/ --builder $(BUILDX_ARM64_BUILDER) --tag=$(allocator_arm64_tag) --build-arg ARCH=arm64 --platform linux/arm64 $(DOCKER_BUILD_ARGS)
   719  
   720  # push the processor image
   721  build-processor-binary: $(ensure-build-image) build-processor-binary-linux-amd64
   722  ifeq ($(WITH_ARM64), 1)
   723  build-processor-binary: build-processor-binary-linux-arm64
   724  endif
   725  
   726  build-processor-binary-linux-amd64: $(ensure-build-image)
   727  	$(GO_BUILD_LINUX_AMD64) \
   728  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/processor/bin/processor.linux.amd64 \
   729  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/processor
   730  build-processor-binary-linux-arm64: $(ensure-build-image)
   731  	$(GO_BUILD_LINUX_ARM64) \
   732  	-tags $(GO_BUILD_TAGS) -o $(go_build_base_path)/cmd/processor/bin/processor.linux.arm64 \
   733  	$(go_rebuild_flags) $(go_version_flags) -installsuffix cgo $(agones_package)/cmd/processor
   734  
   735  # Build the image for the processor service
   736  build-processor-image: build-processor-image-amd64
   737  ifeq ($(WITH_ARM64), 1)
   738  build-processor-image: build-processor-image-arm64
   739  endif
   740  
   741  build-processor-image-amd64: $(ensure-build-image) build-processor-binary build-licenses build-required-src-dist
   742  	docker build $(agones_path)/cmd/processor/ --tag=$(processor_amd64_tag) $(DOCKER_BUILD_ARGS)
   743  # creating docker builder and then using that builder to build processor image in buildx command
   744  build-processor-image-arm64: $(ensure-build-image) build-processor-binary create-arm64-builder
   745  	docker buildx build --provenance false --platform linux/arm64 --builder $(BUILDX_ARM64_BUILDER) --build-arg ARCH=arm64 $(agones_path)/cmd/processor/ --tag=$(processor_arm64_tag) $(DOCKER_BUILD_ARGS)
   746  
   747  # Pushes up the processor image
   748  push-processor-image: push-processor-image-amd64
   749  ifeq ($(WITH_ARM64), 1)
   750  push-processor-image: push-processor-image-arm64
   751  endif
   752  	# Docker >=24.0.6
   753  	docker buildx imagetools create --tag $(processor_tag) $(push_processor_manifest)
   754  
   755  push-processor-image-amd64: build-processor-image-amd64
   756  	docker push $(processor_amd64_tag)
   757  push-processor-image-arm64: build-processor-image-arm64
   758  	$(MAKE) DOCKER_BUILD_ARGS=--push build-processor-image-arm64
   759  
   760  # push the gameservers sidecar image
   761  push-agones-sdk-image: push-agones-sdk-linux-image-amd64
   762  ifeq ($(WITH_WINDOWS), 1)
   763  push-agones-sdk-image: push-agones-sdk-windows
   764  endif
   765  ifeq ($(WITH_ARM64), 1)
   766  push-agones-sdk-image: push-agones-sdk-linux-image-arm64
   767  endif
   768  	$(MAKE) push-agones-sdk-manifest
   769  
   770  push-agones-sdk-manifest:
   771  	docker manifest create --amend $(sidecar_tag) $(push_sidecar_manifest)
   772  	$(MAKE) push_windows_manifest
   773  	docker manifest push --purge $(sidecar_tag)
   774  
   775  push_windows_manifest:
   776  ifeq ($(WITH_WINDOWS), 1)
   777  	for osversion in $(WINDOWS_VERSIONS); do \
   778  		full_version=`docker manifest inspect ${BASE.windows}:$$osversion | grep "os.version" | head -n 1 | awk -F\" '{print $$4}'` || true; \
   779  		docker manifest annotate --os windows --arch amd64 --os-version $$full_version \
   780  		$(sidecar_tag) $(sidecar_tag)-windows_amd64-$$osversion; \
   781  	done
   782  endif
   783  
   784  push-agones-sdk-windows: WINDOWS_DOCKER_PUSH_ARGS=--push
   785  push-agones-sdk-windows: build-agones-sdk-image-windows
   786  
   787  push-agones-sdk-linux-image-arm64: $(ensure-build-image)
   788  	$(MAKE) DOCKER_BUILD_ARGS=--push build-agones-sdk-image-arm64
   789  
   790  push-agones-sdk-linux-image-amd64: build-agones-sdk-image-amd64
   791  	docker push $(sidecar_linux_amd64_tag)
   792  
   793  # Generate the Embedded CRD openapi
   794  gen-embedded-openapi: $(ensure-build-image)
   795  	docker run --rm $(common_mounts) --workdir=$(mount_path)/build/scripts/k8s-export-openapi $(DOCKER_RUN_ARGS) $(build_tag) \
   796  		go run -mod=mod ./main.go
   797  
   798  # Generate the static install script
   799  gen-install: $(ensure-build-image)
   800  	docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \
   801  		'helm template agones-manual --namespace agones-system $(mount_path)/install/helm/agones \
   802  		--set agones.controller.generateTLS=false \
   803  		--set agones.allocator.generateTLS=false \
   804  		--set agones.allocator.generateClientTLS=false \
   805  		--set agones.crds.cleanupOnDelete=false \
   806  		> $(mount_path)/install/yaml/install.yaml'
   807  
   808  # Generate the client, conversions, deepcopy, and defaults code for our CustomResourceDefinition
   809  gen-crd-code: $(ensure-build-image)
   810  	docker run --rm \
   811  		$(common_mounts) -w $(workdir_path) $(build_tag) bash -c "\
   812  		$(git_safe) && \
   813  		/root/gen-crd-code.sh && \
   814  		cd $(workdir_path)/pkg && goimports -w ."
   815  
   816  # Run a bash shell with the developer tools in it. (Creates the image if it doesn't exist)
   817  # Can use DOCKER_RUN_ARGS for extra arguments.
   818  shell: $(ensure-build-image)
   819  	docker run -it --rm \
   820  		$(common_mounts) \
   821  		-w $(workdir_path) \
   822  		-e "KUBECONFIG=/root/.kube/$(kubeconfig_file)" \
   823  		$(DOCKER_RUN_ARGS) \
   824  		$(build_tag) bash -l
   825  
   826  # run a container with pkgsite
   827  pkgsite:
   828  	docker run -p 8888:8888 --rm $(common_mounts) -w $(workdir_path) \
   829  		$(build_tag) pkgsite -http=":8888" .
   830  
   831  # start cpu profiling pprof with a web ui
   832  pprof-cpu-web:
   833  	docker run --rm -it --network=host $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) \
   834  		go tool pprof -http :6061 http://localhost:6060
   835  
   836  # start heap profiling
   837  pprof-heap-web:
   838  	docker run --rm -it --network=host $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) \
   839  		go tool pprof -http :6062 http://localhost:6060/debug/pprof/heap
   840  
   841  # setup prometheus in the current cluster by default Persistent Volume Claims are requested.
   842  setup-prometheus: PVC ?= true
   843  setup-prometheus: PV_SIZE ?= 64Gi
   844  setup-prometheus: SCRAPE_INTERVAL=30s
   845  setup-prometheus:
   846  	$(DOCKER_RUN) helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
   847  	$(DOCKER_RUN) helm repo update
   848  	$(DOCKER_RUN) helm upgrade prom prometheus-community/prometheus --install --wait \
   849   		--namespace metrics --create-namespace \
   850  		--set server.global.scrape_interval=$(SCRAPE_INTERVAL),server.persistentVolume.enabled=$(PVC),server.persistentVolume.size=$(PV_SIZE) \
   851  		$(HELM_ARGS) -f $(mount_path)/build/prometheus.yaml
   852  
   853  uninstall-prometheus: $(ensure-build-image)
   854  	$(DOCKER_RUN) \
   855  		helm uninstall prom --namespace=metrics
   856  
   857  # setup grafana in the current cluster with datasource and dashboards ready for use with agones
   858  # by default Persistent Volume Claims are requested.
   859  setup-grafana: PVC ?= true
   860  setup-grafana: PV_SIZE ?= 64Gi
   861  setup-grafana: PASSWORD ?= admin
   862  setup-grafana:
   863  	$(DOCKER_RUN) helm repo add grafana https://grafana.github.io/helm-charts
   864  	$(DOCKER_RUN) helm repo update
   865  	$(DOCKER_RUN) kubectl apply -f $(mount_path)/build/grafana/
   866  	$(DOCKER_RUN) helm upgrade grafana grafana/grafana --install --wait \
   867  		--namespace metrics --create-namespace \
   868  		--set persistence.enabled=$(PVC),server.persistentVolume.size=$(PV_SIZE) \
   869  		--set adminPassword=$(PASSWORD) $(HELM_ARGS) -f $(mount_path)/build/grafana.yaml
   870  
   871  uninstall-grafana: $(ensure-build-image)
   872  	$(DOCKER_RUN) helm uninstall grafana --namespace=metrics
   873  	$(DOCKER_RUN) kubectl delete -f $(mount_path)/build/grafana/
   874  
   875  # setup prometheus-stack in the current cluster by default Persistent Volume Claims are requested.
   876  setup-prometheus-stack: PVC ?= true
   877  setup-prometheus-stack: PV_SIZE ?= 64Gi
   878  setup-prometheus-stack: SCRAPE_INTERVAL=30s
   879  setup-prometheus-stack: PASSWORD ?= admin
   880  setup-prometheus-stack:
   881  	$(DOCKER_RUN) helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
   882  	$(DOCKER_RUN) helm repo update
   883  	$(DOCKER_RUN) helm upgrade prometheus-stack prometheus-community/kube-prometheus-stack --install --wait --version 19.0.2 \
   884   		--namespace monitoring --create-namespace \
   885  		--set prometheus.server.global.scrape_interval=$(SCRAPE_INTERVAL) \
   886  		--set prometheus.server.persistentVolume.enabled=$(PVC) \
   887  		--set prometheus.server.persistentVolume.size=$(PV_SIZE) \
   888  		--set grafana.adminPassword=$(PASSWORD) \
   889  		$(HELM_ARGS) -f $(mount_path)/build/prometheus-stack.yaml
   890  
   891  uninstall-prometheus-stack: $(ensure-build-image)
   892  	$(DOCKER_RUN) \
   893  		helm uninstall prometheus-stack --namespace=monitoring
   894  
   895  helm-repo-update:
   896  	$(DOCKER_RUN) helm repo update
   897  
   898  clean-test-cluster: $(ensure-build-image) $(uninstall)
   899  
   900  install-custom-pull-secret:
   901  	# if IMAGE_PULL_SECRET_FILE is specified, create the agones-system namespace and install the secret
   902  	@if [ "$(IMAGE_PULL_SECRET_FILE)" != "" ]; then \
   903  		echo "Creating agones-system namespace..." ;\
   904  		$(DOCKER_RUN) kubectl create namespace agones-system; \
   905  		echo "Installing secret $(IMAGE_PULL_SECRET_FILE) in agones-system namespace..."; \
   906  		docker run --rm $(common_mounts) -e "KUBECONFIG=/root/.kube/$(kubeconfig_file)" -v $(dir $(IMAGE_PULL_SECRET_FILE)):/root/secret $(DOCKER_RUN_ARGS) $(build_tag) \
   907  			kubectl apply --namespace agones-system -f /root/secret/$(notdir $(IMAGE_PULL_SECRET_FILE)); \
   908  		echo "Installing secret $(IMAGE_PULL_SECRET_FILE) in default namespace..."; \
   909  		docker run --rm $(common_mounts) -e "KUBECONFIG=/root/.kube/$(kubeconfig_file)" -v $(dir $(IMAGE_PULL_SECRET_FILE)):/root/secret $(DOCKER_RUN_ARGS) $(build_tag) \
   910  			kubectl apply --namespace default -f /root/secret/$(notdir $(IMAGE_PULL_SECRET_FILE)); \
   911  	fi
   912  
   913  update-go-deps:
   914  	$(DOCKER_RUN) go get -u agones.dev/agones
   915  	$(DOCKER_RUN) go mod tidy
   916  	$(DOCKER_RUN) go mod vendor
   917  
   918  test-gen-crd-code:
   919  	mkdir -p build/tmp/apis | mkdir -p build/tmp/client; \
   920  	cp -r ../pkg/apis/* build/tmp/apis | cp -r ../pkg/client/* build/tmp/client; \
   921  	make gen-crd-code; \
   922  	$(MAKE) diff-directory DIRECTORY=apis
   923  	$(MAKE) diff-directory DIRECTORY=client
   924  	# Delete build/tmp if the directory is empty
   925  	if [ ! "$(ls -A build/tmp)" ]; then \
   926  		echo "No differences found. Deleting empty directory build/tmp."; \
   927  		rm -r build/tmp; \
   928  	fi
   929  
   930  diff-directory:
   931  	diff_output=$$(diff -bBr build/tmp/$(DIRECTORY) ../pkg/$(DIRECTORY)); \
   932  	if [ -z "$$diff_output" ]; then \
   933  		echo "No differences found. Deleting build/tmp/$(DIRECTORY)"; \
   934  		rm -r build/tmp/$(DIRECTORY); \
   935  	else \
   936  		echo "Differences found."; \
   937  		echo "$$diff_output"; \
   938  	fi
   939  
   940  install-release: $(ensure-build-image)
   941  	docker run -it --rm \
   942  		$(common_mounts) \
   943  		$(DOCKER_RUN_ARGS) \
   944  		$(build_tag) /go/src/agones.dev/agones/build/install-release.sh
   945  
   946  # Validates the Helm values.yaml file against the values.schema.json file.
   947  helm-lint:
   948  	$(DOCKER_RUN) bash -c 'cd $(mount_path)/install/helm/agones && helm lint .'