Skip to content

Commit

Permalink
feature: create new game-server-watcher (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhenkel92 authored May 6, 2024
1 parent 6a05123 commit a25269c
Show file tree
Hide file tree
Showing 32 changed files with 540 additions and 114 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/game-server-watcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on:
push:
branches:
- main
paths:
- ".github/workflows/game-server-watcher.yml"
- "game-server-watcher/**/*"

name: Cloud Game Server Watcher

jobs:
build:
name: Build Game Server Watcher
runs-on: ubuntu-latest
env:
IMAGE: cloudgame/game-server-watcher
steps:
- uses: actions/checkout@master
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Go vet
run: |
cd game-server-watcher
go vet ./...
- name: Build Docker Container
run: |
cd game-server-watcher
docker build -t $IMAGE:$GITHUB_RUN_ID -f Dockerfile --build-arg DD_GIT_REPOSITORY_URL=$(git config --get remote.origin.url) --build-arg DD_GIT_COMMIT_SHA=${{ github.sha }} .
- name: Push Container
run: |
docker tag $IMAGE:$GITHUB_RUN_ID $IMAGE:latest
docker push $IMAGE:$GITHUB_RUN_ID
docker push $IMAGE:latest
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ repos:
#########################################
- repo: local
hooks:
- id: cargo:fmt
name: Cargo fmt
- id: go:fmt
name: Go fmt
language: script
pass_filenames: false
files: ^game-server-watcher/
entry: ./bin/execute-cargo.sh
args: ["game-server-watcher", "fmt", "--all", "--", "--check"]
- id: cargo:clippy
name: Cargo clippy
entry: ./bin/execute-go.sh
args: ["game-server-watcher", "fmt", "./..."]
- id: go:vet
name: Go Vet
language: script
pass_filenames: false
files: ^game-server-watcher/
entry: ./bin/execute-cargo.sh
args: ["game-server-watcher", "clippy", "--features", "strict"]
entry: ./bin/execute-go.sh
args: ["game-server-watcher", "vet", "./..."]
2 changes: 1 addition & 1 deletion async-server-provisioner/config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ datadog:
api_key: placeholder

cloudGame:
ansibleBranch: use-latest-backup
ansibleBranch: main
apiUrl: http://host.docker.internal:1337
apiToken: placeholder
backupS3Bucket: cloud-game-dev
2 changes: 1 addition & 1 deletion backend/.strapi-updater.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"latest": "4.24.1",
"lastUpdateCheck": 1714910701412,
"lastUpdateCheck": 1715013457662,
"lastNotification": 1714740179673
}
26 changes: 26 additions & 0 deletions backend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@ module.exports = {
* This gives you an opportunity to extend code.
*/
register(/*{ strapi }*/) {
const extension = ({ nexus }) => ({
typeDefs: `
type GameServerPort {
port: Int!
protocol: String!
is_open: Boolean!
}
extend type GameDeployment {
game_server_ports: [GameServerPort!]
}
`,
resolvers: {
GameDeployment: {
game_server_ports: {
resolve: async (parent, args, context) => {
console.log(parent.id);
const data = await fetch("http://localhost:8080/ports");
return data.json();
},
},
},
},
// plugins: [nexus.plugin({})],
});

strapi.plugin("graphql").service("extension").use(extension);
// const extensionService = strapi.plugin('graphql').service('extension');
// extensionService.use({
// resolversConfig: {
Expand Down
13 changes: 13 additions & 0 deletions bin/execute-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
project=$1

if [ "$#" -lt 2 ]; then
exit 1
fi

cd $DIR/../$1
go ${*:2}
File renamed without changes.
90 changes: 90 additions & 0 deletions game-server-watcher-old/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
### Rust template
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Rust template
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions game-server-watcher-old/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ARG BUILD_BASE=1.56.1-alpine3.14
ARG BASE=3.14

FROM rust:${BUILD_BASE} as build

WORKDIR /root

RUN apk add --no-cache musl-dev

COPY . .

ENV CARGO_HTTP_MULTIPLEXING=false
RUN cargo build --release --features "strict"

FROM alpine:${BASE}

COPY --from=build /root/target/release/game-server-watcher /usr/bin/game-server-watcher

ENTRYPOINT ["/usr/bin/game-server-watcher"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
90 changes: 1 addition & 89 deletions game-server-watcher/.gitignore
Original file line number Diff line number Diff line change
@@ -1,90 +1,2 @@
### Rust template
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Rust template
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# These are backup files generated by rustfmt
**/*.rs.bk
dist/
19 changes: 7 additions & 12 deletions game-server-watcher/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
ARG BUILD_BASE=1.56.1-alpine3.14
ARG BASE=3.14
FROM golang:1.22-alpine3.19 as build

FROM rust:${BUILD_BASE} as build

WORKDIR /root

RUN apk add --no-cache musl-dev
ENV workdir=/usr/app
WORKDIR /usr/app

COPY . .

ENV CARGO_HTTP_MULTIPLEXING=false
RUN cargo build --release --features "strict"
RUN CGO_ENABLED=0 go build -o ./game-server-watcher ./cmd/game-server-watcher/*

FROM alpine:${BASE}
FROM alpine:3.19

COPY --from=build /root/target/release/game-server-watcher /usr/bin/game-server-watcher
COPY --from=build /usr/app/game-server-watcher /usr/bin/game-server-watcher

ENTRYPOINT ["/usr/bin/game-server-watcher"]
ENTRYPOINT ["game-server-watcher"]
Loading

0 comments on commit a25269c

Please sign in to comment.