Skip to content

Running the Backend Locally

The MIP backend is a NestJS application that manages game server allocation (Agones/Kubernetes), player sessions, chat, and persistence.

For local development, the backend runs directly on your machine — not inside Docker.


Why Run on Host Instead of Docker?

The backend needs to talk to the Minikube Kubernetes API to allocate and manage game servers. When the backend runs inside a Docker container, it sits on an isolated Docker network and cannot reach the Minikube cluster running on the host. Running directly on the host gives it native access to the Minikube API.

Concern Docker Host (recommended)
Minikube API access Requires socat + port-forward bridge Native — works out of the box
Hot reload Requires volume mounts or rebuild npm run start:dev — instant
Debugging Harder to attach debugger Standard Node.js debugging
Redis / MongoDB Runs in Docker Runs in Docker (same)

Step 1 — Clone the Backend

git clone https://github.com/dana-rs/mip-be-pub.git mip-be
cd mip-be

Step 2 — Start Infrastructure

Redis and MongoDB run in Docker via compose. From the mip-be directory:

docker compose up -d

This starts:

  • Redis on localhost:6379
  • MongoDB on localhost:27017

Step 3 — Configure Environment

Copy or edit the .env file in mip-be/ with your values. The key variables:

Variable Description
KUBE_SERVER Minikube API URL (from Minikube setup)
KUBE_TOKEN Service account token
KUBE_CA Base64-encoded cluster CA
MONGO_DB_URL MongoDB connection string (default: mongodb://mip_admin:yourRandomMongoPasswordHere@localhost:27017/)
REDIS_PASSWORD Redis password (default: mip_redis_internal)

Step 4 — Install Dependencies

npm install

Step 5 — Start the Backend

npm run start:dev

The backend starts on http://localhost:3000 with hot-reload enabled. Any code change automatically restarts the server.


Verifying the Setup

Once the backend is running, you should see NestJS log output indicating successful connections to Redis, MongoDB, and the Kubernetes API. The Unreal Engine client can then connect to http://localhost:3000 for authentication and ws://localhost:3000 for Socket.IO real-time events.