Skip to content

NeedForKillTheGame/nfk-stats

Folders and files

NameName
Last commit message
Last commit date
May 16, 2024
Jun 29, 2024
Apr 30, 2020
Apr 24, 2020
Oct 8, 2024
May 12, 2024
May 1, 2020
Mar 9, 2019
Jun 29, 2024
Oct 8, 2024
Feb 22, 2018
May 16, 2024
Mar 27, 2024
Feb 22, 2018
Jul 17, 2024
May 16, 2024
Feb 22, 2018
Apr 3, 2020
Jun 29, 2024
Jan 20, 2019
Jan 27, 2019
May 12, 2024
Mar 9, 2019
May 13, 2024
Oct 8, 2024

Repository files navigation

NFK Web Statistics

Description

Match statistics site. Works on PHP 5-7.
Runs in a single Docker container since it's not actively maintained and required PHP versions are considered deprecated and hard to install on modern GNU/Linux distributions.
Docker image is based on Alpine Linux, with nginx+php-fpm running under supervisord. Latest PHP 7 version is compiled with all necessary dependencies. Dockerfile was written with one particulal server configuration in mind, meaning it still requires an external database and (preferably) a reverse-proxy.
The suggested configuration below is more of an example, some adaptations are probably required (PRs are welcome).

Installation

  1. Clone this repository
git clone https://github.com/NeedForKillTheGame/nfk-stats
  1. Build the docker image
cd nfk-stats
docker build [ --build-arg="OPTION=value" ] -t local/nfkstats .

Available build options:
THREADS — Number of CPU threads used for compiling (Default: 1).
TESTS_ENABLE — Run build tests after compiling (Default: 0).
UID — UID to match owner of the static files on the host system (Default: 200).

Building example on 16-core CPU (with multithreading enabled):

docker build --build-arg="THREADS=32" -t local/nfkstats .

Usage

  1. Create the config file using inc/config.inc.php.example:
mkdir -p /srv/nfkstats
cp inc/config.inc.php.example /srv/nfkstats/config.inc.php
vim /srv/nfkstats/config.inc.php
  1. Create directories for static files (or restore it from the backup) on a host system:
mkdir /srv/nfkstats/demos
mkdir -p /srv/nfkstats/images/maps
  1. Add a new user with desired UID to avoid permission issues and make him the owner of the directories:
useradd -u 200 -g www-data nfkstats
chown -R nfkstats:www-data /srv/nfkstats
  1. Run the container:
docker run -d --rm --restart=always\
  --name=nfkstats \
  --network=host \
  --volume /srv/nfkstats/config.inc.php:/var/www/inc/config.inc.php:ro \
  --volume /srv/nfkstats/demos:/var/www/demos:rw \
  --volume /srv/nfkstats/images/maps:/var/www/images/maps:rw \
  --env OPTION=value \
  --memory=256M \
  local/nfkstats

Statistics site should be available via port :80.
The available options are:
PORT — Nginx HTTP port (Default: 80).
REAL_IP — IP for nginx set_real_ip_from directive (Default: disabled).

Additional information

Nginx as a reverse proxy

Check the example configuration. It's recommended to protect /nfkstats.php URL with IP whitelisting and /do/new_seasonJGA with Basic Auth as it's mentioned.