Skip to content

Commit

Permalink
Merge pull request #16 from startersclan/enhancement/heatmaps-add-env…
Browse files Browse the repository at this point in the history
…-var-config-support-for-heatmaps-config

Enhancement (heatmaps): Add env var config support for `heatmaps` config
  • Loading branch information
leojonathanoh authored Oct 31, 2023
2 parents c8526ea + 1c7ed31 commit 424b418
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"request": "launch",
"port": 9000,
"pathMappings": {
"/heatmaps": "${workspaceRoot}/heatmaps",
"/web": "${workspaceRoot}/web",
},
"xdebugSettings": {
Expand Down
21 changes: 16 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ services:
# 3. HLStatsX:CE perl daemon accepts the gameserver logs. Gameserver Logs are parsed and stats are recorded
# The daemon's proxy_key secret can only be setup in the HLStatsX:CE Web Admin Panel Settings under 'Proxy Settings' section
# HLStatsX:CE perl daemon: https://github.com/startersclan/docker-hlstatsxce-daemon
# NOTE: Currently, as of v1.6.19, the daemon crashes upon startup. You will need to fix perl errors and rebuild the image.
daemon:
build:
dockerfile: Dockerfile.daemon
Expand All @@ -78,7 +76,6 @@ services:
- --db-username=hlstatsxce
- --db-password=hlstatsxce
- --nodns-resolveip
- --rcon
- --debug
# - --debug
# - --help
Expand Down Expand Up @@ -182,9 +179,23 @@ services:
cache_to:
- type=local,dest=/tmp/.buildx-cache-web,mode=max
volumes:
- ./web:/web
- ./heatmaps:/heatmaps
- ./config/heatmaps/config.inc.php:/heatmaps/config.inc.php:ro # Heatmaps config file
- ./web:/web
environment:
- DB_HOST=db
- DB_NAME=hlstatsxce
- DB_USER=hlstatsxce
- DB_PASS=hlstatsxce
- HLXCE_WEB=/web
- HUD_URL=http://www.hlxcommunity.com
- OUTPUT_SIZE=medium
- DEBUG=1
extra_hosts:
# For xdebug to reach the host via `host.docker.internal`. See: https://github.com/moby/moby/pull/40007#issuecomment-578729356 and https://stackoverflow.com/questions/49907308/installing-xdebug-in-docker
# If xdebug does not work, you may need to add an iptables rule to the INPUT chain: iptables -A INPUT -i br+ -j ACCEPT
- host.docker.internal:host-gateway
depends_on:
- init-container
working_dir: /heatmaps
stop_signal: SIGKILL
entrypoint:
Expand Down
37 changes: 24 additions & 13 deletions heatmaps/config.inc.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
<?php
function iniSet($name, $default) {
$value = getenv($name) ? getenv($name) : $default;
ini_set($name, $value);
}
function defineVar($name, $default) {
$value = getenv($name) ? getenv($name) : $default;
$value = gettype($default) == 'boolean' && $value == 'false' ? false : $value; // Fix string 'false' becoming true for boolean when using settype
settype($value, gettype($default));
define($name, $value);
}

error_reporting(E_ALL);
ini_set("memory_limit", "32M");
ini_set("max_execution_time", "0");
iniSet("memory_limit", "32M");
iniSet("max_execution_time", "0");

define('DB_HOST', 'localhost');
define('DB_USER', '');
define('DB_PASS', '');
define('DB_NAME', '');
define('HLXCE_WEB', '/path/to/where/you/have/your/hlstats/web');
define('HUD_URL', 'http://www.hlxcommunity.com');
define('OUTPUT_SIZE', 'medium');
defineVar('DB_HOST', 'localhost');
defineVar('DB_USER', '');
defineVar('DB_PASS', '');
defineVar('DB_NAME', '');
defineVar('HLXCE_WEB', '/path/to/where/you/have/your/hlstats/web');
defineVar('HUD_URL', 'http://www.hlxcommunity.com');
defineVar('OUTPUT_SIZE', 'medium');

define('DB_PREFIX', 'hlstats');
define('KILL_LIMIT', 10000);
define('DEBUG', 1);
defineVar('DB_PREFIX', 'hlstats');
defineVar('KILL_LIMIT', 10000);
defineVar('DEBUG', 1);

// No need to change this unless you are on really low disk.
define('CACHE_DIR', dirname(__FILE__) . '/cache');
defineVar('CACHE_DIR', dirname(__FILE__) . '/cache');

0 comments on commit 424b418

Please sign in to comment.