Nakama typescript using Docker loads main.go instead of main.ts

Hi,

I am using Nakama 3:20 with Typescript. Whenever I docker-compose up, the message I receive in terminal is about .go and not .ts

Here is my Dockerfile:

FROM node:alpine AS node-builder

WORKDIR /backend

COPY package*.json .
RUN npm install

COPY tsconfig.json .
COPY main.ts .
RUN npx tsc

FROM registry.heroiclabs.com/heroiclabs/nakama:3.20.0

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

and here is my docker-compose.yml

version: '3'
services:
  cockroachdb:
    image: cockroachdb/cockroach:latest-v23.1
    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.20.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", "/nakama/nakama", "healthcheck"]
      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:

Here is the output whenever I do compose-docker up:

PS D:\ParaNoya\Code\CasiNoya-Nakama-Server> docker-compose up
[+] Building 0.0s (0/0)                                                                                                                                                                                      docker:default
[+] Running 3/0
 ✔ Container casinoya-nakama-server-prometheus-1   Created                                                                                                                                                             0.0s 
 ✔ Container casinoya-nakama-server-cockroachdb-1  Created                                                                                                                                                             0.0s 
 ✔ Container casinoya-nakama-server-nakama-1       Created                                                                                                                                                             0.0s 
Attaching to casinoya-nakama-server-cockroachdb-1, casinoya-nakama-server-nakama-1, casinoya-nakama-server-prometheus-1
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.077Z caller=main.go:539 level=info msg="No time or size retention was set so using the default time retention" duration=15d
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.077Z caller=main.go:583 level=info msg="Starting Prometheus Server" mode=server version="(version=2.48.1, branch=HEAD, revision=63894216648f0d6be310c9d16fb48293c45c9310)"
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.077Z caller=main.go:588 level=info build_context="(go=go1.21.5, platform=linux/amd64, user=root@71f108ff5632, date=20231208-23:33:22, tags=netgo,builtinassets,stringlabels)"
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.077Z caller=main.go:589 level=info host_details="(Linux 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 b56a0f169f3a )"
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.077Z caller=main.go:590 level=info fd_limits="(soft=1048576, hard=1048576)"
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.077Z caller=main.go:591 level=info vm_limits="(soft=unlimited, hard=unlimited)"
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.078Z caller=web.go:566 level=info component=web msg="Start listening for connections" address=0.0.0.0:9090
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.079Z caller=main.go:1024 level=info msg="Starting TSDB ..."
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.079Z caller=dir_locker.go:77 level=warn component=tsdb msg="A lockfile from a previous execution already existed. It was replaced" file=/prometheus/data/lock
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.081Z caller=tls_config.go:274 level=info component=web msg="Listening on" address=[::]:9090
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.081Z caller=tls_config.go:277 level=info component=web msg="TLS is disabled." http2=false address=[::]:9090
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.083Z caller=head.go:601 level=info component=tsdb msg="Replaying on-disk memory mappable chunks if any"
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.083Z caller=head.go:682 level=info component=tsdb msg="On-disk memory mappable chunks replay completed" duration=1.302µs
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.083Z caller=head.go:690 level=info component=tsdb msg="Replaying WAL, this may take a while"
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.089Z caller=head.go:761 level=info component=tsdb msg="WAL segment loaded" segment=0 maxSegment=1
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.090Z caller=head.go:761 level=info component=tsdb msg="WAL segment loaded" segment=1 maxSegment=1
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.090Z caller=head.go:798 level=info component=tsdb msg="WAL replay completed" checkpoint_replay_duration=23.394µs wal_replay_duration=7.092407ms wbl_replay_duration=200ns total_replay_duration=7.130708ms
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.091Z caller=main.go:1045 level=info fs_type=EXT4_SUPER_MAGIC
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.091Z caller=main.go:1048 level=info msg="TSDB started"
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.091Z caller=main.go:1230 level=info msg="Loading configuration file" filename=./prometheus.yml
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.092Z caller=main.go:1267 level=info msg="Completed loading of configuration file" filename=./prometheus.yml totalDuration=470.098µs db_storage=1.202µs remote_storage=1.443µs web_handler=461ns query_engine=942ns scrape=176.619µs scrape_sd=49.342µs notify=911ns notify_sd=1.563µs rules=982ns tracing=74.249µs
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.092Z caller=main.go:1009 level=info msg="Server is ready to receive web requests."
casinoya-nakama-server-prometheus-1   | ts=2024-01-09T04:36:04.092Z caller=manager.go:1012 level=info component="rule manager" msg="Starting rule manager..."
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | * WARNING: ALL SECURITY CONTROLS HAVE BEEN DISABLED!
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | * This mode is intended for non-production testing only.
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | * In this mode:
casinoya-nakama-server-cockroachdb-1  | * - Your cluster is open to any client that can access any of your IP addresses.
casinoya-nakama-server-cockroachdb-1  | * - Intruders with access to your machine or network can observe client-server traffic.
casinoya-nakama-server-cockroachdb-1  | * - Intruders can log in without password and read or write any data in the cluster.
casinoya-nakama-server-cockroachdb-1  | * - Intruders can consume all your server's resources and cause unavailability.
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | * INFO: To start a secure server without mandating TLS for clients,
casinoya-nakama-server-cockroachdb-1  | * consider --accept-sql-without-tls instead. For other options, see:
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | * - https://go.crdb.dev/issue-v/53404/v23.1
casinoya-nakama-server-cockroachdb-1  | * - https://www.cockroachlabs.com/docs/v23.1/secure-a-cluster.html
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | * WARNING: Running a server without --sql-addr, with a combined RPC/SQL listener, is deprecated.
casinoya-nakama-server-cockroachdb-1  | * This feature will be removed in a later version of CockroachDB.
casinoya-nakama-server-cockroachdb-1  | *
casinoya-nakama-server-cockroachdb-1  | CockroachDB node starting at 2024-01-09 04:36:05.582897393 +0000 UTC m=+1.324382068 (took 1.1s)
casinoya-nakama-server-cockroachdb-1  | build:               CCL v23.1.13 @ 2023/12/01 21:38:31 (go1.19.13)
casinoya-nakama-server-cockroachdb-1  | webui:               http://127.0.0.1:8080
casinoya-nakama-server-cockroachdb-1  | sql:                 postgresql://root@127.0.0.1:26257/defaultdb?sslmode=disable
casinoya-nakama-server-cockroachdb-1  | sql (JDBC):          jdbc:postgresql://127.0.0.1:26257/defaultdb?sslmode=disable&user=root
casinoya-nakama-server-cockroachdb-1  | RPC client flags:    /cockroach/cockroach <client cmd> --host=127.0.0.1:26257 --insecure
casinoya-nakama-server-cockroachdb-1  | logs:                /var/lib/cockroach/logs
casinoya-nakama-server-cockroachdb-1  | temp dir:            /var/lib/cockroach/cockroach-temp491725272
casinoya-nakama-server-cockroachdb-1  | external I/O path:   /var/lib/cockroach/extern
casinoya-nakama-server-cockroachdb-1  | store[0]:            path=/var/lib/cockroach,attrs=ssd
casinoya-nakama-server-cockroachdb-1  | storage engine:      pebble
casinoya-nakama-server-cockroachdb-1  | clusterID:           7db41f9d-01c6-4c49-b317-1ab72e68d1f9
casinoya-nakama-server-cockroachdb-1  | status:              restarted pre-existing node
casinoya-nakama-server-cockroachdb-1  | nodeID:              1
casinoya-nakama-server-nakama-1       | + /nakama/nakama migrate up --database.address root@cockroachdb:26257
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.603Z","caller":"migrate/migrate.go:155","msg":"Database connection","dsn":"postgres://root@cockroachdb:26257/nakama?sslmode=prefer"}      
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.616Z","caller":"migrate/migrate.go:203","msg":"Database information","version":"CockroachDB CCL v23.1.13 (x86_64-pc-linux-gnu, built 2023/12/01 21:38:31, go1.19.13)"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.654Z","caller":"migrate/migrate.go:226","msg":"Successfully applied migration","count":0}
casinoya-nakama-server-nakama-1       | + exec /nakama/nakama --name nakama1 --database.address root@cockroachdb:26257 --logger.level DEBUG --session.token_expiry_sec 7200 --metrics.prometheus_port 9100
casinoya-nakama-server-nakama-1       | {"level":"warn","ts":"2024-01-09T04:36:07.666Z","caller":"server/config.go:321","msg":"WARNING: insecure default parameter value, change this for production!","param":"console.username"}
casinoya-nakama-server-nakama-1       | {"level":"warn","ts":"2024-01-09T04:36:07.666Z","caller":"server/config.go:325","msg":"WARNING: insecure default parameter value, change this for production!","param":"console.password"}
casinoya-nakama-server-nakama-1       | {"level":"warn","ts":"2024-01-09T04:36:07.666Z","caller":"server/config.go:329","msg":"WARNING: insecure default parameter value, change this for production!","param":"console.signing_key"}
casinoya-nakama-server-nakama-1       | {"level":"warn","ts":"2024-01-09T04:36:07.666Z","caller":"server/config.go:333","msg":"WARNING: insecure default parameter value, change this for production!","param":"socket.server_key"}
casinoya-nakama-server-nakama-1       | {"level":"warn","ts":"2024-01-09T04:36:07.666Z","caller":"server/config.go:337","msg":"WARNING: insecure default parameter value, change this for production!","param":"session.encryption_key"}
casinoya-nakama-server-nakama-1       | {"level":"warn","ts":"2024-01-09T04:36:07.666Z","caller":"server/config.go:341","msg":"WARNING: insecure default parameter value, change this for production!","param":"session.refresh_encryption_key"}
casinoya-nakama-server-nakama-1       | {"level":"warn","ts":"2024-01-09T04:36:07.666Z","caller":"server/config.go:345","msg":"WARNING: insecure default parameter value, change this for production!","param":"runtime.http_key"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.666Z","caller":"main.go:113","msg":"Nakama starting"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.666Z","caller":"main.go:114","msg":"Node","name":"nakama1","version":"3.20.0+88502b00","runtime":"go1.21.5","cpu":24,"proc":24}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.666Z","caller":"main.go:115","msg":"Data directory","path":"/nakama/data"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.666Z","caller":"main.go:126","msg":"Database connections","dsns":["root@cockroachdb:26257"]}
casinoya-nakama-server-nakama-1       | {"level":"debug","ts":"2024-01-09T04:36:07.667Z","caller":"server/db.go:74","msg":"Complete database connection URL","raw_url":"postgres://root@cockroachdb:26257/nakama?sslmode=prefer"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.670Z","caller":"main.go:132","msg":"Database information","version":"CockroachDB CCL v23.1.13 (x86_64-pc-linux-gnu, built 2023/12/01 21:38:31, go1.19.13)"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.679Z","caller":"server/metrics.go:177","msg":"Starting Prometheus server for metrics requests","port":9100}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.715Z","caller":"server/leaderboard_rank_cache.go:122","msg":"Initializing leaderboard rank cache"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.715Z","caller":"server/leaderboard_rank_cache.go:183","msg":"Leaderboard rank cache initialization completed successfully","cached":[],"skipped":[],"duration":"342.349µs"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.715Z","caller":"server/runtime.go:630","msg":"Initialising runtime","path":"/nakama/data/modules"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.724Z","caller":"server/runtime.go:637","msg":"Initialising runtime event queue processor"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.725Z","caller":"server/runtime.go:639","msg":"Runtime event queue processor started","size":65536,"workers":8}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.725Z","caller":"server/runtime_go.go:2701","msg":"Initialising Go runtime provider","path":"/nakama/data/modules"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.725Z","caller":"server/runtime_go.go:2725","msg":"Go runtime modules loaded"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.725Z","caller":"server/runtime_lua.go:115","msg":"Initialising Lua runtime provider","path":"/nakama/data/modules"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.725Z","caller":"server/runtime_lua.go:1220","msg":"Lua runtime modules loaded"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.725Z","caller":"server/runtime_lua.go:1223","msg":"Allocating minimum Lua runtime pool","count":16}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.725Z","caller":"server/runtime_lua.go:1231","msg":"Allocated minimum Lua runtime pool"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.725Z","caller":"server/runtime_javascript.go:634","msg":"Initialising JavaScript runtime provider","path":"/nakama/data/modules","entrypoint":""}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.727Z","caller":"server/runtime_javascript.go:1731","msg":"JavaScript runtime modules loaded"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.727Z","caller":"server/runtime_javascript.go:1734","msg":"Allocating minimum JavaScript runtime pool","count":16}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.727Z","caller":"server/runtime_javascript.go:1742","msg":"Allocated minimum JavaScript runtime pool"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.727Z","caller":"server/runtime.go:666","msg":"Found runtime modules","count":0,"modules":[]}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.727Z","caller":"server/leaderboard_scheduler.go:109","msg":"Leaderboard scheduler start"}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.727Z","caller":"server/leaderboard_scheduler.go:304","msg":"Leaderboard scheduler update","end_active":"-1ns","end_active_count":0,"expiry":"-1ns","expiry_count":0}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.727Z","caller":"server/api.go:138","msg":"Starting API server for gRPC requests","port":7349}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.728Z","caller":"server/api.go:289","msg":"Starting API server gateway for HTTP requests","port":7350}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.730Z","caller":"server/console.go:220","msg":"Starting Console server for gRPC requests","port":7348}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.731Z","caller":"server/console.go:324","msg":"Starting Console server gateway for HTTP requests","port":7351}
casinoya-nakama-server-nakama-1       | {"level":"info","ts":"2024-01-09T04:36:07.925Z","caller":"main.go:203","msg":"Startup done"}

I added some code in my main.ts to see if my implementation is working:

const rpcIdRewards = "rewards_js";
const rpcIdFindMatch = "find_match_js";

function InitModule(
  ctx: nkruntime.Context,
  logger: nkruntime.Logger,
  nk: nkruntime.Nakama,
  initializer: nkruntime.Initializer
) {
  initializer.registerRpc(rpcIdRewards, rpcReward);

  initializer.registerRpc(rpcIdFindMatch, rpcFindMatch);

  initializer.registerMatch(moduleName, {
    matchInit,
    matchJoinAttempt,
    matchJoin,
    matchLeave,
    matchLoop,
    matchTerminate,
    matchSignal,
  });

  logger.info("JavaScript logic loaded.");

  const card1 = new Card(
    1,
    Suit.HEARTS,
    Rank.ACE,
    Effect.HEAL,
    AdditionalEffect.CLEANSE
  );
  const card2 = new Card(2, Suit.DIAMONDS, Rank.TWO, Effect.DAMAGE);
  logger.debug(card1.compareTo(card2));
  logger.debug(card1.toString());
}

Neither the “Javascript logic loaded” or the logger.debug of my cards are showing to the screen. Am I doing something wrong?

Thanks

PS: On another note, I tried running the docker-compose with PostgreSQL but it was not working. Is Cockroach a good database? I see the warning about it not being secure right now and needing to run --accept-sql-without-tls for production server.

Please have a look at Nakama/Docker Path Issues.

The project template might also be useful to you as a starting point.

Cockroach DB is simply warning you that the current configs are not suitable for a production environment, as these are for local development only.

Hi,

I have tried the solutions indicated but without success.

I even tried changing the docker-compose to the one using PostgreSQL and I now have the following error:

 => ERROR [nakama node-builder 7/7] RUN npx tsc                                                                                                                                                                        1.3s 
------
 > [nakama node-builder 7/7] RUN npx tsc:
1.291 error TS6053: File '/backend/ai.ts' not found.
1.291   The file is in the program because:
1.291     Part of 'files' list in tsconfig.json
1.291 error TS6053: File '/backend/classes/card.ts' not found.
1.291   The file is in the program because:
1.291     Part of 'files' list in tsconfig.json
1.291 error TS6053: File '/backend/daily_rewards.ts' not found.
1.291   The file is in the program because:
1.291     Part of 'files' list in tsconfig.json
1.291 error TS6053: File '/backend/match_handler.ts' not found.
1.291   The file is in the program because:
1.291     Part of 'files' list in tsconfig.json
1.291 error TS6053: File '/backend/match_rpc.ts' not found.
1.291   The file is in the program because:
1.291     Part of 'files' list in tsconfig.json
1.291 error TS6053: File '/backend/messages.ts' not found.
1.291   The file is in the program because:
1.291     Part of 'files' list in tsconfig.json
------
failed to solve: process "/bin/sh -c npx tsc" did not complete successfully: exit code: 2

