Sitrec Installation Methods

Sitrec can be installed and run in four different ways:

  1. Docker (Recommended for quickest setup) - Fully containerized, everything included in the container
  2. Serverless Build (PHPless) - Runs without PHP backend, either as static files or a lightweight Node.js server
  3. Standalone Node.js Server - Self-contained build using Node.js + your system's PHP, no web server needed
  4. Local Web Server - Traditional setup with Nginx/Apache + PHP, for full development environment

Choose the method that best fits your needs:

Method Best For Requirements Build Time
Docker Quick testing, no configuration Only Docker Desktop (no Node.js, PHP, or web server needed) ~1 minute
Serverless (PHPless) Offline/portable use Node.js (for server mode) or just a modern browser (for static mode) ~10 seconds
Standalone Development without web server Node.js + PHP in PATH (no web server needed) ~10 seconds
Local Server Full development environment Node.js + Nginx/Apache + PHP ~5 seconds

Serverless Build (No Backend Required)

The serverless build creates a version of Sitrec that runs without any backend server (no PHP). It can be used in two ways:

Option 1: PHPless Node.js Server

Run as a lightweight Node.js server without PHP dependencies:

git clone https://github.com/MickWest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for f in config/*.example; do cp "$f" "${f%.example}"; done  # Mac/Linux
# OR for Windows: for %f in (config\*.example) do copy /Y "%f" "%~dpnf"
npm install
npm run build-serverless
npm run start-serverless

Then open: http://localhost:3000/sitrec

This provides a minimal Node.js server without any PHP backend. All data is stored locally in the browser's IndexedDB.

Option 2: Pure Static Files

After building with npm run build-serverless, the files in dist-serverless/ can be:

Serverless Limitations:

Serverless Advantages:

Quickest Local Install, Using Docker

This method requires only Docker Desktop - no Node.js, PHP, or web server installation needed. Everything runs inside the Docker container.

Prerequisites:

Install Git and Docker Desktop, then run Docker Desktop.

Mac/Linux

git clone https://github.com/MickWest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for f in config/*.example; do cp "$f" "${f%.example}"; done
docker compose -p sitrec up -d --build
open http://localhost:6425/

Windows

git clone https://github.com/mickwest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for %f in (config\*.example) do copy /Y "%f" "%~dpnf"
docker compose -p sitrec up -d --build
start http://localhost:6425/

This will be running on http://localhost:6425/. The "open" or "start" commands above should open a browser window.

Docker Development Build (Advanced)

For active Sitrec development with hot reload capabilities, there's an alternative Docker configuration that provides a more interactive development experience.

Standard Docker vs Development Docker:

Feature Standard Docker (docker-compose.yml) Development Docker (docker-compose.dev.yml)
Purpose Production-like environment Active development with hot reload
Build Time ~2-3 minutes ~5-10 minutes (first build)
File Changes Requires rebuild Immediate (auto-recompile)
Ports 6425 8080 (webpack), 8081 (Apache)
Source Mounting No (files copied into image) Yes (live editing from host)
Hot Reload No Yes (webpack dev server)
Best For Testing, demos, production-like setup Active code development

Development Docker Setup:

Mac/Linux

git clone https://github.com/MickWest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for f in config/*.example; do cp "$f" "${f%.example}"; done
docker-compose -f docker-compose.dev.yml up -d --build
open http://localhost:8080/

Windows

git clone https://github.com/mickwest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for %f in (config\*.example) do copy /Y "%f" "%~dpnf"
docker-compose -f docker-compose.dev.yml up -d --build
start http://localhost:8080/

What this provides:

Hot Reload Behavior:

Useful Commands:

# View live logs
docker-compose -f docker-compose.dev.yml logs -f

# Stop containers
docker-compose -f docker-compose.dev.yml down

# Access container shell
docker-compose -f docker-compose.dev.yml exec sitrec-dev bash

# Restart after config changes
docker-compose -f docker-compose.dev.yml restart

Troubleshooting Docker Dev:

Quick node.js dev server install (Standalone Build)

This method creates a self-contained build and runs it with Node.js and your system's PHP installation. No separate web server (Nginx/Apache) is required.

Prerequisites:

To check if PHP is available:

php --version

If PHP is not installed:

Installation:

