All Collections
General questions
How to run Room Servers from brainCloud
How to run Room Servers from brainCloud

Dockerfile, custom room server, lobby

Jason Liang avatar
Written by Jason Liang
Updated over a week ago

This article will walk you through several essential steps of launching room servers for your game via brianCloud. For the sake of simplicity and accessibility, we will deploy a website on a room server, instead of game logic with brainCloud S2S stuff.

Step 1: build your docker image

The only way that brainCloud deploys your custom game or business logic to the room servers is to load your Docker image and run that image container on the server. So, let's create one.

We will use Vue framework for the demo site. (you should already have docker and Vue installed on your machine).

  • Run this in your bash:

vue create docker-vue
  • build the package

yarn build
  • create a Dockfile

cd docker-vue && touch Dockerfile
  • create an Nginx config file

touch default.conf
  • write the following line to this default.conf file

server { 
listen 80;
server_name localhost;
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
error_log /var/log/nginx/error.log error;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
  • open Dockfile and write the following content into it.

FROM nginx 
COPY dist/ /usr/share/nginx/html/
COPY default.conf /etc/nginx/conf.d/default.conf

FROM nginx -- set the image will build based on nginx:latest image.

COPY dist/ /usr/share/nginx/html/ -- copy all the content from root dist folder to image folder /usr/share/nginx/html/

COPY default.conf /etc/nginx/conf.d/default.conf -- replace Nginx image config file with the one we created.

  • run docker build command to build an image via the current Dockfile.

docker build -t yourdockeraccount/docker-vue . 

-t -- give the image a name.

. -- use the current folder which Dockfile located.

  • once docker builds the image successfully, we can check it by running:

docker image ls
  • now, we can run the image

docker run -d -p 3500:80 --name docker-vue yourdockeraccount/docker-vue

-d -- set the container in detached (background) mode.

-p -- map internal port to docker host port that would run the container.

--name -- give the container a name (here is: docker-vue)

  • check all the running containers by running:

docker ps -a
  • open your browser with localhost:3500 to check the running web

  • open dashboard of Docker desktop, you will find the running container there.

  • now, time to ship your image to your docker hub.

docker push yourdockeraccount/docker-vue
  • you should find it from your docker hub repositories after shipping.

Step 2: Configure room server and lobby on brainCloud

In order to let brainCloud launching your image just like you run on your local machine from the above step, you need to tell brainCloud where to find your image and configure some parameters for your server and the server trigger -- lobby.

  • navigate to Design | My Servers | Cloud Code - My Servers Settings page create a new server and fill the fields as follows. (don't forget to add a region for your server on the Regions section)

  • browser to Design | Multiplayer | Configure Lobbies page, create a new lobby and set it link to the room server you just created.

Step 3: write test code

Chose a brainCloud supported language you prefer to write the code launching the room server. Basically, your code should include these key APIs:

  • RTTService.enableRTT

  • RTTService.registerRTTLobbyCallback

  • LobbyService.createLobby

_bc.RTTService.enableRTT(BrainCloud.RTTConnectionType.WEBSOCKET, rttConnectSuccess, rttConnectFailure);
public void rttConnectSuccess(response)
String lobbyType = "wart";
int rating = 76;
String[] otherUserCxIds =;
String settings = "{}";
boolean isReady = false;
String extraJson = "{}";
String teamCode = "all";
_bc.getLobbyService().createLobby(lobbyType, rating, otherUserCxIds, settings, isReady, extraJson, teamCode, this);
public void rttConnectFailure(String errorMessage)
System.out.print(String.format("Failed | %s", errorMessage));

Step 4: Test and debug

In order to better debugging your running room server, integrating the slack alert will be a good option, refer to this article for the detail of implementation. Give your test code a run, your slack will get a bunch of altering status message from the brainCloud hosting server.

From these return messages, you can get all the information about your running room server, such as instance running IP and port.

(for our example, it is running at, so you can visit the address from your browser to test it. )

Did this answer your question?