You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an issue when using Docker Compose with an Arma Reforger server, specifically when attempting to use Docker secrets for environment variables. When the GAME_PASSWORD environment variable is set to reference a Docker secret, the directory path to the secret is passed as a string, causing the password to be set as the directory path instead of the actual password stored in the secret file.
To Reproduce
Steps to reproduce the behavior:
Set the GAME_PASSWORD variable to: /run/secrets/game_password
Launch the game server
The admin password is set as the string: /run/secrets/game_password (instead of reading the password content from the secret file)
Expected Behavior
The value in the Docker secret file should be read correctly, and the password inside that file should be set as the game server's game password, rather than using the path to the file itself.
Code to Handle Secrets
I’ve created a helper function to check whether the value is an environment variable or a secret file, and read the secret if applicable. Here’s the code I’m using to fetch the secret:
Function that fetches the value of an environment variable. If the value starts with '/run/secrets/', it reads the content of the file at that location (Docker secret). Otherwise, it returns the variable value directly.
defget_secret_or_env_value(env_var_name):
value=Noneifenv_defined(env_var_name):
value=os.environ[env_var_name]
ifvalue.startswith('/run/secrets/'):
try:
withopen(value, 'r') assecret_file:
secret_value=secret_file.read().strip()
print(f"{env_var_name}: '{secret_value}'")
value=secret_valueexceptFileNotFoundError:
print(f"Secret file '{value}' not found for {env_var_name}.")
exceptExceptionase:
print(f"Error reading secret file for {env_var_name}: '{e}'")
returnvalue
Additional Context
I’ve created a fork to restructure some of the steamcmd code into functions and moved things around to suit my needs, so I won’t be able to submit a pull request directly. However, feel free to check out my repo for the changes: Nhimself Reforger Repo
Let me know if you need more details or clarification!
The text was updated successfully, but these errors were encountered:
No Support for Docker Secrets
There is an issue when using Docker Compose with an Arma Reforger server, specifically when attempting to use Docker secrets for environment variables. When the GAME_PASSWORD environment variable is set to reference a Docker secret, the directory path to the secret is passed as a string, causing the password to be set as the directory path instead of the actual password stored in the secret file.
To Reproduce
Steps to reproduce the behavior:
GAME_PASSWORD
variable to:/run/secrets/game_password
/run/secrets/game_password
(instead of reading the password content from the secret file)Expected Behavior
The value in the Docker secret file should be read correctly, and the password inside that file should be set as the game server's game password, rather than using the path to the file itself.
Code to Handle Secrets
I’ve created a helper function to check whether the value is an environment variable or a secret file, and read the secret if applicable. Here’s the code I’m using to fetch the secret:
Function that fetches the value of an environment variable. If the value starts with '/run/secrets/', it reads the content of the file at that location (Docker secret). Otherwise, it returns the variable value directly.
Additional Context
I’ve created a fork to restructure some of the steamcmd code into functions and moved things around to suit my needs, so I won’t be able to submit a pull request directly. However, feel free to check out my repo for the changes:
Nhimself Reforger Repo
Let me know if you need more details or clarification!
The text was updated successfully, but these errors were encountered: