Sitrec can be installed and run in four different ways:
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 |
The serverless build creates a version of Sitrec that runs without any backend server (no PHP). It can be used in two ways:
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.
After building with npm run build-serverless, the files in dist-serverless/ can be:
file:// protocol (with File System Access API support)Serverless Limitations:
Serverless Advantages:
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.
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:
src/): Auto-recompiled by webpack, manual browser refresh requiredsitrecServer/): Immediately available, requires page refreshdata/): Immediately available, requires page refreshUseful 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:
lsof -i :8080 or lsof -i :8081 to find conflicting servicesdocker-compose -f docker-compose.dev.yml down -v then rebuild with --no-cachesitrecServer/config.php appearing? This is normal Docker behavior due to overlapping volume mounts - the file is harmless and already in .gitignoreThis 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:
brew install php (or use the built-in PHP if available)sudo apt install php or sudo yum install phpInstallation:
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:
dist-standalone directory (not your web server)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.
If you want to install and run directly from a local server, and not use Docker, the you will need:
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
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
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.
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.
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:
config - the configuration files. Initially just .example filesdata - per-sitch data like ADS-B data, csv files, TLEs, models, sprites, and imagesdocker - Configuration files for Docker buildsdocs - other .md format Documentation and imagessitrecServer - The server-side PHP files, like cachemaps.phpsrc - The JavaScript source, with the entry point of index.jstest - Test files for the console buildtests - Unit tests that can be run by JestThen there are the project build files:
docker-compose.yml - configures the Docker containerDockerfile - configures the Docker image (which goes in the container)package.json - top-level descriptor, contains npm scripts for build and deploy. It also contains the devDependencies (node modules that are used)webpack.common.js - the main configuration file for Webpack. The next two files both include this.webpack.copy-files.js - a separate Webpack config to just copy the files wihout rebuildingwebpack.dev.js - used for developmentwebpack.prod.js - used for production/deploymentwebpackCopyPatterns.js - defines what files are copied from the dev folder to the build, and how they are transformed and.or renamed (e.g. custom.env)config/config.js - Contains install-specific constants for server paths used by the appconfig/config-install.js - development and production file paths, used by the build system(config.js and config-install.js are initial supplied as config.js.example and config-install.js.example - you will need to rename them).
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
sitrec - the folder containing the Webpack compiled app and the data files (except videos). This is deleted and recreated when rebuilding, so don't edit anything in there, edit thesitrec-config - contains server-side PHP configuration files - you need to edit this.sitrec-cache - a server-side cache for terrain tiles, initially emptysitrec-upload - for rehosting user files (like ADS-B or TLE). Initially emptysitrec-videos - The videos for the sitches. Handled separately as it can get quite large. The videos are subdivided into public (government or other unrestricted files) and private (where the licensing rights are unclear, but are used here under fair-use). So there's two sub-folders that you need to keep
sitrec-videos/publicsitrec-videos/privatesitrec-terrain - Local cache for downloaded terrain tiles (imagery and elevation). Initially empty. See tools/README_IMAGERY_DOWNLOAD.md for download scripts.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.
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
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
See shared.env.example file for usage.
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.
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.
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)
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.
Sitrec has several build commands for different purposes:
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.
npm run build - Build for local development
webpack.dev.js configurationconfig-install.js as dev_pathnpm run start - Development server with hot reload
SITREC_PORT)SITREC_BACKEND_PORT)npm run copy - Copy files without rebuilding
webpack.copy-files.jsnpm run build-standalone - Production standalone build
dist-standalone directorynpm run start-standalone to runnpm run build-standalone-debug - Development standalone build
dist-standalone directorynpm run start-standalone-debug to runnpm run dev-standalone-debug - Build and run standalone (debug mode)
build-standalone-debug + start-standalone-debugnpm run start-standalone - Run the standalone server
dist-standalone directorynpm run start-standalone-debug - Run standalone with Node.js inspector
start-standalone but with --inspect flagnpm run deploy - Build for production deployment
webpack.prod.js configurationconfig-install.js as prod_pathAll 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
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:
eval-source-map for accurate debugging in browser DevTools--inspect flag on port 9229http://localhost:3000/sitrec)F12 to open DevToolswebpack://sitrec/src/ to find your source filesnpm run start-standalone-debugDebugger listening on ws://127.0.0.1:9229/...chrome://inspectstandalone-server.jsWhen 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) |
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"
}
]
}
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
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.
PHP Test Must display a PHP info page showing version number
Terrain elevation test Test of the tile server proxy for terrain elevation. Should give a square image
Mapbox test Returns an aerial tile of some buildings and trees:
OSM Test Returns a segment of a street map
EOX Test Test of EOX landscape server - returns a brown aerial landscape tile
Landscape Test A simple landscape, shows that the landscape proxy server is working
Default Sitch Will load the default local sitch set in config.js
Aquadilla Sitch A more complex sitch with a video, landscape, tracks, and complex computations
Smoke Test A smoke test that loads ALL the sitches one after another
Quick Smoke Test A smoke test that loads ALL the sitches one after another as quickly as possible
Failure could mean
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 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.