Mac/Linux

git clone https://github.com/MickWest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for f in config/*.example; do cp "$f" "${f%.example}"; done
npm install
npm run dev-standalone-debug

Windows

git clone https://github.com/MickWest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for %f in (config\*.example) do copy /Y "%f" "%~dpnf"
npm install
npm run dev-standalone-debug

What this does:

  1. Builds the application into a dist-standalone directory (not your web server)
  2. Starts a Node.js Express server on port 3000
  3. Starts PHP's built-in development server on port 8000 (using your system's PHP)
  4. Proxies requests between the frontend and backend

If successful, you'll see:

🚀 Sitrec standalone server is running!
📱 Frontend: http://localhost:3000/sitrec
🐘 PHP Backend: http://localhost:8000
Press Ctrl+C to stop the server

Then open: http://localhost:3000/sitrec

Note: This uses your local PHP installation (the php command in your PATH). The standalone server will automatically start and stop PHP's built-in server.

Local Server Installation

Prerequisites

If you want to install and run directly from a local server, and not use Docker, the you will need:

Server Install Mac/Linux

Assuming we want to install the build environment in "sitrec-test-dev", run:

git clone https://github.com/MickWest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for f in config/*.example; do cp "$f" "${f%.example}"; done
npm install

Assuming you want to install in a folder called "glass" that's off the root of your local web server. In this example, the full path to my local web server root is: /Users/mick/Library/CloudStorage/Dropbox/Metabunk/

mkdir /Users/mick/Library/CloudStorage/Dropbox/Metabunk/glass
pushd /Users/mick/Library/CloudStorage/Dropbox/Metabunk/glass
mkdir sitrec
mkdir sitrec-cache
mkdir sitrec-upload
mkdir sitrec-videos
mkdir sitrec-terrain
popd

Edit config/config-install.js Set dev_path to /Users/mick/Library/CloudStorage/Dropbox/Metabunk/glass/sitrec Set prod_path to any folder you can use for staging the deploy build (if needed). Example

module.exports = {
dev_path: '/Users/mick/Library/CloudStorage/Dropbox/Metabunk/glass/sitrec',
prod_path: '/Users/mick/sitrec-deploy'
}

Build into the local web folder we defined earlier

npm run build

Server Install Windows

git clone https://github.com/mickwest/sitrec2 sitrec-test-dev
cd sitrec-test-dev
for %f in (config\*.example) do copy /Y "%f" "%~dpnf"
npm install

Assuming you want to install in a folder called "glass" that's off the root of your local web serve

mkdir c:\\nginx\\html\\glass
pushd c:\\nginx\\html\\glass
mkdir sitrec
mkdir sitrec-cache
mkdir sitrec-upload
mkdir sitrec-videos
mkdir sitrec-terrain
popd
notepad config\config-install.js

Edit config\config-install.js Set dev_path to the local deployment folder on the web server Set prod_path to any folder you can use for staging the deploy build (if needed)

Example:

module.exports = {
    dev_path: 'c:\\nginx\\html\\glass\\sitrec',
    prod_path: 'c:\\users\\mick\\sitrec-deploy'
}

Build into the local web folder we defined earlier

npm run build

Code overview

Sitrec runs mostly client-side using JavaScript and some custom shaders but also has a handful of server-side scripts written in PHP.

The rendering code uses Three.js, and there are a variety of other open-source libraries. All this uses MIT licenses or similar.

The code cannot be run directly, as it is set up to be compiled using WebPack.

Install local dev environment

Assuming that you want to run the code on a local machine for development, testing, etc, you need a web server. I use Nginx, but Apache should work The web server should be configured to run php files (i.e. php-fpm) It should also load an index.html file when there's one in the directory (this is usually default)

You will also need to install node.js in you build environment, from: https://nodejs.org/en/download

Node.js is used both for build tools (i.e. webpack) and for packages used by the app. It is not used server-side.

Create Source file and sitrec project folder structure

Sitrec is built from the "sitrec" project folder. Note this is NOT the same "sitrec" server folder you deploy to.

Clone Sitrec from GitHub, or download a release archive. This will give you the sitrec project folder with these sub-folders:

Then there are the project build files:

(config.js and config-install.js are initial supplied as config.js.example and config-install.js.example - you will need to rename them).

