2323# \_/ \__,_|_| |_|\__,_|_.__/|_|\___|___/
2424#
2525
26- VERSION ?= 0.1
26+ # base version target. This is usually the next release.
27+ base_version = 0.1
28+
29+ #
30+ # All of the following can be overwritten with environemt 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 ) -$(shell git rev-parse --short HEAD)
36+ # The registry that is being used to store docker images
2737REGISTRY ?= gcr.io/agon-images
28- CLUSTER_NAME ?= test-cluster
38+ # Where the kubectl configuration files are being stored
2939KUBECONFIG ?= $(build_path ) /.kube
40+ # The (gcloud) test cluster that is being worked against
41+ CLUSTER_NAME ?= test-cluster
3042
3143# Directory that this Makefile is in.
3244mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST ) ) )
@@ -46,6 +58,8 @@ build_tag = agon-build:$(build_version)
4658controller_tag = $(REGISTRY ) /gameservers-controller:$(VERSION )
4759sidecar_tag = $(REGISTRY ) /gameservers-sidecar:$(VERSION )
4860
61+ go_version_flags = -ldflags "-X github.com/agonio/agon/pkg.Version=$(VERSION ) "
62+
4963# _____ _
5064# |_ _|_ _ _ __ __ _ ___| |_ ___
5165# | |/ _` | '__/ _` |/ _ \ __/ __|
@@ -63,10 +77,16 @@ test: ensure-image
6377# Push all the images up to $(REGISTRY)
6478push : push-gameservers-controller-image push-gameservers-sidecar-image
6579
80+ # install the development version of Agon
81+ install :
82+ cp $(build_path ) /install.yaml $(build_path ) /.install.yaml
83+ sed -i -e ' s!$${REGISTRY}!$(REGISTRY)!g' -e ' s!$${VERSION}!$(VERSION)!g' $(build_path ) /.install.yaml
84+ docker run --rm $(common_mounts ) --entrypoint=kubectl $(build_tag ) apply -f $(mount_path ) /build/.install.yaml
85+
6686# Build a static binary for the gameserver controller
6787build-gameservers-controller-binary : ensure-image
6888 docker run --rm -e " CGO_ENABLED=0" $(common_mounts ) --entrypoint=go $(build_tag ) build \
69- -o $(mount_path ) /gameservers/controller/bin/controller -a -installsuffix cgo $(agon_package ) /gameservers/controller
89+ -o $(mount_path ) /gameservers/controller/bin/controller -a $( go_version_flags ) -installsuffix cgo $(agon_package ) /gameservers/controller
7090
7191# Build the image for the gameserver controller
7292build-gameservers-controller-image : ensure-image build-gameservers-controller-binary
@@ -79,7 +99,7 @@ push-gameservers-controller-image: ensure-image
7999# build the static binary for the gamesever sidecar
80100build-gameservers-sidecar-binary : ensure-image
81101 docker run --rm -e " CGO_ENABLED=0" $(common_mounts ) --entrypoint=go $(build_tag ) build \
82- -o $(mount_path ) /gameservers/sidecar/bin/sidecar -a -installsuffix cgo $(agon_package ) /gameservers/sidecar
102+ -o $(mount_path ) /gameservers/sidecar/bin/sidecar -a $( go_version_flags ) -installsuffix cgo $(agon_package ) /gameservers/sidecar
83103
84104# Build the image for the gameserver sidecar
85105build-gameservers-sidecar-image : ensure-image build-gameservers-sidecar-binary
0 commit comments