Skip to content

osboo/masonsmafia

Repository files navigation

Build Status

Server installation

  1. sudo apt-get install git
  2. cd Checkout directory
  3. Install MySQL sudo apt-get install mysql-server
  4. Install Workbench
  5. curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
  6. sudo apt-get install -y nodejs
  7. npm install
  8. npm run build
  9. export MYSQL_HOST=localhost && node src/server/init.js (For first initialization)

Run server application:

export MYSQL_HOST=localhost && npm start

For mocha test run:

  1. MASONS_ENV=TEST
  2. Create masons_test schema and user in accordane with conf (it is easier via MySQL Workbench)
  3. user interface=bdd
  4. test directory=Checkout directory/tests

Running server container

First, run database container.

Run the database container

docker network create mynet
docker run -d -p 3306:3306 \
--env "MYSQL_ROOT_PASSWORD=<PASSWORD>" \
--env "MYSQL_HOST=<CONTAINER NAME>" \
--name <CONTAINER NAME> \
--volume <LOCAL PATH>:/var/lib/mysql \
--net mynet \
osboo/masonsmafia-db

Initialization of database

If <LOCAL PATH> contains data then the container works with it. If there is a need in first database initialization (fresh install or running in testing envrironment) then following command should be executed:

docker exec -it <DB CONTAINER NAME> node src/server/init.js

Initialization for tests

Before each Mocha tests run the database should be initialized. Please also note that the container volume should be stateless so it must be cleaned after each test run. Command to inititialize the database in test env:

docker exec -it -e MASONS_ENV=TEST <DB CONTAINER NAME> node src/server/init.js

Running the app

Then run container in user defined network (mynet in this example):

docker run -p 3000:3000 \
--name <APP CONTAINER NAME> \
--env "MYSQL_HOST=<DB CONTAINER NAME>" \
--net mynet \
osboo/masonsmafia-app

Run via docker-compose

Create docker-compose.yml file with following:

version: '3'

services:
  db:
    image: osboo/masonsmafia-db
    container_name: <DB CONTAINER NAME>
    volumes:
      - <LOCAL PATH>:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: <PASSWORD>
      MYSQL_HOST: db

  app:
    depends_on:
      - db
    image: osboo/masonsmafia-app
    container_name: <APP CONTAINER NAME>
    ports:
      - "3000:3000"
    environment:
      MYSQL_HOST: db

Then run:

docker-compose up

Before the first run the database should be initialized by app-required schema and user settings. Aliases <DB CONTAINER NAME> and <APP CONTAINER NAME> will define the name of containers to apply initialization command (by default docker creates containers with random unpredictable names).

Run Mocha tests via docker

Make docker-compose.test.yml with following configuration:

version: '3'

services:
  db:
    image: osboo/masonsmafia-db
    container_name: testdb
    volumes:
      - <TEMPORARY LOCAL STORAGE>:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: mypassword
      MYSQL_HOST: db

  app:
    depends_on:
      - db
    image: osboo/masonsmafia-app
    container_name: testapp
    ports:
      - "3000:3000"
    environment:
      MYSQL_HOST: db
      MASONS_ENV: TEST

Then spin up containers:

docker-compose -f docker-compose.test.yml up -d

Then initialize the fresh local store see above.

And restart containers again (first run is unsuccessfull as database it not initialized):

docker-compose -f docker-compose.test.yml restart
  • For unit-tests call: docker exec -it testapp ./node_modules/mocha/bin/mocha -u bdd ./tests/unit-tests
  • For integration tests (db): docker exec -it testapp ./node_modules/mocha/bin/mocha -u bdd ./tests/dbtest
  • For integration tests (add new games): docker exec -it testapp ./node_modules/mocha/bin/mocha -u bdd ./tests/personal_statistics_test

About

Masons mafia club statistic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors