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.