Skip to content

Commit

Permalink
Working on v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdalertdk committed Jun 20, 2024
1 parent bff9f58 commit 8b41c52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ EXPOSE 8088/tcp
EXPOSE 8089/tcp

ENTRYPOINT [ "/etc/entrypoint.d/docker-entrypoint.sh" ]
CMD ["python3", "-m", "opentakserver.app"]
CMD ["python3", "-u", "-m", "opentakserver.app"]
18 changes: 12 additions & 6 deletions entrypoint.d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,35 @@ def save_config(config):
# Get default config from opentakserver
config.from_object(DefaultConfig);

# Get env variables with the prefix 'DOCKER_'
# Used so we can override variables from the docker-compose file
config.from_prefixed_env('DOCKER');

# Override settings to make OTS work in a container
config.update(
OTS_LISTENER_ADDRESS = os.environ.get("DOCKER_OTS_LISTENER_ADDRESS", "0.0.0.0"),
OTS_RABBITMQ_SERVER_ADDRESS = os.environ.get("DOCKER_OTS_RABBITMQ_SERVER_ADDRESS", "rabbitmq")
OTS_RABBITMQ_SERVER_ADDRESS = os.environ.get("DOCKER_OTS_RABBITMQ_SERVER_ADDRESS", "rabbitmq"),
OTS_CA_SUBJECT = '/C={}/ST={}/L={}/O={}/OU={}'.format( config["OTS_CA_COUNTRY"], config["OTS_CA_STATE"], config["OTS_CA_CITY"], config["OTS_CA_ORGANIZATION"], config["OTS_CA_ORGANIZATIONAL_UNIT"] ),
SECURITY_TOTP_ISSUER = config["OTS_CA_ORGANIZATION"]
)

# Get env variables with the prefix 'DOCKER_'
# Used so we can override variables from the docker-compose file
config.from_prefixed_env('DOCKER');

save_config(config)
else:
print('Container init | Found existing config.yml')

print('Container init | Checking environment variables...')

# Get config.yml
init_config_file = FlaskConfig(config_file)
init_config_file.from_file(config_file, load=yaml.safe_load);

# Get Docker Env
init_config_env = FlaskConfig(config_file)
init_config_env.from_prefixed_env('DOCKER');

# Compare config.yml and docker env.
init_config_diff = set(init_config_file).intersection(set(init_config_env))

# If there is a differnce between the two, update config.yml with the new docker env.
if bool(init_config_diff):
init_config_updated = dict()
for value in init_config_diff:
Expand Down

0 comments on commit 8b41c52

Please sign in to comment.