Skip to content
🂺 Poker - A Multiplayer App Crafted with Haskell and React
Haskell JavaScript CSS Shell HTML Dockerfile Nix
Branch: master
Clone or download
Pull request Compare This branch is 288 commits ahead, 108 commits behind ConsenSys:master.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
client Wider Navbar Items Nov 25, 2019
server Use Special Yarn Command for Docker Nov 23, 2019
README.md Update Link Nov 25, 2019
docker-compose.yml Use Special Yarn Command for Docker Nov 23, 2019

README.md

alt text

A multiplayer app crafted with Haskell and React

Netlify Status License: Unlicense

alt text

Play now

Get everything running with Docker

Prerequisites

In order to use Docker have the following installed.

Firstly start Docker Machine

docker-machine start

Then set the correct variables in your terminal so you can connect to Docker Machine

eval $(docker-machine env)

Now build the images. This will take a while.

docker-compose up

Now go navigate to http://192.168.99.100:3000 in your browser and the app should be running.

The above ip address is the one for your docker-machine VM if you are on the default settings. By default docker-machine doesn't serve localhost but instead uses 192.168.99.100 as the host.

You can simulate multiple players in the same game on on your machine if you navigate to the above url in a few different browser tabs. Eac time you open up a new tab just remember to log out after you have signed in as the browser will cache the access_token for the last logged in user for each new tab as URL is the same.

Common Docker Problems

Docker has the wrong TLS setting

If you get the error below then Docker Compose is not using the correct TLS version.

Building web
ERROR: SSL error: HTTPSConnectionPool(host='192.168.99.100', port=2376): Max retries exceeded with url: /v1.30/build?q=False&pull=False&t=server_web&nocache=False&forcerm=False&rm=True (Caused by SSLError(SSLError(1, u'[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:727)'),))

You can fix this by setting the following environment variable with the correct TLS version.

export COMPOSE_TLS_VERSION=TLSv1_2

Container runs out of memory

If the server docker container runs out of memory whilst building. Whis would look like this.

--  While building package Cabal-2.4.1.0 using:
      /root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.4.0.1 build --ghc-options ""
    Process exited with code: ExitFailure (-9) (THIS MAY INDICATE OUT OF MEMORY)

Then set increase the memory available to the VM you are using for docker-machine. Assuming your VM is named "default", run:

docker-machine stop default
VBoxManage modifyvm default --memory 4096
docker-machine start default

Slow builds

If you want to speed up builds then replace n in the command below with the number of cores your machine has and run the command. The command below assumes that "default" is the name of the VM Docker Machine is using.

docker-machine stop default
VBoxManage modifyvm default --cpus n
docker-machine start default

Building locally from scratch.

The following steps are based on an Ubuntu distribution.

Back End

Firstly make sure you have ghc and stack installed in order to compile the back end written in Haskell. If you need to install the Haskell platform then run

curl -sSL https://get.haskellstack.org/ | sh

Secondly install libpq (c bindings to postgres)

sudo apt-get install libpq-dev

Next install redis.

sudo apt-get install redis

Navigate to the server/ directory.

cd server

Compile the back end poker server.

stack build

Now we need to set some config.

Ensure postgresql 10 is installed and running.

Set the env var so that the server has the postgresql connection string. Of course you will need to change the db connection parameters below to match your local database.

export dbConnStr='host=0.0.0.0 port=5432 user=tom dbname=defaultdb password=pass'

Set env variable with the secret key for generating auth tokens.

export secret="your-super-secret"

Lastly ensure redis-server is running in the background on default port

redis-server

Now run the server locally. The default user API port is 8000 and websocket port is 5000.

stack run

Front End

Install node version 10.16.3 and then install yarn globally

npm i -g yarn@1.17.3

Install a required system dependency for node-sass .

sudo apt-get install libpng-dev

Navigate to the client/ directory with

cd client

Then just run.

yarn start

Now you are ready to play poker!

Simulating a multiplayer game locally

You may want to play against yourself when you are developing locally so just run the clients on two separate ports.

In your first terminal run

PORT=8001 yarn start

Then open another terminal and run

PORT=8002 yarn start

Now just open two tabs in your browser navigating to

localhost:8001

and

localhost:8002

Running Tests

To run the test suite on the backend which has over a hundred tests

cd server && stack test

Contributions Welcome

Have a look at the issues if you want some starting ideas on how to get involved.

Feel free to open any issues with potential enhancements or bugs you have found.

License

This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.

You can’t perform that action at this time.