Skip to content

Commit

Permalink
Support builds on macOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
enocom committed Feb 12, 2018
1 parent b4c064c commit 489e61b
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ common_mounts = -v $(build_path)/.config/gcloud:/root/.config/gcloud \

# Use a hash of the Dockerfile for the tag, so when the Dockerfile changes,
# it automatically rebuilds
build_version := $(shell sha256sum $(build_path)/build-image/Dockerfile | head -c 10)
build_version := $(shell \
if hash sha256sum 2>/dev/null; then \
sha256sum $(build_path)/build-image/Dockerfile | head -c 10; \
else \
shasum -a 256 $(build_path)/build-image/Dockerfile | head -c 10; \
fi \
)
build_tag = agones-build:$(build_version)
build_remote_tag = $(REGISTRY)/$(build_tag)
controller_tag = $(REGISTRY)/agones-controller:$(VERSION)
Expand Down Expand Up @@ -109,9 +115,10 @@ install: ALWAYS_PULL_SIDECAR := true
install: IMAGE_PULL_POLICY := "Always"
install: ensure-build-image
cp $(build_path)/install.yaml $(build_path)/.install.yaml
sed -i -e 's!$${REGISTRY}!$(REGISTRY)!g' -e 's!$${VERSION}!$(VERSION)!g' \
-e 's!$${IMAGE_PULL_POLICY}!$(IMAGE_PULL_POLICY)!g' -e 's!$${ALWAYS_PULL_SIDECAR}!$(ALWAYS_PULL_SIDECAR)!g' \
$(build_path)/.install.yaml
sed -i -e 's!$${REGISTRY}!$(REGISTRY)!g' $(build_path)/.install.yaml
sed -i -e 's!$${VERSION}!$(VERSION)!g' $(build_path)/.install.yaml
sed -i -e 's!$${IMAGE_PULL_POLICY}!$(IMAGE_PULL_POLICY)!g' $(build_path)/.install.yaml
sed -i -e 's!$${ALWAYS_PULL_SIDECAR}!$(ALWAYS_PULL_SIDECAR)!g' $(build_path)/.install.yaml
docker run --rm $(common_mounts) $(ARGS) $(build_tag) kubectl apply -f $(mount_path)/build/.install.yaml

# Build a static binary for the gameserver controller
Expand Down Expand Up @@ -287,4 +294,4 @@ minikube-install: minikube-agones-profile
# Convenience target for transferring images into minikube.
# Use TAG to specify the image to transfer into minikube
minikube-transfer-image:
docker save $(TAG) | ($(MINIKUBE_DOCKER_ENV) && docker load)
docker save $(TAG) | ($(MINIKUBE_DOCKER_ENV) && docker load)

0 comments on commit 489e61b

Please sign in to comment.