Skip to content

Commit 8871bb0

Browse files
committed
Windows and OSX builds of the sidecar
This now means local development on Windows and OSX is possible. Also added documentation on how to run this process when developing locally with Agon. Closes agones-dev#8
1 parent 5f8a46a commit 8871bb0

4 files changed

Lines changed: 54 additions & 11 deletions

File tree

build/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ push-gameservers-controller-image: ensure-image
104104

105105
# build the static binary for the gamesever sidecar
106106
build-gameservers-sidecar-binary: ensure-image
107-
docker run --rm -e "CGO_ENABLED=0" $(common_mounts) --entrypoint=go $(build_tag) build \
108-
-o $(mount_path)/gameservers/sidecar/bin/sidecar -a $(go_version_flags) -installsuffix cgo $(agon_package)/gameservers/sidecar
107+
docker run --rm -e "CGO_ENABLED=0" $(common_mounts) $(build_tag) go build \
108+
-o $(mount_path)/gameservers/sidecar/bin/sidecar.linux.amd64 -a $(go_version_flags) -installsuffix cgo $(agon_package)/gameservers/sidecar
109+
docker run --rm -e "GOOS=darwin" -e "GOARCH=amd64" $(common_mounts) $(build_tag) go build \
110+
-o $(mount_path)/gameservers/sidecar/bin/sidecar.darwin.amd64 $(go_version_flags) $(agon_package)/gameservers/sidecar
111+
docker run --rm -e "GOOS=windows" -e "GOARCH=amd64" $(common_mounts) $(build_tag) go build \
112+
-o $(mount_path)/gameservers/sidecar/bin/sidecar.windows.amd64.exe $(go_version_flags) $(agon_package)/gameservers/sidecar
109113

110114
# Build the image for the gameserver sidecar
111115
build-gameservers-sidecar-image: ensure-image build-gameservers-sidecar-binary

build/README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,29 @@ Make sure you are in the `build` directory to start.
3838

3939
First, let's test all the code. To do this, run `make test`, which will execute all the unit tests for the codebase.
4040

41-
If you haven't run any of the `build` make targets before then this will also create the build image, and then run the tests.
42-
Building the `build-image` may take a few minutes to download all the dependencies, so feel
41+
If you haven't run any of the `build` make targets before then this will also create the Docker based build image,
42+
and then run the tests.
43+
44+
Building the build image may take a few minutes to download all the dependencies, so feel
4345
free to make cup of tea or coffee at this point. ☕️
4446

4547
The build image is only created the first time one of the make targets is executed, and will only rebuild if the build
4648
Dockerfile has changed.
4749

4850
Assuming that the tests all pass, let's go ahead an compile the code and build the Docker images that Agon consists of.
4951

50-
To compile the code, create the Docker images, and compile and archive the sdks,
51-
run `make build`. This will compile the code and create the docker image.
52-
You may note that the docker image is tagged with a concatenation of the upcoming release number and short git hash
53-
for the current commit. This has also been set in the code itself, so that it can be seen in log statements.
52+
Let's compile and build everything, by running `make build`, this will:
53+
54+
- Compile the Agon Kubernetes integration code
55+
- Create the Docker images that we will later push
56+
- Build the local development tooling for all supported OS's
57+
- Compile and archive the SDKs in various languages
58+
59+
You may note that docker images, and tar archives are tagged with a concatenation of the
60+
upcoming release number and short git hash for the current commit. This has also been set in
61+
the code itself, so that it can be seen in via log statements.
5462

55-
Congratulations! You have now successfully tested and built Agon!
63+
Congratulations! You have now successfully tested and built Agon!
5664

5765
### Running a Test Google Kubernetes Engine Cluster
5866

gameservers/sidecar/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM alpine:3.6
22

3-
COPY ./bin/sidecar /home/agon/sidecar
3+
COPY ./bin/sidecar.linux.amd64 /home/agon/sidecar
44
RUN apk --update add ca-certificates && \
55
adduser -D agon && \
66
chown -R agon /home/agon && \

sdks/README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,35 @@ The GameServer state will be set `Shutdown` and the
3434
backing Pod will be deleted, if they have not shut themselves down already.
3535

3636
## Local Development
37-
(Coming soon: Track [this bug](https://github.com/googleprivate/agon/issues/8) for details)
37+
_Note:_ There has yet to be a release of Agon, so if you want the local
38+
development tools, you will need to [build from source](build/README.md).
39+
40+
If you do not wish to `make build` and build everything,
41+
the `make` target `build-gameservers-sidecar-binary` will compile the necessary binaries
42+
for all supported operating systems (64 bit windows, linux and osx).
43+
44+
You can find the binaries in the `bin` folder in [`gameservers/sidecar`](../gameservers/sidecar)
45+
once compilation is complete.
46+
47+
When the game server is running on Agon, the SDK communicates over TCP to a small
48+
gRPC server that Agon coordinated to runs in a container in the same network
49+
namespace as it - usually referred to in Kubernetes terms as a "sidecar".
50+
51+
Therefore, when developing locally, we also need a process for the SDK to connect to!
52+
53+
To do this, we can run the same binary that runs inside Agon, but pass in a flag
54+
to run it in "local mode". Local mode means that the sidecar binary
55+
won't try and connect to anything, and will just send logs messages to stdout so
56+
that you can see exactly what the SDK in your game server is doing, and can
57+
confirm everything works.
58+
59+
To run in local mode, pass the flag `--local` to the executable.
60+
61+
For example:
62+
63+
```bash
64+
$ ./sidecar.linux.amd64 --local
65+
{"level":"info","local":true,"msg":"Starting sdk sidecar","port":59357,"time":"2017-12-22T16:09:03-08:00","version":"0.1-5217b21"}
66+
{"level":"info","msg":"Ready request has been received!","time":"2017-12-22T16:09:19-08:00"}
67+
{"level":"info","msg":"Shutdown request has been received!","time":"2017-12-22T16:10:19-08:00"}
68+
```

0 commit comments

Comments
 (0)