Skip to content
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

Add parameters for basic handling of mods #11

Merged
merged 19 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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_REGION="EU"
ENV SERVER_ID=""
Expand All @@ -62,6 +63,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 @@ -70,6 +73,7 @@ WORKDIR /reforger
VOLUME /steamcmd
VOLUME /home/profile
VOLUME /reforger/Configs
VOLUME /reforger/workshop

EXPOSE 2001/udp
EXPOSE 17777/udp
Expand Down
24 changes: 23 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,10 +27,31 @@ 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

By default the configs are generated from the ENV variables in the dockerfile. After the first run the file can be expanded with additional options manually, but the fields will always be overwritten by the ENV variables.

Alternatively, change the `ARMA_CONFIG` variable to a file present in the `Configs` volume. It will be used without modification.

### Mods

Workshop mods can be defined in two ways. You can use both or either of those.
- via GAME_MODS_IDS_LIST variable as a comma separated list of IDs, with an optional version, for example
```sh
-e GAME_MODS_IDS_LIST="5965770215E93269=1.0.6,5965550F24A0C152"
```
- via GAME_MODS_JSON_FILE_PATH variable, as a JSON file that contains array of mod objects, for example
```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 @@ -10,6 +10,7 @@ services:
volumes:
- ./reforger/configs:/reforger/Configs
- ./reforger/profile:/home/profile
- ./reforger/workshop:/reforger/workshop
environment:
- SERVER_REGION=EU # or other ISO 3166-1 alpha-2 code
- SERVER_HOST_REGISTER_ADDRESS=public-ip
Expand Down
26 changes: 26 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 @@ -109,6 +110,29 @@ 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"
sdsznsk marked this conversation as resolved.
Show resolved Hide resolved
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)
for mod in json_mods:
config["game"]["mods"].append(mod)
Dahlgren marked this conversation as resolved.
Show resolved Hide resolved

f = open(CONFIG_GENERATED, "w")
json.dump(config, f, indent=4)
Expand All @@ -124,6 +148,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