-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build Docker image for Game Server in Cloud Build (#114)
IT'S ALIVE (and surprisingly easy to do!) This has: * Dockerfile for the Unreal Engine Dedicated game server, built with the Unreal development container. * Documentation updates on how access the Unreal development containers. * Create the secret for the GitHub personal access token via Terraform. * Cloud Build script to create the image. Closes #29
- Loading branch information
1 parent
bd35d19
commit 3991e44
Showing
9 changed files
with
230 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2023 Google LLC 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. | ||
|
||
.vs | ||
*.blend1 | ||
*.fbx | ||
Binaries | ||
Build | ||
DerivedDataCache | ||
Droidshooter.sln | ||
Intermediate | ||
Packaged | ||
Saved | ||
*.code-workspace | ||
/Makefile |
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,34 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# 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. | ||
|
||
# | ||
# Build a container for the Unreal Engine dedicated game server | ||
# | ||
|
||
FROM ghcr.io/epicgames/unreal-engine:dev-slim-5.1.0 as builder | ||
ARG SERVER_CONFIG=Development | ||
|
||
COPY --chown=ue4:ue4 . /tmp/project | ||
|
||
RUN /home/ue4/UnrealEngine/Engine/Build/BatchFiles/RunUAT.sh BuildCookRun \ | ||
-Server -NoClient -ServerConfig=${SERVER_CONFIG} \ | ||
-Project=/tmp/project/Droidshooter.uproject \ | ||
-UTF8Output -NoDebugInfo -AllMaps -NoP4 -Build -Cook -Stage -Pak -Package -Archive \ | ||
-ArchiveDirectory=/tmp/project/Packaged \ | ||
-Platform=Linux | ||
|
||
FROM gcr.io/distroless/cc-debian11:nonroot | ||
COPY --from=builder --chown=nonroot:nonroot /tmp/project/Packaged/LinuxServer /home/nonroot/project | ||
EXPOSE 7777/udp | ||
ENTRYPOINT ["/home/nonroot/project/Droidshooter/Binaries/Linux/DroidshooterServer", "Droidshooter"] |
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 |
---|---|---|
@@ -1,3 +1,34 @@ | ||
# Droidshooter | ||
|
||
World scale demo for Google and Google Cloud for Games | ||
This is the Unreal Engine 5.1.0 project for the DroidShooter game! | ||
|
||
## Local Builds | ||
|
||
## Dedicated Game Server Docker Image | ||
|
||
```shell | ||
docker build . -t droidshooter-server | ||
``` | ||
|
||
To run, you will need a copy of Agones [local SDK](https://agones.dev/site/docs/guides/client-sdks/local/) toolkit. | ||
|
||
In one shell, start the local testing SDK server: | ||
|
||
```shell | ||
./sdk-server.linux.amd64 --local | ||
``` | ||
|
||
Then in another shell: | ||
|
||
```shell | ||
docker run --rm --network=host droidshooter-server:latest | ||
``` | ||
|
||
(In non *nix OS's where Docker is not native, you may need to do a slightly different network configuration to get the | ||
same experience) | ||
|
||
You now have a dedicated game server running on 127.0.0.1:7777 | ||
|
||
## Client building | ||
|
||
See the top level [README.md](../README.md#game-client) game client section for full launch instructions. |
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,39 @@ | ||
# Copyright 2023 Google LLC 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. | ||
|
||
serviceAccount: projects/${PROJECT_ID}/serviceAccounts/cloudbuild-cicd@${PROJECT_ID}.iam.gserviceaccount.com | ||
steps: | ||
- name: gcr.io/cloud-builders/docker | ||
id: github-login | ||
script: | | ||
echo $CR_PAT | docker login ghcr.io -u USERNAME --password-stdin | ||
secretEnv: | ||
- CR_PAT | ||
- name: gcr.io/cloud-builders/docker | ||
id: build-image | ||
args: ["build", ".", "-t", "${_UNREAL_SERVER_IMAGE}"] | ||
artifacts: | ||
images: | ||
- ${_REGISTRY}/droidshooter-server | ||
substitutions: | ||
_UNREAL_SERVER_IMAGE: ${_REGISTRY}/droidshooter-server:${BUILD_ID} | ||
_REGISTRY: us-docker.pkg.dev/${PROJECT_ID}/global-game-images | ||
availableSecrets: | ||
secretManager: | ||
- versionName: projects/${PROJECT_ID}/secrets/github-packages/versions/latest | ||
env: CR_PAT | ||
options: | ||
dynamic_substitutions: true | ||
machineType: E2_HIGHCPU_32 | ||
logging: CLOUD_LOGGING_ONLY |
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,41 @@ | ||
# Copyright 2023 Google LLC 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. | ||
|
||
resource "google_secret_manager_secret" "secret_github_packages" { | ||
secret_id = "github-packages" | ||
|
||
labels = { | ||
"environment" = var.resource_env_label | ||
} | ||
|
||
replication { | ||
automatic = true | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_version" "pat_1" { | ||
secret = google_secret_manager_secret.secret_github_packages.id | ||
enabled = true | ||
|
||
secret_data = var.github_pat | ||
} | ||
|
||
resource "google_secret_manager_secret_iam_binding" "cloud_build_binding" { | ||
project = var.project | ||
secret_id = google_secret_manager_secret.secret_github_packages.id | ||
role = "roles/secretmanager.secretAccessor" | ||
members = [ | ||
"serviceAccount:cloudbuild-cicd@${var.project}.iam.gserviceaccount.com", | ||
] | ||
} |
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