Skip to content

Commit 983752b

Browse files
committed
Adds game server template with containerized sdk-client-test
1 parent 50d88e6 commit 983752b

File tree

10 files changed

+287
-259
lines changed

10 files changed

+287
-259
lines changed

test/sdk/go/Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2024 Google LLC All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Build the Go image from source
16+
FROM golang:1.22.6 AS build-stage
17+
18+
WORKDIR /agones.dev
19+
20+
COPY *.go ./
21+
22+
# Note: because this installs the most recently released version of Agones, this will need to be
23+
# built and pushed post-release.
24+
# TODO: Add to post-release check list.
25+
RUN go mod init agones.dev/agones/test/sdk/go/sdk-client-test
26+
RUN go mod tidy
27+
RUN go mod download
28+
29+
RUN CGO_ENABLED=0 GOOS=linux go build -o /sdk-client-test
30+
31+
# Copy the above binary into a lean image
32+
FROM gcr.io/distroless/static-debian12:nonroot AS build-release-stage
33+
34+
WORKDIR /
35+
36+
COPY --from=build-stage /sdk-client-test /sdk-client-test
37+
38+
USER nonroot:nonroot
39+
40+
ENTRYPOINT ["/sdk-client-test"]

test/sdk/go/Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2024 Google LLC All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#
16+
# Makefile for building a test game-server
17+
#
18+
19+
# __ __ _ _ _
20+
# \ \ / /_ _ _ __(_) __ _| |__ | | ___ ___
21+
# \ \ / / _` | '__| |/ _` | '_ \| |/ _ \ __|
22+
# \ V / (_| | | | | (_| | |_) | | __\__ \
23+
# \_/ \__,_|_| |_|\__,_|_.__/|_|\___|___/
24+
#
25+
26+
REGISTRY ?=
27+
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
28+
project_path := $(dir $(mkfile_path))
29+
root_path = $(realpath $(project_path)/)
30+
# Because go mod init in the Dockerfile installs the most recently released version of Agones, this
31+
# will need to be built and pushed post-release. During DEV it will be built at DEV - 1.
32+
base_version = 1.43.0
33+
server_tag := $(REGISTRY)/sdk-client-test:$(base_version)
34+
35+
# _____ _
36+
# |_ _|_ _ _ __ __ _ ___| |_ ___
37+
# | |/ _` | '__/ _` |/ _ \ __/ __|
38+
# | | (_| | | | (_| | __/ |_\__ \
39+
# |_|\__,_|_| \__, |\___|\__|___/
40+
# |___/
41+
42+
# Build a docker image for the server, and tag it
43+
build:
44+
cd $(root_path) && docker build -f $(project_path)Dockerfile --tag=$(server_tag) .
45+
46+
push: build
47+
docker push $(server_tag)
48+
49+
# build and push the sdk-client-test image with specified tag
50+
cloud-build:
51+
cd $(root_path) && gcloud builds submit --config=cloudbuild.yaml

test/sdk/go/cloudbuild.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
# Copyright 2024 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
steps:
16+
#
17+
# Creates the initial make + docker build platform
18+
#
19+
- name: ubuntu
20+
script: |
21+
echo 'FROM gcr.io/cloud-builders/docker:24.0.6\nRUN apt-get install make\nENTRYPOINT [\"/usr/bin/make\"]' > Dockerfile.build
22+
- name: gcr.io/cloud-builders/docker:24.0.6
23+
id: build-make-docker
24+
entrypoint: docker
25+
args: [build, -f, Dockerfile.build, -t, make-docker, .]
26+
27+
# build and push sdk-client-test image to Google Artifact Registry
28+
- name: make-docker
29+
id: push
30+
dir: .
31+
env: ['REGISTRY=${_REGISTRY}']
32+
script: |
33+
make push
34+
options:
35+
dynamic_substitutions: true
36+
substitutions:
37+
_REGISTRY: us-docker.pkg.dev/${PROJECT_ID}/ci
38+
timeout: 1800s

test/upgrade/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ FROM golang:1.22.6 AS build-stage
3939

4040
WORKDIR /agones.dev
4141

42-
COPY go.mod go.sum ./
43-
RUN go mod download
44-
4542
COPY *.go ./
4643

44+
RUN go mod init agones.dev/agones/test/upgrade/testContainer
45+
RUN go mod tidy
46+
RUN go mod download
47+
4748
RUN CGO_ENABLED=0 GOOS=linux go build -o /upgrade-test
4849

4950
# Copy the above binary into a lean image

test/upgrade/gameserverTemplate.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2024 Google LLC All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
---
16+
apiVersion: v1
17+
kind: ConfigMap
18+
metadata:
19+
name: gameserver-template
20+
data:
21+
gameserver.yaml: |
22+
---
23+
apiVersion: agones.dev/v1
24+
kind: GameServer
25+
metadata:
26+
generateName: sdk-client-test-
27+
labels:
28+
agonesVersion: {{ .AgonesVersion }}
29+
spec:
30+
ports:
31+
- name: default
32+
portPolicy: Dynamic
33+
containerPort: 7654
34+
template:
35+
metadata:
36+
labels:
37+
agonesVersion: {{ .AgonesVersion }}
38+
spec:
39+
containers:
40+
- name: sdk-client-test
41+
image: "{{ .Registry }}:{{ .AgonesVersion }}"
42+
resources:
43+
requests:
44+
memory: 64Mi
45+
cpu: 20m
46+
limits:
47+
memory: 64Mi
48+
cpu: 20m

test/upgrade/go.mod

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)