Skip to content

Deploying the Web App

Besides the desktop RPM, Squirrel is published as a container image that serves the web app, ghcr.io/slaclab/react-squirrel. This page is for whoever runs it. For the desktop app, see Deploying the Desktop App.

Getting the Image

CI builds the image from docker/Dockerfile on every push to main; pull requests only check that it builds. Each build is tagged:

Tag What it is
sha-<id> The build of one commit, named by its first 7 characters; never changes. Pin deployments to this
latest The newest build from main

Running the Image

The image serves the static bundle from unprivileged nginx (uid 101, port 8080) and proxies Canopy, so the API key lives in the container and never reaches the browser.

Variable Required Meaning
CANOPY_UPSTREAM Yes Canopy base URL, e.g. http://canopy-api:8000 (a trailing slash is dropped)
CANOPY_API_KEY Yes Key nginx sends as X-API-Key (see below)

The container exits at startup if either is missing.

The key needs read and write access to the squirrel and hare modules, e.g. <token>:read+write@squirrel+hare. jobs is implicitly allowed, and analytics ingestion takes no key. For Post to Elog, add elog as well; see E-log Access.

  • Base path. The bundle is built for /squirrel/ (--build-arg VITE_BASE_PATH=... to change it). nginx serves from the root and relies on the ingress to strip the prefix, so https://<host>/squirrel/ reaches the container as /.
  • config.json. Mount it at /usr/share/nginx/html/config.json. Declare one instance whose apiUrl points at the proxy and carries no apiKey, either absolute or relative to the host:
{ "instances": { "canopy": { "apiUrl": "https://<host>/squirrel/api/canopy" } } }

A web build never shows the API-key prompt (that banner is desktop-only).

  • Proxy. /api/canopy/ is forwarded to CANOPY_UPSTREAM/, WebSocket upgrades included (Hare's live values). Of Hare, only GET on its live-values WebSocket (/hare/v1/ws/pvs) goes through, since that is all the UI uses; its REST routes, PV writes included, are refused with a 403. Request bodies up to 25 MB are accepted; the ingress proxy-body-size must be at least that large.

Access

nginx adds the key to every proxied request, so anyone who can reach the ingress gets the key's access without logging in, Squirrel's writes and restores included. Put the ingress behind SSO or a network allowlist.

Trying It Locally

There is no ingress to strip a prefix, so build for the root and point apiUrl at the container, e.g. "apiUrl": "http://localhost:8080/api/canopy":

docker build -f docker/Dockerfile --build-arg VITE_BASE_PATH=/ -t react-squirrel .
docker run --rm -p 8080:8080 \
  -e CANOPY_UPSTREAM=http://host.docker.internal:8000 -e CANOPY_API_KEY=dev \
  -v "$PWD/config.json:/usr/share/nginx/html/config.json:ro" react-squirrel