Skip to content

Commit

Permalink
Merge pull request #11 from sdsznsk/pr-mods
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpas authored Nov 3, 2023
2 parents 8fff96b + 9d994e8 commit 2d7cb57
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ ENV ARMA_PROFILE=/home/profile
ENV ARMA_BINARY="./ArmaReforgerServer"
ENV ARMA_PARAMS=""
ENV ARMA_MAX_FPS=120
ENV ARMA_WORKSHOP_DIR=/reforger/workshop

ENV SERVER_BIND_ADDRESS="0.0.0.0"
ENV SERVER_BIND_PORT=2001
Expand All @@ -61,6 +62,8 @@ ENV GAME_PROPS_FAST_VALIDATION=true
ENV GAME_PROPS_SERVER_MAX_VIEW_DISTANCE=2500
ENV GAME_PROPS_SERVER_MIN_GRASS_DISTANCE=50
ENV GAME_PROPS_NETWORK_VIEW_DISTANCE=1000
ENV GAME_MODS_IDS_LIST=""
ENV GAME_MODS_JSON_FILE_PATH=""

ENV SKIP_INSTALL=false

Expand All @@ -69,6 +72,7 @@ WORKDIR /reforger
VOLUME /steamcmd
VOLUME /home/profile
VOLUME /reforger/Configs
VOLUME /reforger/workshop

EXPOSE 2001/udp
EXPOSE 17777/udp
Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ An Arma Reforger dedicated server. Updates to the latest version every time it i
-p 2001:2001/udp \
-v path/to/configs:/reforger/Configs \
-v path/to/profiles:/home/profile \
-v path/to/workshop:/reforger/workshop \
-e SERVER_REGION="EU" \
-e SERVER_HOST_REGISTER_ADDRESS="public ip" \
-e GAME_NAME="My Docker Reforger Server" \
Expand All @@ -26,7 +27,7 @@ Simply check-out / copy [the provided docker-compose.yml](docker-compose.yml) an

## Parameters

Check [the Dockerfile](Dockerfile#L32-L64), more docs will come later.
Check [the Dockerfile](Dockerfile#L32-L67), more docs will come later.

### Configs

Expand All @@ -37,3 +38,33 @@ Alternatively, change the `ARMA_CONFIG` variable to a file present in the `Confi
### Experimental server

To use the experimental server instead of the regular set `STEAM_APPID` variable to `1890870`.

### Mods

Workshop mods can be defined in two ways. You can use both or either of those.

#### GAME_MODS_IDS_LIST

A comma separated list of IDs, with an optional version.

```sh
-e GAME_MODS_IDS_LIST="5965770215E93269=1.0.6,5965550F24A0C152"
```

#### GAME_MODS_JSON_FILE_PATH

Path to a JSON file that contains array of mod objects.

```sh
-v ${PWD}/mods_file.json:/mods_file.json
-e GAME_MODS_JSON_FILE_PATH="/mods_file.json"
```

```json
[
{
"modId": "597706449575D90B",
"version": "1.1.1"
}
]
```
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
volumes:
- ./reforger/configs:/reforger/Configs
- ./reforger/profile:/home/profile
- ./reforger/workshop:/reforger/workshop
environment:
- SERVER_PUBLIC_ADDRESS=public-ip
- GAME_NAME=My Docker Reforger Server
35 changes: 35 additions & 0 deletions launch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
import random
import re
import subprocess

CONFIG_GENERATED = "/reforger/Configs/docker_generated.json"
Expand Down Expand Up @@ -112,6 +113,38 @@ def bool_str(text):
config["game"]["gameProperties"]["networkViewDistance"] = int(
os.environ["GAME_PROPS_NETWORK_VIEW_DISTANCE"]
)
if env_defined("GAME_MODS_IDS_LIST"):
reg = re.compile(r"^[A-Z\d,=.]+$")
assert reg.match(
str(os.environ["GAME_MODS_IDS_LIST"])
), "Illegal characters in GAME_MODS_IDS_LIST env"
mods = str(os.environ["GAME_MODS_IDS_LIST"]).split(",")
mods[:] = [mod for mod in mods if mod] # Remove empty items form list
reg = re.compile(r"^\d\.\d\.\d$")
for mod in mods:
mod_details = mod.split("=")
assert 0 < len(mod_details) < 3, f"{mod} mod not defined properly"
mod_config = {"modId": mod_details[0]}
if len(mod_details) == 2:
assert reg.match(
mod_details[1]
), f"{mod} mod version does not match the pattern"
mod_config["version"] = mod_details[1]
config["game"]["mods"].append(mod_config)
if env_defined("GAME_MODS_JSON_FILE_PATH"):
with open(os.environ["GAME_MODS_JSON_FILE_PATH"]) as f:
json_mods = json.load(f)
allowed_keys = ["modId", "name", "version"]
for provided_mod in json_mods:
assert (
"modId" in provided_mod
), f"Entry in GAME_MODS_JSON_FILE_PATH file does not contain modId: {provided_mod}"
valid_mod = {
key: provided_mod[key]
for key in allowed_keys
if key in provided_mod
} # Extract only valid config keys
config["game"]["mods"].append(valid_mod)

f = open(CONFIG_GENERATED, "w")
json.dump(config, f, indent=4)
Expand All @@ -127,6 +160,8 @@ def bool_str(text):
"-nothrow",
f"-maxFPS {os.environ['ARMA_MAX_FPS']}",
f"-profile {os.environ['ARMA_PROFILE']}",
f"-addonDownloadDir {os.environ['ARMA_WORKSHOP_DIR']}",
f"-addonsDir {os.environ['ARMA_WORKSHOP_DIR']}",
os.environ["ARMA_PARAMS"],
]
)
Expand Down

0 comments on commit 2d7cb57

Please sign in to comment.