Skip to content

Local Setup

This page gets Squirrel's frontend running on your machine against a local Canopy server.

Prerequisites

  • Node.js 18+ and pnpm 10. The exact pnpm version is pinned in package.json's packageManager field; corepack enable installs it for you.
  • A Canopy server, normally the development stack from the Canopy repository, which needs Docker and uv.

1. Start Canopy

In a checkout of Canopy, start its development stack and run the database migrations once:

cd docker
docker compose up -d
cd ..
CANOPY_DATABASE_URL=postgresql+asyncpg://canopy:canopy@localhost:5432/canopy \
  uv run alembic upgrade head

This starts Canopy's API, its worker (which captures and restores snapshots), Postgres, and Redis. It uses Canopy's simulated EPICS backend, so no control system is needed: every PV reads as a changing synthetic value, and restores always succeed. Its API key is dev. See Canopy's Docker Compose guide for details.

Port mismatch

Canopy's development stack listens on port 8000, but Squirrel's dev server expects Canopy on 8080 by default (#232). Until that's fixed, set CANOPY_URL=http://localhost:8000 in .env.local (step 3), or start Canopy with API_HOST_PORT=8080 in its docker/.env.

To try restore failures, or the built-in restore hooks, set Canopy's simulation options in its docker/.env and restart the worker; see Testing Squirrel in Canopy's documentation.

2. Install

In this repository:

pnpm install

This also installs the git pre-commit hook; see Testing and Code Quality.

3. Configure

Copy the example environment file:

cp .env.local.example .env.local

.env.local holds the dev server's settings:

Variable Default Meaning
API_KEY dev Required. The key the dev server adds to every request to Canopy. dev matches Canopy's development stack.
CANOPY_URL http://localhost:8080 The Canopy server to forward to. Set it to http://localhost:8000 for Canopy's development stack.

.env.local is ignored by git, so it's safe to put a real key in it.

4. Run

pnpm dev

Open http://localhost:5173. On startup the dev server prints whether API_KEY was loaded and which Canopy server it forwards to. Without API_KEY, it refuses to start.

How requests reach Canopy

The browser only talks to the dev server. The dev server forwards Canopy's module paths, /squirrel, /jobs, /hare (including the live-data WebSocket), /analytics and /elog, and Canopy's own /v1 routes, such as the facility list, to CANOPY_URL, adding API_KEY as the X-API-Key header. So in development:

  • The app has no instances and no key of its own; there is no instance picker and no API key banner.
  • Any other path isn't forwarded and is answered by the dev server itself.

To develop against a remote Canopy server instead, set CANOPY_URL to its address and API_KEY to a key for it. The key needs every module the app calls; see API Keys.

Next Steps