Running Work Adventure without Docker

This guide is outdated since Work Adventure got massive changes overtime. This guide may still be a guideline for current state.

last update on 2021-08-18T18:51:00Z
This is no official guide, can include typos, so check commands twice!

Intro

The official guide to run a selfhosted Work Adventue [WA] instance is to use docker-compose. Since I had problems in setting up a production enviroment I took a look into the different main components and how they are run in docker.

There are three main components of WA all in their corresponding subfolder:

When talking about building and running, the context is always the corresponding subfolder!

Building and running components

Prerequisites

Software

I am running on an Ubuntu 21.04. So this guide is linux based.

Enviroment

For every component, some build enviroments variables need to be set. Therefore I created .env files for every component to export those values into current session. The required and optional variables are listed in every component.

Message component

Working directory: ./messages

All other components use protobuf messages which need to be generated and copied into all other components.

Run the following commands

yarn install
yarn proto
cp -r generated/ ../front/src/Messages/
cp -r generated/ ../pusher/src/Messages/
cp -r generated/ ../back/src/Messages/

Front component

Working directory: ./front

Prerequisites

Create and configure .env-file:

### required
export NODE_ENV=production
export PUSHER_URL="//pusher.workadventure.localhost"
export ADMIN_URL="//workadventu.re"
### optional
export DEBUG_MODE=false
export START_ROOM_URL="/_/global/maps.workadventure.localhost/Floor0/floor0.json"
export UPLOADER_URL="//uploader.workadventure.localhost"
export JITSI_URL="meet.jit.si"
export JITSI_PRIVATE_MODE=false
export STUN_SERVER="stun:stun.l.google.com:19302"
export TURN_SERVER=
export TURN_USER=
export TURN_PASSWORD=
export MAX_PER_GROUP=4
export MAX_USERNAME_LENGTH=8
export DISABLE_NOTIFICATIONS=true
export SKIP_RENDER_OPTIMIZATIONS=true
export GA_TRACKING_ID=
Building

Run the following commands

yarn install
./templater.sh # I have to check if you can skip this step whenn you don't want to use Google Analytics and have no GA_TRACKING_ID set.
source .env
yarn run build

Afterwards a complete frontend build should be inside the ./dist/-folder.

Important hint: when you have NODE_ENV=production set before yarn install the build process will fail, so keep that in mind, that source .env get's called after yarn install and if you need to update dependencies, reset your enviroment. This also applies to the other components!
Running

To make the frontend running, just make the ./dist/-folder available in your webserver. A simple example for Apache2 is listed below, please always adjust to your needs like using SSL etc.

<VirtualHost *:80>
	ServerName play.workadventure.localhost

	DocumentRoot "[..]workadventure/front/dist/"

	<Directory [..]workadventure/front/dist/>
		Options Indexes FollowSymLinks MultiViews
		Options FollowSymLinks
		AllowOverride All
	</Directory>
</VirtualHost>
Another option is to use yarn start to start a webserver on port 8080, but I'll have to check if this is only meant for development purporses.

Pusher component

Working directory: ./pusher

Prerequisites

I had to update a dependency in the package.json:
"uWebSockets.js": "uNetworking/uWebSockets.js#v19.3.0"
otherwise my build failed with incompatible versions.

Create and configure .env-file:

### required
export NODE_ENV=production
export API_URL="localhost:50051"
### optional
export PUSHER_HTTP_PORT=
export SECRET_KEY="yourSecretKey"
export JITSI_URL="meet.jit.si"
export JITSI_ISS=
export SECRET_JITSI_KEY=
export ADMIN_API_URL=
export ADMIN_API_TOKEN=
export FRONT_URL="http://play.workadventure.localhost"
export OPID_CLIENT_ID=
export OPID_CLIENT_SECRET=
export OPID_CLIENT_ISSUER=
Building

Run the following commands

yarn install
source .env
yarn run tsc
yarn install --production
npm rebuild # I don't know why, otherwise next command fails with hint to do npm rebuild and it worked

Running

Start the pusher service with
yarn run runprod
This will run pusher on port 8080 or the defined PUSHER_HTTP_PORT.

Proxy the pusher port to your pusher url, for example to pusher.workadventure.localhost with Apache2.

<VirtualHost *:80>
	ServerName pusher.workadventure.localhost

	RewriteEngine On

	# forward websocket
	RewriteCond %{HTTP:Upgrade} websocket [NC]
	RewriteCond %{HTTP:Connection} upgrade [NC]
	RewriteRule ^/(.*) "ws://localhost:8080/$1" [P,L]

	ProxyPass / http://localhost:8080/
	ProxyPreserveHost On
	ProxyPassReverse / http://localhost:8080/
</VirtualHost>

Back component

Working directory: ./back

Prerequisites

As in Pusher, I had to update a dependency in the package.json:
"uWebSockets.js": "uNetworking/uWebSockets.js#v19.3.0"

Create and configure .env-file:

### required
export NODE_ENV=production
### optional
export HTTP_PORT=
export GRPC_PORT=
export SECRET_KEY="yourSecretKey"
export JITSI_URL="meet.jit.si"
export JITSI_ISS=
export SECRET_JITSI_KEY=
export MAX_PER_GROUP=4
export ADMIN_API_URL=
export ADMIN_API_TOKEN=
export TURN_STATIC_AUTH_SECRET="
export REDIS_HOST=
export REDIS_PORT=
export REDIS_PASSWORD=
Building

Run the following commands

yarn install
source .env
yarn run tsc
yarn install --production
npm rebuild # same as in Pusher

Running

Start the back service with
yarn run runprod
This will run back on HTTP_PORT (8080) and on GRPC_PORT (50051).

I am also a bit unsure here, because HTTP_PORT defaults to 8080 which is also used by Pusher, but I didn't get any errors and connected Pusher to GRPC_PORT (50051) anyways. But I think it should be better to use a different HTTP_PORT here.