Skip to content

Commit d62fba6

Browse files
committed
Support builds on macOS
The BSD version of sed does not support multiple `-e` flags and `sha256sum` is not installed by default. This commit makes minor changes to ensure a macOS user may build agones without any additional effort.
1 parent ced8bad commit d62fba6

5 files changed

Lines changed: 24 additions & 16 deletions

File tree

build/Makefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ common_mounts = -v $(build_path)/.config/gcloud:/root/.config/gcloud \
5353
-v $(KUBEPATH):/root/.kube \
5454
-v $(agones_path):$(mount_path)
5555

56-
# Use a hash of the Dockerfile for the tag, so when the Dockerfile changes,
57-
# it automatically rebuilds
58-
build_version := $(shell sha256sum $(build_path)/build-image/Dockerfile | head -c 10)
5956
build_tag = agones-build:$(build_version)
6057
build_remote_tag = $(REGISTRY)/$(build_tag)
6158
controller_tag = $(REGISTRY)/agones-controller:$(VERSION)
@@ -76,7 +73,7 @@ ifneq ($(findstring Microsoft,$(shell uname -r)),)
7673
else ifeq ($(uname),Linux)
7774
osinclude := linux.mk
7875
else ifeq ($(uname),Darwin)
79-
osinclude := osx.mk
76+
osinclude := macos.mk
8077
endif
8178

8279
include ./includes/$(osinclude)
@@ -112,9 +109,10 @@ install: ALWAYS_PULL_SIDECAR := true
112109
install: IMAGE_PULL_POLICY := "Always"
113110
install: ensure-build-image
114111
cp $(build_path)/install.yaml $(build_path)/.install.yaml
115-
sed -i -e 's!$${REGISTRY}!$(REGISTRY)!g' -e 's!$${VERSION}!$(VERSION)!g' \
116-
-e 's!$${IMAGE_PULL_POLICY}!$(IMAGE_PULL_POLICY)!g' -e 's!$${ALWAYS_PULL_SIDECAR}!$(ALWAYS_PULL_SIDECAR)!g' \
117-
$(build_path)/.install.yaml
112+
sed -i -e 's!$${REGISTRY}!$(REGISTRY)!g' $(build_path)/.install.yaml
113+
sed -i -e 's!$${VERSION}!$(VERSION)!g' $(build_path)/.install.yaml
114+
sed -i -e 's!$${IMAGE_PULL_POLICY}!$(IMAGE_PULL_POLICY)!g' $(build_path)/.install.yaml
115+
sed -i -e 's!$${ALWAYS_PULL_SIDECAR}!$(ALWAYS_PULL_SIDECAR)!g' $(build_path)/.install.yaml
118116
docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) kubectl apply -f $(mount_path)/build/.install.yaml
119117

120118
# Build a static binary for the gameserver controller
@@ -258,8 +256,8 @@ clean-gcloud-config:
258256
# Switches to an "agones" profile, and starts a kubernetes cluster
259257
# of the right version.
260258
#
261-
# Use MINIKUBE_DRIVER variable to change the VM driver
262-
# (defaults virtualbox for Linux and OSX, hyperv for windows) if you so desire.
259+
# Use MINIKUBE_DRIVER variable to change the VM driver
260+
# (defaults virtualbox for Linux and macOS, hyperv for windows) if you so desire.
263261
minikube-test-cluster: minikube-agones-profile
264262
$(MINIKUBE) start --kubernetes-version v1.8.0 --vm-driver $(MINIKUBE_DRIVER)
265263
$(MAKE) minikube-post-start

build/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tasks you may wish to accomplish.
1414
1. [Building on Different Platforms](#building-on-different-platforms)
1515
1. [Linux](#linux)
1616
1. [Windows](#windows)
17-
1. [OSX](#osx)
17+
1. [macOS](#macOS)
1818
1. [GOPATH](#gopath)
1919
1. [Testing and Building](#testing-and-building)
2020
1. [Running a Test Google Kubernetes Engine Cluster](#running-a-test-google-kubernetes-engine-cluster)
@@ -60,7 +60,7 @@ as this makes it easy to create a (relatively) cross platform development and bu
6060
driver - the same virtualisation platform as the Docker installation.
6161
- **Note**: If you want to dev and test with Minikube, you **must** run WSL as Administrator, otherwise Minikube can't control HyperV.
6262

63-
### OSX
63+
### macOS
6464

6565
- Install Make, `brew install make`, if it's not installed already
6666
- Install [Docker for Mac](https://docs.docker.com/docker-for-mac/install/)
@@ -71,9 +71,7 @@ This has currently yet to be tested, but should have few issues around testing,
7171

7272
Issues with building and developing on Minikube are currently expected, due to lack of testing, but Agones will run on Minikube.
7373

74-
Testing on OSX and reporting bugs are appreciated.
75-
76-
You can see progress on this on the [Build Agones on OSX](https://github.com/googleprivate/agones/issues/46) ticket.
74+
Testing on macOS and reporting bugs are appreciated.
7775

7876
## GOPATH
7977

@@ -326,8 +324,8 @@ Since Minikube runs locally, there are some targets that need to be used instead
326324
Switches to an "agones" profile, and starts a kubernetes cluster
327325
of the right version.
328326

329-
Use MINIKUBE_DRIVER variable to change the VM driver
330-
(defaults virtualbox for Linux and OSX, hyperv for windows) if you so desire.
327+
Use MINIKUBE_DRIVER variable to change the VM driver
328+
(defaults virtualbox for Linux and macOS, hyperv for windows) if you so desire.
331329

332330
#### `minikube-push`
333331
Push the local Agones Docker images that have already been built

build/includes/linux.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# \_/ \__,_|_| |_|\__,_|_.__/|_|\___|___/
2424
#
2525

26+
# Use a hash of the Dockerfile for the tag, so when the Dockerfile changes,
27+
# it automatically rebuilds
28+
build_version := $(shell sha256sum $(build_path)/build-image/Dockerfile | head -c 10)
29+
2630
# Minikube executable
2731
MINIKUBE ?= minikube
2832
# Default minikube driver
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# \_/ \__,_|_| |_|\__,_|_.__/|_|\___|___/
2424
#
2525

26+
# Use a hash of the Dockerfile for the tag, so when the Dockerfile changes,
27+
# it automatically rebuilds
28+
build_version := $(shell shasum -a 256 $(build_path)/build-image/Dockerfile | head -c 10)
29+
2630
# Minikube executable
2731
MINIKUBE ?= minikube
2832
# Default minikube driver

build/includes/windows.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
# \_/ \__,_|_| |_|\__,_|_.__/|_|\___|___/
2424
#
2525

26+
# Use a hash of the Dockerfile for the tag, so when the Dockerfile changes,
27+
# it automatically rebuilds
28+
build_version := $(shell sha256sum $(build_path)/build-image/Dockerfile | head -c 10)
29+
2630
# Minikube executable
2731
MINIKUBE ?= minikube.exe
2832
# Default minikube driver

0 commit comments

Comments
 (0)