An HTML5 application used to distribute scores and update league tables during the football tournaments held at STBGFC.
It includes a sockets based score update (and a 'videprinter' to ticker the score updates as they are received) giving a simulated real-time update for results and league tables. The web app can also display news and announcements broadcast by the organisers.
To work, it needs a companion backend API (the Tournament API ) and a mongo database to store the tournament data. Mongo can be run in docker or any valid
mongodb:// URI can be supplied to the API container, for example to a native local installation or a remote provider.
Pre-requisites are a Linux server of some sort with
docker-engine (1.10 or higher) and
docker-compose (1.7 or higher) installed.
Running with docker-compose
Create a directory on the docker server (
mkdir -p /opt/tournament-app/ssl && cd /opt/tournament-app) and then copy the following into a file named
docker-compose.yml in that directory.
# # Example docker-compose file - edit values as appropriate # version: '2' services: tournament-app: image: stbgfc/tournament-app ports: - "80:80" - "443:443" networks: - public volumes: - /opt/tournament-app/ssl:/etc/ssl/private environment: - SERVER_NAME=tournament.example.com tournament-api: image: stbgfc/tournament-api ports: - "3000:3000" networks: - public - data environment: - STBGFC_MONGO_URI=mongodb://192.168.21.100:27017/tournamentApp - JWT_SECRET_KEY - JWT_EXPIRES_IN_MINUTES=600 networks: public: driver: bridge data: driver: bridge
You need to change the values of the
SERVER_NAME and the
STBGFC_MONGO_URI env variables before saving the file. If you chose a different directory to
/opt/tournament-app then change the volume mapping where that is referenced too.
If you want a quick database to play with, you can create and populate a db named
tournamentApp using the test script from the project like this;
curl https://raw.githubusercontent.com/STBGFC/tournament-app/master/scripts/testdb-seed.js | mongo tournamentApp
STBGFC_MONGO_URI would be
SSL and Secret Keys
Before running the app, you must create or obtain a valid SSL certificate and private key (plenty of examples on the web of creating self-signed certs for development and testing). Place them in the
ssl directory which should be at the same level as your
docker-compose.yml file. The files MUST be named
tournament-app.key respectively. Rename them appropriately. You also need to provide a Diffie Hellman parameter file to ensure your SSL key exchange is safe (hey, you can't be too careful out there!). Run
openssl dhparam -rand -- 4096 > ssl/dh4096.pem. It will take forever. Now
chmod -R 600 ssl/* and then your
ssl directory should look something like this now..
$ ls -al ssl total 48 drwx------ 2 darren darren 4096 Jun 14 21:14 . drwxrwxr-x 3 darren darren 4096 Jun 14 21:13 .. -rw------- 1 darren darren 769 Jun 13 21:01 dh4096.pem -rw------- 1 darren darren 4229 Jun 13 21:01 tournament-app.crt -rw------- 1 darren darren 1675 Jun 13 21:01 tournament-app.key
JWT_SECRET_KEY env var is left undefined in the compose file as ideally this should change each time you run it. You can generate a nice secure random one on each invocation by doing the following:
export JWT_SECRET_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1) docker-compose up
If everything worked after that last command, you should have a running app.
- docker env vars
- rebuilding with custom branding