I’m trying to centralize calls from my game in nakama modules. I have been looking at the documentation and the video tutorial that they have on the web. And I’m having problems. I can launch docker compose up just fine and can access the control panel. The problem is that I can’t get the modules to appear. I have seen the documentation, I have followed the tutorial, and I have even downloaded the project that they have on github Project template nakama But there is no way to see the healthcheck in the explorer api calls. I don’t know if this has happened to anyone else. Possibly I have something misconfigured but I would say no. I have to say that I am using the cockroach database, although I don’t think that is the problem. This is my 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”
healthcheck:
test: [“CMD”, “curl”, “-f”, “http://localhost:8080/health?ready=1”]
interval: 3s
timeout: 3s
retries: 5
nakama:
image: registry.heroiclabs.com/heroiclabs/nakama:3.15.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:
condition: service_healthy
prometheus:
condition: service_started
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 < ./prometheus.yml <<EON
global:
scrape_interval: 15s
evaluation_interval: 15s
Do I understand correctly, that you have a problem that nakama doesn’t load your game logic modules?
do you have modules directory next to docker compose file ? If so, could you provide nakama container logs
@sergisnt what type of runtime module are you trying to load - Go, Lua or TS? If you’re using the latter, are you placing the bundled JS in the local modules folder where you have the Nakama source? The docker-compose you shared is really only meant to run Nakama with the modules present in its source code.
@sesposito My idea was to use TS types. Although I have tried projects that had Go and Lua modules and the methods do not appear either. I have used the project that you have provided. HERE and still still does not appear the modules. I have only modified the Docker Compose to use the Cockroach database. But the rest is identical. With the Index.js in the Build folder and still do not appear the methods of Daily_reward and others.
As you can see, in the project there is the daily_reward file both in TS and in GO and Lua. And it doesn’t appear in the nakama panel.
There are no modules in execution time or the methods in the API Explorer. And I have cloned the project and I have segated the steps that appear below the NPM Install and NPX TSC. I have followed the 3 tutorials they have on the web. That of Daily Reward and another more basic. What can be happening?
@sergisnt I just did docker compose up on the project template and it correctly loaded the modules, although I did not do any changes to the Docker/docker-compose.yml files in the repository, unless there’s some Windows issue I’m not aware of I don’t know why you wouldn’t see the modules being loaded too.
It also seems strange to me that I can’t see the modules or the methods created in the nakama control panel. I have followed the tutorials correctly. I have tried to disable the W10 firewall in case it had any influence but nothing. This leads me to ask myself some questions.
Is it possible that where the project is located is the problem?
Is there somewhere where the route that refers to the modules could have been configured wrong?
I have new information. I just tried on another machine and I have seen with the project from the GitHub repository if it works. BUT IT ONLY WORKS WITH POSTGRES. The problem is that when I use the cockroach docker compose that they have on their website, the default does not load the modules or the methods.
I wanted to use cockroach, and the docker compose of cockroach works on neither of the two machines, that is, it works, but it doesn’t load the modules.
Like I explained above, you cannot use the example cockroachdb docker-compose because it is not prepared to load your local modules, you need to change the one in the project template to use the cockroach db container image instead and pass the correct db configs for Nakama to connect to it.
Just to add to what @sesposito is saying here, specifically the issue is that the “CockroachDB” Docker Compose file you are referring to runs Nakama directly from the registry.heroiclabs.com/heroiclabs/nakama:3.15.0 image. This image is not configured to load any modules from your local machine and will therefore run a vanilla Nakama server.
The Docker Compose file in the nakama-project-template repo is configured to run Nakama by building it’s own image using the provided Dockerfile. As you can see, this Dockerfile is specifically made to copy across the local module files into the Nakama container (lines 14-17).
Sorry for the delay in your response, I was away for a while. I think I now understand better how it works. So what solution do you recommend? I use the oldest version, the 3.9 that they have in the template. Or is there a way that DockerCompose version 15 can accept modules locally?
That is, I use the “docker compose up” command to launch my ‘Nakama Server’. I tried to use this project by replacing the docker-compose.yml with the one from version 15 but it doesn’t load the modules either. What would be the solution to use version 15 and generate the modules? or is it not possible for now?
Yes, my idea was to use typescript since I am more familiar with it. Now I have a question, I wanted to use the docker 3.15 image. because it is more updated than version 9. But it is not prepared to load the modules at runtime as @tom said. Is there no way to have the most updated version and have the option to load the modules? Is there any important difference between version 15 and 9? Like security for example.
I see that you want to use Cockroach instead of Postgres which seems to be the main issue here. This is just a case of replacing the postgres block in the docker-compose.yml file with an appropriate cockroach block (see the configuration here for example) and updating the database connection details in the entrypoint block for the nakama service.
@sesposito@sergisnt
Hi, i’m late to the thread but i ran across the same problem. I’m citing you all because i found other threads in the forum with the same issue and i found out what causes it and how to work around it. I’m replying directly to tom’s post because the “bug” is related to the Dockerfile and docker-compose in fact. Specifically with what he described in the post:
The dockerfile is prepared to build and then copy the modules to the docker image before building it. This means that when you add the line:
“volume: ./data:/nakama/data”
To the nakama section of the docker-compose.yml to mount your data folder with your custom config file, all modules copied to the docker image’s data folder during the building step get removed, as the whole folder gets replaced.
The 2 possible solutions or workarounds i have found are these:
Copy the built modules to a temporary folder in the docker image, then move them to the /nakama/data folder after launching the container (in the entrypoint section of the docker-compose)
Remove the “volume: ./data:/nakama/data” line inside the docker-compose.yml, delete the local “data” folder and copy the cofig file (local.yml) to the main folder instead. Since the default dockerfile already copies all the contents of the main folder and then tries to copy a “local.yml” file to the container image, the config file should still be loaded correctly. This solution is simple but you wont be able to mount a data folder to the container.