-
Notifications
You must be signed in to change notification settings - Fork 811
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes the sdk generation tooling from our main build image.
Each supported SDK language has its own Dockerfile. We support 3 commands (gen,build,test) for each SDK. Add documentation on how to add a new SDK.
- Loading branch information
Cyril Tovena
committed
Mar 20, 2019
1 parent
cf49d9c
commit a651191
Showing
23 changed files
with
470 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Agones SDKs build | ||
|
||
As we seen before GameServers can communicate their current state back to Agones controller using a side car. This sidecar runs a GRPC server handling the communication to Agones, the GameServer connects using a SDK which a thin wrapper around GRPC client code. | ||
|
||
By using GRPC, adding more languages should be pretty straigthforward as it supports code generation for many of them. | ||
|
||
> if your language doesn't support GRPC you can still create a SDK by connecting to the HTTP GRPC gateway. | ||
This guide explains how to build, test and generate GRPC code for our SDKs but also how to add a new language. | ||
|
||
## How it works | ||
|
||
Our build system heavily rely on Docker and make, but that's all you need. The rest of the GRPC tooling and language specific dependencies are installed inside Docker images via Dockerfile. | ||
|
||
We separated each language specific tooling in their on Docker image, this way building them will be faster and easier to maintain. | ||
|
||
A base GRPC image with protoc is provided, every other images inherit from it via the `FROM` Dockerfile syntax. This way SDKs grpc code is generated from the same version of our SDK sidecar. | ||
|
||
## Targets | ||
|
||
We currently support 3 commands per SDK: | ||
|
||
- `gen` to generate GRPC required by SDKs. | ||
- `test` to run SDKs tests. | ||
- `build` to build SDKs binaries. | ||
|
||
> All commands might not be required for all SDKs. (e.g. build is only used for our cpp SDK) | ||
SDKs build scripts and Dockerfile are stored in a folder in this directory. | ||
|
||
To run tests for a single SDK use with the `SDK_FOLDER` of your choice: | ||
|
||
```bash | ||
make test-sdk SDK_FOLDER=go | ||
``` | ||
|
||
You can also run all SDKs tests by using `make test-sdks`. | ||
|
||
To generate GRPC code and build binaries you can respectively use: | ||
|
||
```bash | ||
make gen-sdk-grpc SDK_FOLDER=go | ||
make build-sdk SDK_FOLDER=go | ||
|
||
# for all SDKs | ||
make gen-all-sdk-grpc | ||
make build-sdks | ||
``` | ||
|
||
## Adding support for a new language | ||
|
||
Makefile targets run docker containers built from Dockerfile in each folder found in this directory. This means you don't need to change our Makefile | ||
|
||
Simply create a new directory with the name of your SDK. Then copy our [template](./tool/template) folder content you SDK folder. | ||
|
||
Edit the Dockerfile to install all dependencies you need to generate, build and test your SDK. (you should not need to change the base image) | ||
|
||
> As explained in our [SDK documentation](https://agones.dev/site/docs/guides/client-sdks/) you have 2 options HTTP or GRPC. If you are using HTTP you don't need to use our base SDK image so feel free to use the distribution of your choice. | ||
Then add your steps in `build.sh`, `test.sh` and `gen.sh` script files. | ||
|
||
You should now be able to use your `SDK_FOLDER` with our [Makefile targets](#targets). | ||
|
||
Each targets will ensure that your Dockerfile is built and then run the image with a pre-defined command. The Agones code source repository is mounted in the working directory inside the container and you can also access the current Agones version via the environment variable `VERSION`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2018 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
ARG BASE_IMAGE=agones-build-sdk-base:latest | ||
FROM $BASE_IMAGE | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y zip && \ | ||
apt-get clean | ||
|
||
# code generation scripts | ||
COPY *.sh /root/ | ||
RUN chmod +x /root/*.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2017 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
|
||
cd ./sdks/cpp | ||
make build install archive VERSION=$VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2019 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
ARG BASE_IMAGE=agones-build-sdk-base:latest | ||
FROM $BASE_IMAGE | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y wget jq && \ | ||
apt-get clean | ||
|
||
# install go | ||
WORKDIR /usr/local | ||
ENV GO_VERSION=1.11.5 | ||
ENV GOPATH /go | ||
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \ | ||
tar -xzf go${GO_VERSION}.linux-amd64.tar.gz && rm go${GO_VERSION}.linux-amd64.tar.gz && mkdir -p ${GOPATH} | ||
|
||
ENV PATH /usr/local/go/bin:/go/bin:$PATH | ||
|
||
# install go-proto-gen 1.1 | ||
RUN mkdir -p /go/src/github.com/golang && cd /go/src/github.com/golang && \ | ||
git clone https://github.com/golang/protobuf.git && \ | ||
cd protobuf && git checkout v1.2.0 && \ | ||
go install github.com/golang/protobuf/protoc-gen-go && \ | ||
go get -u golang.org/x/tools/cmd/goimports | ||
|
||
|
||
# code generation scripts | ||
COPY *.sh /root/ | ||
RUN chmod +x /root/*.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2017 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
go test -v -race agones.dev/agones/sdks/... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2019 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
ARG BASE_IMAGE=agones-build-sdk-base:latest | ||
FROM $BASE_IMAGE | ||
|
||
RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - && \ | ||
apt-get install -y nodejs | ||
|
||
# code generation scripts | ||
COPY *.sh /root/ | ||
RUN chmod +x /root/*.sh |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2017 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -x | ||
cd ./sdks/nodejs | ||
npm install-test |
Oops, something went wrong.