A multiplayer app crafted with Haskell and React
Get everything running with Docker
In order to use Docker have the following installed.
Firstly start Docker Machine
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.
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.
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-22.214.171.124 using: /root/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_126.96.36.199_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux/Cabal-188.8.131.52 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
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.
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.
Compile the back end poker server.
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=pokerdbtest password=tom
Set env variable with the secret key for generating auth tokens. Note that this secret must be 32 characters long or it won't work.
Lastly ensure redis-server is running in the background on default port
Now run the server locally. The default user API port is 8000 and websocket port is 5000.
Install node version 10.16.3 and then install yarn globally
npm i -g email@example.com
Install a required system dependency for node-sass .
sudo apt-get install libpng-dev
Navigate to the client/ directory with
Then just run.
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
To run the test suite on the backend which has over a hundred tests
cd server && stack test
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.
This is free and unencumbered software released into the public domain.
For more information, please refer to the
UNLICENSE file or unlicense.org.