Skip to content

Commit

Permalink
chore: update deployment files and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
suprovsky committed Oct 16, 2023
1 parent 3fbbd71 commit cf4ae4b
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 11 deletions.
29 changes: 26 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
# possible options: production, development, test
# leave it on production unless you know what you're doing
REDIS_ENV=production
# set LOG_LISTENER_ADDRESS as your IPv4/FQDN address instead of 0.0.0.0
# this IPv4 address is being set as an address where a game server is
# supposed to send its logs for parsing
LOG_LISTENER_ADDRESS=0.0.0.0
# defines port for lostening game server logs
LOG_LISTENER_PORT=20001
# idk what it does but I made it configurable anyway
WEBSOCKET_PORT=9001
# username required in HTTP Basic authentication
# you pass this with the password in order to enter the site
HTTP_USERNAME=vtvonly
# the password in question
HTTP_PASSWORD=hahasupersecretfunnypassword
# defines a listen port for the web service
PUBLIC_PORT=3020
WORKERS_AMOUNT=4
DB_ROOT_PASSWORD=anotherdbrootpassword
# root password for the MariaDB/MySQL database
MARIADB_ROOT_PASSWORD=supersecretrootpassword
# database address
DB_ADDRESS=db
# database name used by the app
DB_NAME=live_log_development
# database user used by the app
DB_USERNAME=tf2livestats
# database user's password used by the app
DB_PASSWORD=anothersuperfunnypassword
MARIADB_ROOT_PASSWORD=supersecretrootpassword
# secret token for cookies, changing it invalidates all cookies
# make sure it's long and randomized
SECRET_TOKEN=hahaanothersuperlongandsuperfunnypasswordwhichisverylongtrustme
# idk what it does but also make sure it's long and randomized
COOKIE_STORE=_tf2_live_stats_session
# redis address used by the app
REDIS_ADDRESS=redis
# redis port used by the app, if you change it here make sure
# you also set a custom port for it in docker-compose.yml
REDIS_PORT=6379
# memcached address used by the app
MEMCACHED_ADDRESS=memcached
# memcached port used by the app, if you change it here make sure
# you also set a custom port for it in docker-compose.yml
MEMCACHED_PORT=11211
56 changes: 49 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,58 @@

Please read this readme and the license carefully before contacting me about this project, thanks :heart:

This project is a POC that grew out of control and should've been rewritten ages ago.
This project is a POC that grew out of control and should've been rewritten ages ago, however some people wanted to pull this corpse out of the closet, so here we are, running in Docker!

## Requirements
* Ruby 1.9+
## Project components
* The main app, based on Ruby 2.4.9
* Memcached
* Database
* Experience running Ruby/Rails apps
* MySQL/MariaDB database
* Redis

## Installation
Assuming you have experience with running Rails apps, you'll know what to do. The web part of TF2 Live Stats should run in any ruby app server or passenger.
Use `docker-compose.yml` in the root of this repository. Make sure you have a modern version of Docker installed and you make your own `.env` file (use `.env.example` for reference). With these two files do `docker compose up -d` and all components should set up and start its operation. Assuming you care about security, you should set up some reverse proxy in front of the web service (UDP listener is being exposed directly).

Here is a configuration example for Nginx (assuming you use a default port for the web service):

```nginx
server {
listen 80;
listen [::]:80;
server_name example.com;
return 302 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
access_log /var/log/nginx/tf2livestats-access.log;
error_log /var/log/nginx/tf2livestats-error.log;
#HSTS, optional
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
#OCSP stapling, optional
ssl_stapling on;
ssl_stapling_verify on;
ssl_session_cache shared:ssl_session_cache:10m;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
location / {
proxy_pass http://localhost:3020;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
```

## Building

The build process is long, because instead of using a ready Ruby image (based on Debian 9) we build ruby on Debian 11 before the actual app.

```docker
docker buildx build . -t ghcr.io/Arie/tf2_live_stats
```

## Basic overview
TF2 Live Stats consists of 2 parts. The website that displays log events and a log listener daemon, that listens for incoming log lines on a UDP port, parses them and stores them in the database.
Expand All @@ -24,7 +66,7 @@ The website has 3 pages for live stats:


## Adding a match
Open /matches/new. If you enter both ip:port and rcon, the tool will configure the server for you. Don't forget to find and replace 'fakkelbrigade.eu:20001', with your own stuff.
Open /matches/new. If you enter both ip:port and rcon, the tool will configure the server for you.
If you don't have rcon you'll need someone else to run the command for you. In that case, leave everything blank and hit save, on the next page you'll get an rcon command to copy to someone who will run it for you.

The logsecret is used for servers that already use the logaddress mechanism for other purposes. For example, serveme.tf. You'll need to get the logsecret from the server using 'rcon sv_logsecret' and use that when creating your match on TF2 Live Stats.
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.8'

services:
app:
image: ghcr.io/suprovsky/tf2_live_stats:latest
image: ghcr.io/Arie/tf2_live_stats:latest
restart: always
depends_on:
- db
Expand Down

0 comments on commit cf4ae4b

Please sign in to comment.