Was trying to follow video tutorial here: Nakama: Go Runtime | Heroic Labs Documentation
Unfortunately, cannot get it to run. see logs below.
- Versions: Nakama 3.14.0, Docker, require GitHub - heroiclabs/nakama-common: The runtime framework for Nakama server. v1.25.0
- Server Framework Runtime language: Go 1.19
Logs:
{"level":"error","ts":"2022-11-16T23:39:10.259Z","caller":"server/runtime_go.go:2494","msg":"Could not open Go module","path":"/nakama/data/modules/backend.so","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
{"level":"error","ts":"2022-11-16T23:39:10.260Z","caller":"server/runtime.go:586","msg":"Error initialising Go runtime provider","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
{"level":"fatal","ts":"2022-11-16T23:39:10.260Z","caller":"main.go:146","msg":"Failed initializing runtime modules","error":"plugin.Open(\"/nakama/data/modules/backend\"): plugin was built with a different version of package google.golang.org/protobuf/internal/pragma"}
Dockerfile:
FROM heroiclabs/nakama-pluginbuilder:3.3.0 AS go-builder
ENV GO111MODULE on
ENV CGO_ENABLED 1
WORKDIR /backend
COPY go.mod .
COPY main.go .
COPY vendor/ vendor/
RUN go build --trimpath --mod=vendor --buildmode=plugin -o ./backend.so
FROM registry.heroiclabs.com/heroiclabs/nakama:3.14.0
COPY --from=go-builder /backend/backend.so /nakama/data/modules/
COPY local.yml /nakama/data/
go.mod file:
module github.com/technicallyty/nakama-demo
go 1.19
require github.com/heroiclabs/nakama-common v1.25.0
require google.golang.org/protobuf v1.28.1 // indirect
docker-compose.yml:
version: '3'
services:
postgres:
command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all
container_name: backend_postgres
environment:
- POSTGRES_DB=nakama
- POSTGRES_PASSWORD=localdb
expose:
- "8080"
- "5432"
image: postgres:12.2-alpine
ports:
- "5432:5432"
- "8080:8080"
volumes:
- data:/var/lib/postgresql/data
nakama:
build: .
container_name: backend
depends_on:
- postgres
entrypoint:
- "/bin/sh"
- "-ecx"
- >
/nakama/nakama migrate up --database.address postgres:localdb@postgres:5432/nakama?sslmode=disable &&
exec /nakama/nakama --config /nakama/data/local.yml --database.address postgres:localdb@postgres:5432/nakama?sslmode=disable
expose:
- "7349"
- "7350"
- "7351"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7350/"]
interval: 10s
timeout: 5s
retries: 5
links:
- "postgres:db"
ports:
- "7349:7349"
- "7350:7350"
- "7351:7351"
restart: unless-stopped
volumes:
data: