aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Dockerfile10
-rw-r--r--docker-compose.yaml11
-rw-r--r--entrypoint.bash34
4 files changed, 57 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..dea4296
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/.env
+/nuclearoption/ \ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..77ecf3d
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,10 @@
+FROM ghcr.io/steamcmd/steamcmd:debian-13
+WORKDIR /app
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ jq \
+ && rm -rf /var/lib/apt/lists/*
+
+COPY entrypoint.bash /
+RUN chmod +x /entrypoint.bash
+ENTRYPOINT [ "/entrypoint.bash" ] \ No newline at end of file
diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 0000000..c8c66b7
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,11 @@
+services:
+ nuclearoption:
+ build: .
+ # environment:
+ # - STEAM_USERNAME=anonymous
+ # - STEAM_PASSWORD=
+ network_mode: host
+ env_file:
+ - .env
+ volumes:
+ - ./nuclearoption:/app \ No newline at end of file
diff --git a/entrypoint.bash b/entrypoint.bash
new file mode 100644
index 0000000..3616629
--- /dev/null
+++ b/entrypoint.bash
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# do we have a username and password?
+if [ "$STEAM_USERNAME" = "anonymous" ]; then
+ echo "Using anonymous login. No password needed."
+ STEAM_PASSWORD=""
+elif [ -z "$STEAM_USERNAME" ] || [ -z "$STEAM_PASSWORD" ]; then
+ echo "Please set STEAM_USERNAME and STEAM_PASSWORD environment variables."
+ echo "If you want to use anonymous login, set STEAM_USERNAME to 'anonymous' and leave STEAM_PASSWORD empty."
+ exit 1
+fi
+
+# install game server via steamcmd
+steamcmd +login "$STEAM_USERNAME" "$STEAM_PASSWORD" +force_install_dir /app +app_update 3930080 validate +quit
+
+# handle configuration file changes
+CONFIG_FIELDS=(
+ "ServerName"
+ "MaxPlayers"
+ "Password"
+)
+
+CONFIG_PATH="/app/DedicatedServerConfig.json"
+
+for FIELD in "${CONFIG_FIELDS[@]}"; do
+ ENV_VAR="CONFIG_${FIELD^^}"
+ if [ -n "${!ENV_VAR}" ]; then
+ echo "Setting $FIELD to ${!ENV_VAR} in config file."
+ jq --arg value "${!ENV_VAR}" ".${FIELD} = \$value" "$CONFIG_PATH" > tmp.$$.json && mv tmp.$$.json "$CONFIG_PATH"
+ fi
+done
+
+# run the server
+sh /app/RunServer.sh \ No newline at end of file