Create the local (and production) server folder structure

Sitrec can exist at the server root, or in any path. I use the root, but it's maybe neater to have in a folder. Here I'll assume it's in a folder called "s". You do not have to use "s", you can put it in another folder, or in the web root (like I do)

There are six folders in the server structure

Note sitrec-cache and sitrec-upload must have write permission.

There's also an optional URL shortener, which is uses a folder called 'u' to store HTML files with short names that are used to redirect to longer URLs.

Download the videos

The private video folder contains videos taken by individuals and posted on the internet. I use them in Sitrec under fair-use, non-commercial, educational. But they are not included here. Ask me if you really need one. The public folder contain videos that are government produced, are by me, or are otherwise free of restrictions. They can be found here: https://www.dropbox.com/scl/fo/biko4zk689lgh5m5ojgzw/h?rlkey=stuaqfig0f369jzujgizsicyn&dl=0

Create/Edit the config files in config/

You will need to edit shared.env, config.js, config-install.js and config.php. The defaults will work to an extent (with no credentials for downloading Mapbox or Space-Data, etc), so the minumum you need to edit is config-install.js

sitrec/config/shared.env

See shared.env.example file for usage.

sitrec/config/config.js

This has the basic paths for both the local dev environment, and (optionally) the server environment For the dev environment, we need edits in two places:

const SITREC_LOCAL = "http://localhost/s/sitrec/"
const SITREC_LOCAL_SERVER = "http://localhost/s/sitrec/sitRecServer/"

Then the server, the file has code which will attempt to determine SITREC_HOST from the environment. You might have to set it manually. There's comments in the file explaining this.

config.js also has the localSituation variable which determines which sitch you boot up into in a local dev environment.

sitrec/config/config-install.js

This tells Webpack where to put the built application. My setup is:

dev_path: '/Users/mick/Library/CloudStorage/Dropbox/Metabunk/sitrec',
prod_path: '/Users/mick/sitrec-deploy'

dev_path is the path to the local server. Here /Users/mick/Library/CloudStorage/Dropbox/Metabunk/ is the root of my local web server. A simple Windows configuration might be:

dev_path: 'c:\\nginx\\html\\s\\sitrec',
prod_path: 'c:\\Users\\Fred\\sitrec-deploy'

If you are just building/testing locally, these can be the same path.

sitrec/config/config.php

This sets up credentials for site like mapbox, amazon S3, space-data, etc are now in shared.env Read the comments in the file. There's a config.php.example file to use as a starting point

File paths are now automatically detected by config_paths.php, which you should not need to edit. If you have a configuration that requires you to edit this file, then please let me know (Open an issue on GitHub or email me, mick@mickwest.com)

Install the node modules

In sitrec there will also be a folder, node-modules. This is autogenerated by node.js from the package.json file. To create or update it, in the sitrec folder run

npm install

This will create the folder node_modules, which will (currently) have 218 folders in it. These are the 24 packages that are used, plus their dependencies. Note you won't be uploading this to the production server, as we use WebPack to only include what is needed. You will need to do this when you get new code, but not during your own development.

Available Build Commands

Sitrec has several build commands for different purposes:

Webpack Configuration

Sitrec uses separate webpack configs optimized for different environments:

Config Cache File Watching Use Case
webpack.dev.js Disabled Filesystem native Local development
webpack.dev.docker.js Enabled (filesystem) Polling (1000ms) Docker containers

Local development disables caching to ensure clean rebuilds on every change. Docker uses caching and polling for better performance with volume mounts.

Development Builds (for local web server)

npm run build - Build for local development

npm run start - Development server with hot reload

npm run copy - Copy files without rebuilding

Standalone Builds (self-contained, no web server needed)

npm run build-standalone - Production standalone build

npm run build-standalone-debug - Development standalone build

npm run dev-standalone-debug - Build and run standalone (debug mode)

npm run start-standalone - Run the standalone server

npm run start-standalone-debug - Run standalone with Node.js inspector

Production Build

npm run deploy - Build for production deployment

Port Configuration

All ports can be customized via environment variables:

