@@ -32,15 +32,22 @@ WINDOWS_VERSIONS = ltsc2019
3232WINDOWS_DOCKER_PUSH_ARGS = # When pushing set to --push.
3333# Build with Windows support
3434WITH_WINDOWS=1
35+ # Build with ARM64 support
36+ WITH_ARM64 =1
3537
3638mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST ) ) )
3739project_path := $(dir $(mkfile_path ) )
38- server_tag = $(REGISTRY ) /simple-game-server:0.12
40+ server_tag = $(REGISTRY ) /simple-game-server:0.13
41+
3942ifeq ($(WITH_WINDOWS ) , 1)
40- server_tag_linux_amd64 = $(server_tag ) -linux_amd64
43+ server_tag_linux_amd64 = $(server_tag ) -linux-amd64
44+ server_tag_linux_arm64 = $(server_tag ) -linux-arm64
4145else
42- server_tag_linux_amd64 = $(server_tag )
46+ server_tag_linux_amd64 = $(server_tag ) -amd64
47+ server_tag_linux_arm64 = $(server_tag ) -arm64
4348endif
49+
50+ push_server_manifest = $(server_tag_linux_amd64 )
4451root_path = $(realpath $(project_path ) /../..)
4552
4653# _____ _
@@ -51,26 +58,40 @@ root_path = $(realpath $(project_path)/../..)
5158# |___/
5259
5360ifeq ($(WITH_WINDOWS ) , 1)
54- push : push-multi-arch-image
55- build : build-linux-image $(foreach winver, $(WINDOWS_VERSIONS ) , build-windows-image-$(winver ) )
56- else
57- push : push-linux-image
58- build : build-linux-image
61+ push_server_manifest += $(foreach windows_version, $(WINDOWS_VERSIONS ) , $(server_tag ) -windows_amd64-$(windows_version ) )
62+ endif
63+ ifeq ($(WITH_ARM64 ) , 1)
64+ push_server_manifest += $(server_tag_linux_arm64 )
65+ endif
66+
67+ build : build-linux-image-amd64
68+
69+ ifeq ($(WITH_WINDOWS ) , 1)
70+ build : $(foreach winver, $(WINDOWS_VERSIONS ) , build-windows-image-$(winver ) )
71+ endif
72+ ifeq ($(WITH_ARM64 ) , 1)
73+ build : build-linux-image-arm64
5974endif
6075
6176# Builds all image artifacts and create a docker manifest that is used to inform the CRI (Docker or containerd usually)
6277# which image is the best fit for the host. See https://www.docker.com/blog/multi-arch-images/ for details.
63- push-multi-arch-image : push-linux-image push-windows-images
64- # TODO: `docker manifest` does not yet stamp the `os.version` for Windows manifest entry.
65- # This means only 1 Windows version can be supported in a multi-platform build.
66- # Either adopt, https://github.com/kubernetes-sigs/azuredisk-csi-driver/pull/585/files or
67- # wait for https://github.com/docker/cli/pull/2578 to be available in Docker 20.10.
68- DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(server_tag ) $(server_tag_linux_amd64 ) $(foreach windows_version, $(WINDOWS_VERSIONS ) , $(server_tag ) -windows_amd64-$(windows_version ) )
78+ push : push-linux-image-amd64
79+ -DOCKER_CLI_EXPERIMENTAL=enabled docker manifest rm $(server_tag )
80+ DOCKER_CLI_EXPERIMENTAL=enabled docker manifest create $(server_tag ) $(push_server_manifest )
81+ ifeq ($(WITH_WINDOWS ) , 1)
82+ push : push-windows-images
83+ DOCKER_CLI_EXPERIMENTAL=enabled docker manifest annotate --os.version $(WINDOWS_VERSIONS )
84+ endif
85+ ifeq ($(WITH_ARM64 ) , 1)
86+ push : push-linux-image-arm64
87+ endif
6988 DOCKER_CLI_EXPERIMENTAL=enabled docker manifest push $(server_tag) --purge
7089
7190# Pushes all variants of the Windows images to the container image registry.
72- push-linux-image : build
91+ push-linux-image-amd64 : build
7392 docker push $(server_tag_linux_amd64 )
93+ push-linux-image-arm64 : build
94+ $(MAKE ) DOCKER_BUILD_ARGS=--push build-linux-image-arm64
7495
7596# Pushes all variants of the Windows images to the container image registry.
7697push-windows-images : $(foreach winver, $(WINDOWS_VERSIONS ) , push-windows-image-$(winver ) )
@@ -80,9 +101,8 @@ push-windows-image-%:
80101 $(MAKE ) WINDOWS_DOCKER_PUSH_ARGS=--push build-windows-image-$*
81102
82103build-windows-image-% : build-windows-binary ensure-windows-buildx
83- # TODO: Use `--builder $(BUILDX_WINDOWS_BUILDER)` later once Docker 19.03.13 is the build target. Cloud Build has 19.03.08 https://cloud.google.com/cloud-build/release-notes
84104 cd $(root_path ) && DOCKER_CLI_EXPERIMENTAL=enabled \
85- docker buildx build --platform windows/amd64 -f $(project_path ) Dockerfile.windows \
105+ docker buildx build --platform windows/amd64 --builder $( BUILDX_WINDOWS_BUILDER ) - f $(project_path ) Dockerfile.windows \
86106 --tag=$(server_tag ) -windows_amd64-$* --build-arg WINDOWS_VERSION=$* examples/simple-game-server/ $(WINDOWS_DOCKER_PUSH_ARGS )
87107
88108# Builds the server binary for Windows (amd64).
@@ -98,8 +118,10 @@ ensure-windows-buildx:
98118 -DOCKER_CLI_EXPERIMENTAL=enabled docker buildx create --name=$(BUILDX_WINDOWS_BUILDER ) --use
99119
100120# Build a docker image for the server, and tag it
101- build-linux-image :
121+ build-linux-image-amd64 :
102122 cd $(root_path ) && docker build -f $(project_path ) Dockerfile --tag=$(server_tag_linux_amd64 ) .
123+ build-linux-image-arm64 :
124+ cd $(root_path ) && docker build -f $(project_path ) Dockerfile --platform linux/arm64 --tag=$(server_tag_linux_arm64 ) .
103125
104126# check if hosted on Google Cloud Registry
105127gcr-check :
0 commit comments