A 2D multiplayer game with a dynamic lobby system. Lobbies are created on demand and dynamically spun up as new instances behind a Traefik reverse proxy. This architecture showcases core concepts of distributed systems and was built with scalability and modularity in mind.
- Push to the
main
branch- A GitHub Action will build the package and instruct the web server to run the container
- Access the app at: https://distr-sys-io.ivo-zilkenat.de/
Make sure you have the following installed:
docker
ansible
python3-dotenv-cli
git
(pre-installed on most Linux distributions)make
(pre-installed on most Linux distributions)
- Clone the project.
- Configure environment variables:
cp local.env ./deployment/.env
(Set values likeDOMAIN
, etc.) - Change into the deployment directory:
cd ./deployment
- Join a Docker Swarm cluster:
- If no cluster is present, initialize one and use the current machine as the master node:
docker swarm init --advertise-addr 127.0.0.1
- If no cluster is present, initialize one and use the current machine as the master node:
Deploy using local containers (e.g. for testing code changes in game_server
or app_matchmaking_host
):
- Ensure image and domain variables are set in
deployment/.env
based onlocalhost.env
- Run:
make deploy-local
Deploy:
make deploy
Undeploy:
make rm-all
Scale (e.g. add a new lobby instance):
make lobby_id=your_name_here add-lobby
Run the Database:
cd services/database
docker compose up
Run the Matchmaking Server:
cd services/app_matchmaking_host
source backend/venv/bin/activate # Adjust path if necessary
python main.py
Run a Game Server:
cd services/game_server
source venv/bin/activate # Adjust path if necessary
Optional environment variables:
DEPEND_ON_MATCHMAKING=0
– Start without matchmaking dependencyHOST=localhost
– Host address (default:0.0.0.0
)PORT=3001
– Port numberSERVER_NAME=Unbekannt
– Lobby nameSERVER_URL=http://{HOST}:{PORT}
– Lobby URLSERVER_ID
andSERVER_TOKEN
– Credentials for reconnecting to matchmaking (optional)CREDENTIALS_FILE=DATA_DIR/credentials.json
– Where credentials are saved
Start the server:
python main.py