I tried removing the lines

    volumes:
      - ./:/nakama/data

but without success. After every failed docker-compose, I delete the container and associated volumes in docker-desktop.

What am I doing wrong?

Looking at your Dockerfile you’re only copying the main.ts file into the container. This looks like the project template, perhaps it would be easier to use it as a starting point instead and then change the code to suit your needs.

Best.

Hi,

I was able to make the typescript modules load but only by using PostgreSQL and not cockroachdb. For now it is fine as I didn’t setup my db yet so I can do it with PostgreSQL.

Here is the final docker-compose file for future reference:

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/local.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
    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:

and here is the dockerfile:

FROM node:alpine AS node-builder

WORKDIR /backend

COPY package*.json ./
RUN npm install

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

FROM heroiclabs/nakama:3.20.0

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

and here is the project structure:

project_name
|
build
—index.js
|
data
—model
—modules
—local.yml
|
src
—classes
—main.ts
|
docker-compose.yml
dockerfile
tsconfig.json

On a side note, the RUN npx tsc command in the Dockerfile does not seem to work as I still need to run it manually every time. Is the Dockerfile not correct?

We can close the ticket after answering the side note. Thanks!

@StudioParaNoya perhaps you need to run docker compose up --build to force the container re-run npx tsc

I am doing that but it doesn’t work. It’s fine, you can close the ticket. Thanks again!