Skip to content

Game is containerized #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM barichello/godot-ci:3.3

RUN useradd -ms /bin/bash node

WORKDIR /ghosted

RUN mkdir -v -p ~/.local/share/godot/templates
RUN mkdir -v -p build/web ~/.local/share/godot/templates


ADD . .
# RUN chown -R node:node /ghosted
RUN godot -v --export "HTML5" ./build/web/index.html

COPY scores.json /ghosted/build/web/scores.json
WORKDIR /ghosted/build/web

CMD ["python", "-m", "SimpleHTTPServer", "7777"]

23 changes: 23 additions & 0 deletions Dockerfile.fedora
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM fedora:33

WORKDIR /root

RUN dnf -y upgrade --setopt=install_weak_deps=False && \
dnf -y install --setopt=install_weak_deps=False \
bash bzip2 curl git make nano patch pkgconfig python-unversioned-command python3-pip unzip which xz && \
pip install scons==4.1.0

RUN dnf install -y scons pkgconfig libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel \
libXi-devel mesa-libGL-devel mesa-libGLU-devel alsa-lib-devel pulseaudio-libs-devel \
libudev-devel yasm gcc-c++ libstdc++-static xorg-x11-apps


WORKDIR /ghosted

ADD . .

# RUN scons -f /root/SConstruct -j8 platform=server tools=no target=release
RUN scons -f /root/Sconstruct platform=x11 tools=no target=release_debug bits=64

CMD ["/ghosted/ghosted.x86_64"]

19 changes: 13 additions & 6 deletions Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,27 @@ func new_round():
func save_score(score):
if $HUD/PlayerList/LocalPlayer.text != "":
var file = File.new()
# var file = $HTTPRequest.request("localhost:7777/scores.json")
if score > get_player_high_score($HUD/PlayerList/LocalPlayer.text):
file.open("scores.json", File.WRITE)
file.open("./scores.json", File.WRITE)
highScores[$HUD/PlayerList/LocalPlayer.text] = score
file.store_string(JSON.print(highScores))
file.close()


func load_scores():
var file = File.new()
if file.file_exists("scores.json"):
file.open("scores.json", File.READ)
var json_records = JSON.parse(file.get_as_text())
file.close()
var file
var request = $HTTPRequest.request("localhost:7777/scores.json")
if request == OK:
var json_records = JSON.parse(request.get_as_text())
return json_records.result
else:
file = File.new()
if file.file_exists("./scores.json"):
file.open("./scores.json", File.READ)
var json_records = JSON.parse(file.get_as_text())
file.close()
return json_records.result


func get_player_high_score(name):
Expand Down
2 changes: 2 additions & 0 deletions Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ position = Vector2( 4363.53, 1302.94 )
[node name="HellSpawn3" parent="." instance=ExtResource( 8 )]
position = Vector2( 1030.77, 1210.74 )

[node name="HTTPRequest" type="HTTPRequest" parent="."]

[connection signal="bonus_points" from="Player" to="." method="_on_Player_bonus_points"]
[connection signal="hit" from="Player" to="." method="game_over"]
[connection signal="timeout" from="MobTimer" to="." method="_on_MobTimer_timeout"]
Expand Down
44 changes: 44 additions & 0 deletions deploy/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ghosted
spec:
replicas: 1
selector:
matchLabels:
app: ghosted
template:
metadata:
labels:
app: ghosted
spec:
containers:
- name: ghosted
image: quay.io/bholifie/ghosted:latest
ports:
- containerPort: 7777
resources:
requests:
memory: "500Mi"
cpu: "500m"
limits:
memory: "2Gi"
cpu: "2"

---
apiVersion: v1
kind: Service
metadata:
labels:
app: ghosted
name: ghosted-service
spec:
ports:
- name: 7777-tcp
port: 7777
protocol: TCP
targetPort: 7777
selector:
app: ghosted
sessionAffinity: None
type: ClusterIP
9 changes: 5 additions & 4 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="exported/creep/index.html"
export_path="build/web/index.html"
patch_list=PoolStringArray( )
script_export_mode=1
script_encryption_key=""

Expand All @@ -27,12 +28,12 @@ html/experimental_virtual_keyboard=false

name="Linux/X11"
platform="Linux/X11"
runnable=true
runnable=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
export_path="./ghosted.x86_64"
script_export_mode=1
script_encryption_key=""

Expand All @@ -41,7 +42,7 @@ script_encryption_key=""
custom_template/debug=""
custom_template/release=""
binary_format/64_bits=true
binary_format/embed_pck=false
binary_format/embed_pck=true
texture_format/bptc=false
texture_format/s3tc=true
texture_format/etc=false
Expand Down