Coffee & Code - Setting Up Nakama on DigitalOcean for Flutter Games

Coffee & Code - Setting Up Nakama on DigitalOcean for Flutter Games

See how I finally got Nakama to run on my DigitalOcean Droplet and added a leaderboard to the Gift Grab app.


Sample Image
Cappuccino from Gem City Catfé in Dayton, OH.

I finally achieved a significant breakthrough with the Gift Grab app. I was encountering issues getting the Nakama instance to run on the server to allow users to compete against each other. It turned out that my Droplet on DigitalOcean was missing some components.

Sample Image
The Gift Grab leaderboard.

First, I had to include an extra command in my Dockerfile to fetch dependencies needed in the main.go file.

Sample Image
The leaderboard in Nakama’s dashboard.

I initially ran the go mod vendor command outside the Dockerfile, so when it was deployed to the server, it couldn’t locate the packages.

Sample Image
Running the command for building the volume in the Droplet’s console.

Second, I discovered my Nakama instance was built from an outdated Volume. Oddly enough, if a Volume is already built, any modifications made to the Images and/or Containers are irrelevant.

FROM heroiclabs/nakama-pluginbuilder:3.16.0 AS builder
ENV GO111MODULE on
ENV CGO_ENABLED 1
WORKDIR /backend
COPY . .
RUN go mod vendor
RUN go build --trimpath --mod=vendor --buildmode=plugin -o ./backend.so
FROM heroiclabs/nakama:3.16.0
COPY --from=builder /backend/backend.so /nakama/data/modules
COPY --from=builder /backend/local.yml /nakama/data/

Once I removed everything and ran the command compose -p gift-grab-api up — build, a new Volume was built, and my leaderboard was successfully created.

Sample Image
New test builds of the app for Android/iOS.

Related posts
Coffee & Code - Deploying Nakama to DigitalOcean Droplet

Coffee & Code - Deploying Nakama to DigitalOcean Droplet

Read more
Coffee & Code - Nakama Sessions & Authentication

Coffee & Code - Nakama Sessions & Authentication

Read more
Coffee & Code - Building Games with Nakama Backend

Coffee & Code - Building Games with Nakama Backend

Read more
Coffee & Code - Navigating App Store Submissions for Flutter

Coffee & Code - Navigating App Store Submissions for Flutter

Read more