agones.dev/agones@v1.53.0/examples/rust-simple/Makefile (about)

     1  # Copyright 2018 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 the world's simplest Rust game server
    17  #
    18  
    19  #  __     __         _       _     _
    20  #  \ \   / /_ _ _ __(_) __ _| |__ | | ___ ___
    21  #   \ \ / / _` | '__| |/ _` | '_ \| |/ _ \ __|
    22  #    \ V / (_| | |  | | (_| | |_) | |  __\__ \
    23  #     \_/ \__,_|_|  |_|\__,_|_.__/|_|\___|___/
    24  #
    25  
    26  REPOSITORY ?=
    27  PROD_REPO ?= us-docker.pkg.dev/agones-images/examples
    28  
    29  mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
    30  project_path := $(dir $(mkfile_path))
    31  root_path := $(realpath $(project_path)/../..)
    32  version := 0.13
    33  ifeq ($(REPOSITORY),)
    34  	server_tag := rust-simple-server:$(version)
    35  else
    36  	server_tag := $(REPOSITORY)/rust-simple-server:$(version)
    37  endif
    38  
    39  #   _____                    _
    40  #  |_   _|_ _ _ __ __ _  ___| |_ ___
    41  #    | |/ _` | '__/ _` |/ _ \ __/ __|
    42  #    | | (_| | | | (_| |  __/ |_\__ \
    43  #    |_|\__,_|_|  \__, |\___|\__|___/
    44  #                 |___/
    45  
    46  # Build the example Gameserver
    47  # alias for 'build-image'
    48  build: build-image
    49  
    50  # Build the server binary
    51  build-server:
    52  	cargo build --release
    53  
    54  # Build a docker image for the server, and tag it
    55  build-image:
    56  	# Docker does not allow to copy outside files
    57  	mkdir -p $(project_path)sdk
    58  	cp -rf $(project_path)../../sdks/rust/* $(project_path)sdk
    59  	docker build $(project_path) --tag=$(server_tag)
    60  
    61  # Run Rust Gameserver binary
    62  # Could be tested with:
    63  # cd ../../build; make run-sdk-conformance-local TIMEOUT=120 TESTS=ready,watch,health,gameserver,shutdown
    64  run:
    65  	./target/release/rust-simple
    66  
    67  # Run docker image
    68  # Could be tested with:
    69  # cd ../../build; make run-sdk-conformance-local TIMEOUT=120 TESTS=ready,watch,health,gameserver,shutdown
    70  run-image:
    71  	docker run --network=host $(PROD_REPO)/$(server_tag)
    72  
    73  # When you used 'build' or 'build-server' locally without docker
    74  clean:
    75  	cargo clean
    76  	rm -rf $(project_path)sdk
    77  
    78  # If you are building with docker clean files in /sdk directory,
    79  # clean leftover files after building an image with Docker
    80  clean-docker:
    81  	rm -rf $(project_path)sdk
    82  
    83  # check if hosted on Google Artifact Registry
    84  gar-check:
    85  	gcloud container images describe $(PROD_REPO)/$(server_tag)
    86  
    87  #output the tag for this image
    88  echo-image-tag:
    89  	@echo $(PROD_REPO)/$(server_tag)
    90  
    91  # Push the docker image
    92  push: build
    93  	docker push $(server_tag)
    94  
    95  # build and push the rust-simple image with specified tag
    96  cloud-build:
    97  	cd $(root_path) && gcloud builds submit --config=./examples/rust-simple/cloudbuild.yaml