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

Enhancement: Mount config.php as read-only #8

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,30 @@ The new BF2Statistics 3.0 ASP, currently in public Beta. The GameSpy server to m

See [docker-compose.example.yml](docker-compose.example.yml) example showing how to deploy BF2Statistics using `docker-compose`.

Notes:
- Mount the [`config.php`](./config/ASP/config.php) as read-only for the `php` service so that `ASP` doesn't mutate the config file. The `ASP`'s `System > Edit Configuration` should no longer be used, since we are managing the configuration file. `System > System Tests` will fail for `config.php` since `ASP` expects the file to be writeable, but this may be ignored.
- Seed the `db` service with `schema.sql` and `data.sql` so that the database is populated on the first run. The `ASP`'s `System > System Installation` doesn't need to be used.
- Optional: For better security, define `MARIADB_USER` and `MARIADB_PASSWORD` for the `db` service, so that a regular `mariadb` user is created on the first run, instead of using the `root` user. Note that this hasn't been tested, and might break some modules in the `ASP` dashboard.

## Development

Requires `docker` and `docker-compose`.

```sh
# Start
docker-compose up --build
# Dashboard now available at http://localhost/ASP, username: admin, password admin. See ./src/ASP/system/config/config.php configuration file
# phpmyadmin available at http://localhost:8080. Username: root, password: ascent. See ./src/ASP/system/config/config.php configuration file
# Dashboard now available at http://localhost/ASP, username: admin, password admin. See ./config/ASP/config.php config file
# phpmyadmin available at http://localhost:8080. Username: root, password: ascent. See ./config/ASP/config.php config file

# Fix php xdebug not reaching host IDE
iptables -A INPUT -i br+ -j ACCEPT

# Test routes
docker-compose -f docker-compose.test.yml up

# Dump the DB
docker exec -it <db_container> mysqldump -uroot -pascent bf2stats | gzip > bf2stats.sql.gz

# Stop
docker-compose down

Expand Down
54 changes: 54 additions & 0 deletions config/ASP/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/***************************************
* Battlefield 2 Private Stats Config *
****************************************
* All comments have been removed from *
* this file. Please use the Web Admin *
* to change values. *
***************************************/
$admin_user = 'admin';
$admin_pass = 'admin';
$admin_hosts = array('0.0.0.0/0','192.1.0.1/32');
$admin_ignore_ai = 1;
$admin_last_login = 1619049094;
$admin_current_login = 1619062147;
$admin_timezone = 'America/Los_Angeles';
$debug_lvl = 4;
$db_host = 'db';
$db_port = 3306;
$db_user = 'root';
$db_pass = 'ascent';
$db_name = 'bf2stats';
$stats_strict_api = 0;
$stats_aspx_cache_time = 30;
$stats_risingstar_refresh = 1619049068;
$stats_smoc_refresh = 1618270660;
$stats_general_refresh = 1617845422;
$stats_ignore_ai = 0;
$stats_min_game_time = 0;
$stats_min_player_game_time = 0;
$stats_players_min = 1;
$stats_players_max = 256;
$stats_awds_complete = 0;
$stats_rank_complete = 0;
$stats_lan_override = '174.49.21.221';
$stats_save_snapshot = 1;
$stats_risingstar_interval = 7;
$stats_smoc_interval = 7;
$stats_smoc_last_select = 1618270691;
$stats_general_interval = 31;
$stats_general_last_select = 1618270681;
$stats_general_mode = 0;
$game_unlocks = 0;
$game_unlocks_bonus = 2;
$game_unlocks_bonus_min = 1;
$game_awds_ignore_time = 0;
$battlespy_enable = 1;
$battlespy_max_spm = 7;
$battlespy_max_kpm = 10;
$battlespy_max_target_kills = 10;
$battlespy_max_team_kills = 5;
$battlespy_max_awards = 0;
$battlespy_max_accuracy = 50;
$battlespy_weapons = array('0','2','3','4','5','7','8');
$battlespy_rank_check = 1;
15 changes: 8 additions & 7 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ services:
nginx:
image: leojonathanoh/asp:nginx
volumes:
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf:ro # Override if needed
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf:ro # Customize as needed
ports:
- 80:80
networks:
Expand All @@ -55,8 +55,8 @@ services:
php:
image: leojonathanoh/asp:php
volumes:
- ./config.php:/src/ASP/system/config/config.php # Override if needed
- ./config/php/conf.d/php.ini:/usr/local/etc/php/conf.d/php.ini:ro # Override if needed
- ./config/ASP/config.php:/src/ASP/system/config/config.php:ro # Customize as needed.
- ./config/php/conf.d/php.ini:/usr/local/etc/php/conf.d/php.ini:ro # Customize as needed
- backups-volume:/src/ASP/system/backups
- cache-volume:/src/ASP/system/cache
- logs-volume:/src/ASP/system/logs
Expand All @@ -71,12 +71,13 @@ services:
image: mariadb:10.8
environment:
- MARIADB_ROOT_PASSWORD=ascent
# - MARIADB_USER=unused
# - MARIADB_PASSWORD=unused
# - MARIADB_USER=myuser # Uncomment this if you want to create a regular user
# - MARIADB_PASSWORD=mypassword # Uncomment this if you want to create a regular user
- MARIADB_DATABASE=bf2stats
volumes:
- ./src/ASP/system/sql/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro # Seed the database on the first run. No need to use the dashboard installer.
- ./src/ASP/system/sql/data.sql:/docker-entrypoint-initdb.d/02-data.sql:ro # Seed the database on the first run. No need to use the dashboard installer.
# Seed the database on the first run. No need to use the ASP dashboard's installer. Note that the .sql file are executed in alphabetical order of their names.
- ./src/ASP/system/sql/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
- ./src/ASP/system/sql/data.sql:/docker-entrypoint-initdb.d/02-data.sql:ro
- db-volume:/var/lib/mysql
networks:
- default
Expand Down
10 changes: 6 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ services:
dockerfile: Dockerfile.php.dev
volumes:
- ./src:/src
- ./config/ASP/config.php:/src/ASP/system/config/config.php:ro
- ./config/php/conf.d/php.ini:/usr/local/etc/php/conf.d/php.ini:ro
- backups-volume:/src/ASP/system/backups
- cache-volume:/src/ASP/system/cache
Expand All @@ -79,12 +80,13 @@ services:
image: mariadb:10.8
environment:
- MARIADB_ROOT_PASSWORD=ascent
# - MARIADB_USER=unused
# - MARIADB_PASSWORD=unused
# - MARIADB_USER=myuser # Uncomment this if you want to create a regular user
# - MARIADB_PASSWORD=mypassword # Uncomment this if you want to create a regular user
- MARIADB_DATABASE=bf2stats
volumes:
- ./src/ASP/system/sql/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro # Seed the database on the first time. No need to use the dashboard installer.
- ./src/ASP/system/sql/data.sql:/docker-entrypoint-initdb.d/02-data.sql:ro # Seed the database on the first time. No need to use the dashboard installer.
# Seed the database on the first run. No need to use the ASP dashboard's installer. Note that the .sql file are executed in alphabetical order of their names.
- ./src/ASP/system/sql/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
- ./src/ASP/system/sql/data.sql:/docker-entrypoint-initdb.d/02-data.sql:ro
- db-volume:/var/lib/mysql
networks:
- default
Expand Down