The Nakama recommended in this issue is an open-source online multiplayer gaming framework.
Nakama is an open-source online multiplayer game framework consisting of an extensible server framework and various client SDKs that can add powerful features to your game.
Customer concept: Connect to your Nakama server and use Nakama social and competitive features to build your game:
Server Framework: The most advanced game server that can be fully extended using Go, TypeScript/JavaScript, and Lua to create server authoritative game logic and advanced features, and better control permissions, storage engines, and direct database access when needed.
project Properties
- Users – Register/log in as new users through social networks, email, or device ID.
- Storage – Store user records, settings, and other objects in a collection.
- Social – Users can contact friends and join groups. Built in social graph to see how to connect users.
- Chat – one-on-one, group, and global chatting between users. Keep chat records for messages.
- Multiplayer – Real time or turn based active and passive multiplayer games.
- Leaderboards – dynamic, seasonal, gaining top members or members around users. There are as many as possible.
- Tournaments – Invite players to compete for prizes together. Connect many people together to create a league.
- Parts – Add team games to the game. Users can form teams and communicate with party members.
- Runtime code – Use custom logic extension servers written in Lua, TypeScript/JavaScript, or native Go code.
Quick start
Install Nakama using Docker Compose
- Install to the original environment
- Easy installation and operation of CockrachDB or PostgreSQL databases for Nakama
- Take snapshots, delete and reinstall Nakama without affecting your primary operating system
- No matter what your operating system is, you can enjoy a fast and simplified installation experience
Run Nakama
Firstly, create a directory where your Nakama server is located, such as Desktop/Nakama
Create a docker-compose.yml file in this folder and open it using your favorite text editor.
Heroic Labs provides two YML files for use: using CockroachDB or PostgreSQL as the database.
docker-compose.yml:
version: '3'
services:
cockroachdb:
image: cockroachdb/cockroach:latest-v20.2
command: start-single-node --insecure --store=attrs=ssd,path=/var/lib/cockroach/
restart: "no"
volumes:
- data:/var/lib/cockroach
expose:
- "8080"
- "26257"
ports:
- "26257:26257"
- "8080:8080"
nakama:
image: heroiclabs/nakama:3.9.0
entrypoint:
- "/bin/sh"
- "-ecx"
- >
/nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
exec /nakama/nakama --name nakama1 --database.address root@cockroachdb:26257 --logger.level DEBUG --session.token_expiry_sec 7200 --metrics.prometheus_port 9100
restart: "no"
links:
- "cockroachdb:db"
depends_on:
- cockroachdb
- prometheus
volumes:
- ./:/nakama/data
expose:
- "7349"
- "7350"
- "7351"
- "9100"
ports:
- "7349:7349"
- "7350:7350"
- "7351:7351"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7350/"]
interval: 10s
timeout: 5s
retries: 5
prometheus:
image: prom/prometheus
entrypoint: /bin/sh -c
command: |
'sh -s <<EOF
cat > ./prometheus.yml <<EON
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
- job_name: nakama
metrics_path: /
static_configs:
- targets: ['nakama:9100']
EON
prometheus --config.file=./prometheus.yml
EOF'
ports:
- '9090:9090'
volumes:
data:
docker-compose-postgres.yml:
version: '3'
services:
postgres:
container_name: postgres
image: postgres:9.6-alpine
environment:
- POSTGRES_DB=nakama
- POSTGRES_PASSWORD=localdb
volumes:
- data:/var/lib/postgresql/data
expose:
- "8080"
- "5432"
ports:
- "5432:5432"
- "8080:8080"
nakama:
container_name: nakama
image: heroiclabs/nakama:3.9.0
entrypoint:
- "/bin/sh"
- "-ecx"
- >
/nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama &&
exec /nakama/nakama --name nakama1 --database.address postgres:localdb@postgres:5432/nakama --logger.level DEBUG --session.token_expiry_sec 7200
restart: always
links:
- "postgres:db"
depends_on:
- postgres
volumes:
- ./:/nakama/data
expose:
- "7349"
- "7350"
- "7351"
ports:
- "7349:7349"
- "7350:7350"
- "7351:7351"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7350/"]
interval: 10s
timeout: 5s
retries: 5
volumes:
data:
Copy and paste the content of the preferred options into the docker-compose.yml file.
Open a terminal window and navigate to your Nakama directory. For example:
cd desktop/nakama
To extract all necessary images and launch your application, run the following command:
docker compose up
Congratulations! Your Nakama server is now up and running, available at 127.0.0.1:7350
Middle console
You can also access the Nakama console by navigating your browser to 127.0.0.1:7351:
configuration file
You can customize many available configuration options for Nakama servers. You can create a YML file for all the configurations you want to set up and pass it to your Docker container.
Firstly, you need to provide a local storage volume for Docker:
1 docker-compose.yml Open your file in your favorite text editor.
Edit Nakama: volumes: entry to specify the desired volume. For example, to create a folder for/data in the directory we use on desktop/nakama, which can be used in Docker containers with nakama/data, it is as follows:
volumes:
– ./ data:/nakama/data
Save the modified file and restart the Docker container for the changes to take effect. From your terminal:
docker compose restart
Next, create your custom configuration file, such as my-config.yml, and place it in the folder you provided for Docker on/data.
my-config.yml:
name: nakama-node-1
data_dir: "./data/"
logger:
stdout: false
level: "warn"
file: "/nakama/data/logfile.log"
console:
port: 7351
username: "my_user"
password: "my_password"
Open your docker-compose.yml file again, and this time edit the nakama: entrypoint entry to add the — config flag pointing to your configuration file. It should be as follows:
nakama:
entrypoint:
- "/bin/sh"
- "-ecx"
- >
/nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
/nakama/nakama --config /nakama/data/my-config.yml
Save the changed file and restart the Docker container for the changes to take effect. From your terminal:
docker compose restart
Project Preview
Status:
The status page provides a real-time view of the Nakama server, including usage details for each node and a general view of bandwidth and latency, including:
- Delay: The time, in milliseconds (ms), taken to execute a remote procedure call (RPC) function
- Rate: RPC count per second
- Input: Inbound traffic in kilobytes per second (kb/s)
- Output: Outbound traffic in kilobytes per second (kb/s)
User management:
The user management page allows you to add new console users or delete any existing users. When creating a new user, there are four available roles that allow you to set up a support team that can only access the UI features they need.
Runtime modules:
The runtime module page allows you to easily observe which functions in the project are active and when they were last modified.
Accounts:
The Accounts page displays a list of all user accounts, which can be searched based on user ID and username. From here, you can view, edit, and delete any user.
Leaderboards:
The leaderboard page allows you to view and manage your leaderboards and tournaments, as well as their corresponding records.
—END—
Open source license: Apache-2.0 License