Nakama Server Runtime Typescript

having similar issue with this Nakama/Docker Path Issues, although im not quite sure whats the directory looks like, mine is like this:

basically im getting this error when running docker compose up:

{"level":"fatal","ts":"2023-07-19T01:55:05.678Z","caller":"server/config.go:306","msg":"JavaScript entrypoint must be a valid path","error":"stat data/modules/build/index.js: no such file or directory"}

.
├── build/
├── data/
│   ├── modules/
│   └── .cookie [RO]
│   └── logfile.log
│   └── my-config.yml
├── node_modules/
│   ├── nakama-runtime/
│   └── typescript/
├── docker-compose.yml
├── Dockerfile
├── package-lock.json
├── package.json
├── src/
└── tsconfig.json

my-config.yml

name: nakama-node-1
data_dir: "./data"

logger:
    stdout: true
    level: "warn"
    file: "/nakama/data/logfile.log"

runtime:
  js_entrypoint: "build/index.js"

console:
    port: 7351
    username: "root"
    password: "password"

Dockerfile

FROM node:alpine AS node-builder

WORKDIR /backend

COPY package*.json ./
RUN npm install

COPY tsconfig.json ./
COPY src/*.ts ./
RUN npx tsc

FROM heroiclabs/nakama:3.16.0

COPY --from=node-builder /backend/build/*.js /nakama/data/modules/build/
COPY my-config.yml /nakama/data/

docker-compose.yml

version: '3'
services:
  postgres:
    command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all
    container_name: postgres
    image: postgres:12.2-alpine
    environment:
      - POSTGRES_DB=nakama
      - POSTGRES_PASSWORD=localdb
    volumes:
      - data:/var/lib/postgresql/data
    expose:
      - "8080"
      - "5432"
    ports:
      - "5432:5432"
      - "8080:8080"
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "postgres", "-d", "nakama"]
      interval: 3s
      timeout: 3s
      retries: 5

  nakama:
    build: .
    container_name: nakama
    image: registry.heroiclabs.com/heroiclabs/nakama:3.16.0
    entrypoint:
      - "/bin/sh"
      - "-ecx"
      - >
          /nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama &&
          exec /nakama/nakama --name nakama1 --config /nakama/data/my-config.yml --database.address postgres:localdb@postgres:5432/nakama --logger.level DEBUG --session.token_expiry_sec 7200
    links:
      - "postgres:db"
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
      - ./data:/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
    restart: unless-stopped
volumes:
  data:

Long story short, the problem is that you mount the data folder from your PC with the docker one, which overwrites everything.

In order to make it work, you’ll have to delete these lines from docker-compose.yml :

But to fix the docker compose up --build command, you’ll have to change this line in Dockerfile as well :

to:

COPY src ./src

As I can see, @khamarr3524 in Nakama/Docker Path Issues have the same problem.

1 Like

sweet that did it, thanks a lot @yurisq . one thing I changed is the Dockerfile with line: COPY my-config.yml /nakama/data/ to COPY /data/my-config.yml

side note, if somebody is also having this issue and still couldnt get it working, stop docker service, delete your .docker directory and restart it, after that run docker compose up --build

docker compose up --build should suffice I think, unless there was some other issue.

If you really want to delete all associated containers and volumes you can run:
docker compose down -v (this will delete all the database container data)

1 Like