Mode Default Port Environment Variable Description
npm run start 3000 SITREC_PORT Webpack dev server port
npm run start 8081 SITREC_BACKEND_PORT Backend (nginx/Apache) port for proxying
Standalone 3000 SITREC_PORT Express server port
Standalone 8000 SITREC_PHP_PORT PHP built-in server port
Serverless 3000 SITREC_PORT Express server port
Docker 6425 (docker-compose.yml) Exposed port
Docker Dev 8080 (docker-compose.dev.yml) Webpack dev server
Docker Dev 8081 (docker-compose.dev.yml) Apache/PHP backend

Example: Run on different ports

SITREC_PORT=4000 npm run start                           # Dev server on 4000
SITREC_PORT=4000 SITREC_PHP_PORT=9000 npm run start-standalone  # Standalone on 4000/9000
SITREC_BACKEND_PORT=80 npm run start                     # Proxy to nginx on port 80

Debugging

Debug Builds

For debugging, use the debug build commands which include enhanced features:

npm run dev-standalone-debug     # Build + run with full debugging
npm run build-standalone-debug   # Build only with debug features
npm run start-standalone-debug   # Start with Node.js inspector

Debug build features:

Browser Debugging (Chrome DevTools)

  1. Open your application (e.g., http://localhost:3000/sitrec)
  2. Press F12 to open DevTools
  3. Go to Sources tab
  4. Navigate to webpack://sitrec/src/ to find your source files
  5. Set breakpoints in your original source code

Node.js Server Debugging

  1. Run: npm run start-standalone-debug
  2. Look for: Debugger listening on ws://127.0.0.1:9229/...
  3. Open Chrome and navigate to: chrome://inspect
  4. Click "Open dedicated DevTools for Node"
  5. Set breakpoints in standalone-server.js

Debug Endpoints (Standalone/Serverless)

When running standalone or serverless servers, these debug endpoints are available:

Endpoint Description
/debug/status Server configuration and status
/debug/files List all built files and assets
/api/health Health check (serverless only)
/api/manifest Available sitches list (serverless only)

VS Code Debugging

Create .vscode/launch.json with:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug Sitrec Standalone",
            "program": "${workspaceFolder}/standalone-server.js",
            "console": "integratedTerminal"
        }
    ]
}

Build the dev app with node.js and Webpack

In the sitrec project folder, run

npm run build

This will build the app to the location specified by dev_path in config-install.js (e.g., http://localhost/s/sitrec/), which mostly comprises:

index.html - the entry point
index.css - combined CSS
index.9a60e8af738fb4a9ce40.bundle.js (or similar, the name changes) - the code
/src/ - web worker code which is not included in webpack
/sitrecServer/ - the PHP server files
/data/ a copy of the /sitrec/data folder

Since this is building (via dev-path) into the local server, the dev app will be at

http://localhost/s/sitrec

Testing

The following are URLS for tests of basic functions (these assume that the dev setup is in /s/). If they fail, first check the dev tools console to see if there's a helpful error message.

Failure could mean

Production Build and Deploy

npm run deploy

This will build a production version of the code into the folder specified by prod_path in config-install.js

This is essentially the same as the dev version, except it's minified and has no debug info (file/line numbers, etc.) The minification means it takes a bit longer to build (for me build/dev is 3-4 seconds, and deploy/prod is about 15 seconds. YMMV)

The folder specified by prod_path here is arbitrarily named, it's just a temporary container for the production app and data before you transfer it to the production server. You can do that with FTP, ssh/rsync, or the deployment tool of your choice. I use rsync:

rsync -avz --delete -e "ssh " "$LOCAL_DIR/" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR

Before testing this, ensure you've got the five folders on the deploy servers, the same as on the local dev server.

Docker

docker compose -p sitrec up -d will start a container running the sitrec frontend and sitrecServer. By default, this will expose the service on http://localhost:6425/, without a basepath. To run on a different port, change the ports section of the docker-compose.yml file.

docker compose -p sitrec up -d --build will force a rebuild of the image.

A default bind mount is set up for the sitrec-videos folder in the root of the project directory, allowing videos to be added. The sitrec-cache folder uses a volume by default, but can be changed to a bind mount by uncommenting a line in the docker-compose.yml file.

Default sitrec-cache and sitrec-upload folders is created - but these will not persist.

The shortening functionality is not available in the docker container, as this depends on the Metabunk server.