Configuration File #

There are many configuration options available that you can customize for your Nakama server. You can create a YML file for all configurations you want to set, and pass that file to your Docker containers.

First you will need to make a local storage volume available to Docker:

  1. Open your docker-compose.yml file in your preferred text editor.
  2. Edit the nakama:volumes: entry to specify your desired volume. For example, to create a /data folder in our desktop/nakama directory used above, which would be available at nakama/data in your Docker container, it would look like the following:
1
2
volumes:
  - ./data:/nakama/data

This will map the local ./data directory to the /nakama/data path inside the Nakama container.

  1. Save the changed file and restart your Docker containers for the change to take effect. From your Terminal:
1
2
docker compose restart
docker compose up
  1. Next, create your custom configuration file, for example my-config.yml, and place it in the /data folder that you made available to Docker, above.

PostgreSQL #

my-config.yml

1
2
3
4
5
6
7
8
name: nakama1
database:
  address:
    - "postgres:localdb@postgres:5432/nakama"
logger:
  level: DEBUG
session:
  token_expiry_sec: 7200

CockroachDB #

my-config.yml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
name: nakama1
database:
  address:
    - "root@cockroachdb:26257"
logger:
  level: DEBUG
session:
  token_expiry_sec: 7200
metrics:
  prometheus_port: 9100
  1. Open your docker-compose.yml file again, this time to edit the nakama:entrypoint entry to add the --config flag pointing to your configuration file. It should look like this:
1
2
3
4
5
6
7
nakama:
    entrypoint:
    - "/bin/sh"
    - "-ecx"
    - >
        /nakama/nakama migrate up --database.address root@cockroachdb:26257 &&
        /nakama/nakama --config /nakama/data/my-config.yml        
  1. Save the changed file and restart your Docker containers for the change to take effect. From your Terminal:
1
2
docker compose restart
docker compose up