Deploying a shared server#

This page sets up a rapidtools-gui server that colleagues open in their browsers over HTTPS. The GUI runs in Docker behind the Caddy web server, which gets its HTTPS certificate by itself, and imagery, results and caches stay on the host’s disk. The files are under deploy/ in the repository. The same steps work on a machine in your lab, a university VM or a cloud instance. Windows workstations and cloud machines have their own sections further down.

What you need#

  • A Linux machine with Docker and the Docker Compose plugin. To run local models (Gemma 4, Qwen, Llama) and fast SAM 3 detection, it also needs an NVIDIA GPU with at least 16 GB of memory, NVIDIA driver 580 or newer (the image ships CUDA 13) and the NVIDIA Container Toolkit. Without a GPU, the hosted models (Gemini, Claude, OpenAI, Qwen and Muse Spark) still work, and SAM 3 runs slowly on the CPU.

  • A DNS name that points at the machine, such as gui.example.edu, with ports 80 and 443 reachable by your colleagues. Port 8765 stays closed; only Caddy is exposed.

  • An SMTP relay, if you want email notifications.

One-time setup#

  1. Get the code onto the machine and prepare the folders that will hold imagery and results:

    git clone https://github.com/RAPID-Facility/rAPIdtools.git
    cd rAPIdtools
    sudo mkdir -p /srv/rapidtools/data /srv/rapidtools/output
    sudo chown -R $USER /srv/rapidtools
    
  2. Copy the environment template and fill it in:

    cp deploy/.env.example deploy/.env
    python -c "import secrets; print(secrets.token_urlsafe(18))"   # a token
    nano deploy/.env
    

    RAPIDTOOLS_DOMAIN is the DNS name, RAPIDTOOLS_GUI_TOKEN the secret colleagues must present, DATA_DIR and OUTPUT_DIR the two folders above. Fill the RAPIDTOOLS_SMTP_* lines to enable email notifications; leave them empty otherwise. On a machine without a GPU uncomment the two CPU lines at the end.

  3. Start it. With a GPU:

    docker compose -f deploy/docker-compose.yml -f deploy/docker-compose.gpu.yml \
        --env-file deploy/.env up -d
    

    Without one:

    docker compose -f deploy/docker-compose.yml --env-file deploy/.env up -d
    

    This pulls the prebuilt image of the latest release from the GitHub Container Registry. The CUDA image is several gigabytes, a few minutes on a fast connection. docker compose logs -f gui shows the server starting. The first request builds the RAPID route database from Mapillary, which takes two to three minutes; after that it is cached in the rapidtools-cache volume.

  4. Open https://<domain>/?token=<your token> and check that the map loads. That link is what you send to colleagues; the token can also be typed on the sign-in page.

Day to day#

Sharing

Everyone shares one workspace and one job queue. One detection or inference runs at a time, and a second person’s request is refused until it finishes. If your team needs to run analyses at the same time, add a second GUI service on another port to the compose file, with its own token, and route to it in the Caddyfile under a second path or name.

Files

Imagery that colleagues load must be under DATA_DIR, since the file browser cannot leave it. Results, crops and downloaded basemaps go to OUTPUT_DIR. Both are ordinary folders on the host, so copy files in and out as usual. Model weights and the route database live in the rapidtools-cache volume, so a restart does not download them again.

Notifications

With the SMTP lines filled in, users can ask for an email when a long run ends. Webhooks (Slack, Teams) need no setup, and browser alerts work because the site is served over HTTPS. Links in messages use RAPIDTOOLS_PUBLIC_URL, which the compose file sets to the domain.

Updating

Run docker compose ... pull, then the same up -d command with the same -f and --env-file options. A restart clears the loaded image and assets from memory but keeps every result file.

Rotating the token

Change it in deploy/.env and restart the gui service.

The published images#

Each release publishes two images, built from deploy/Dockerfile, to the GitHub Container Registry. The repository is public, so you can pull them without an account.

Image

Contents

ghcr.io/rapid-facility/rapidtools-gui:latest

CUDA build on the PyTorch 2.15 runtime base (CUDA 13.2); also tagged with the version (0.3.0, 0.3)

ghcr.io/rapid-facility/rapidtools-gui:latest-cpu

CPU-only build (0.3.0-cpu, 0.3-cpu)

RAPIDTOOLS_IMAGE in deploy/.env selects the image. Pin a version tag there if you want to decide when the server moves to a new release, and use the -cpu tag on a machine without a GPU. For a quick look on a workstation, the image also runs on its own, without Caddy:

docker run --rm --gpus all -p 8765:8765 \
    -e RAPIDTOOLS_GUI_TOKEN=<token> \
    -v /path/to/imagery:/data -v /path/to/results:/output \
    ghcr.io/rapid-facility/rapidtools-gui:latest

To build the image from a checkout instead, for example to try a change before it is released, add --build to the up -d command; the BASE_IMAGE and TORCH_INDEX lines in .env choose the CPU build.

A Windows machine in the lab#

On a Windows workstation that colleagues reach over the local network, you can skip Docker and Caddy. Run the console script in a conda environment, keep it alive with Task Scheduler, and open the port in the Windows firewall.

  1. Install, in an Anaconda Prompt (the CUDA build of PyTorch is picked up automatically on a machine with an NVIDIA driver):

    conda create -n rapidtools python=3.11 -y
    conda activate rapidtools
    pip install "git+https://github.com/RAPID-Facility/rAPIdtools.git@main"
    mkdir D:\rapidtools\data D:\rapidtools\output
    
  2. Try it once by hand, with a token you generate:

    python -c "import secrets; print(secrets.token_urlsafe(18))"
    set RAPIDTOOLS_GUI_TOKEN=<paste the token>
    rapidtools-gui --host 0.0.0.0 --port 8765 --no-browser ^
        --data-root D:\rapidtools\data --output-dir D:\rapidtools\output
    

    The window prints share links such as http://LAB-PC-07:8765/?token=... using the machine name and its LAN address. Open one from another computer on the network to check it works. The first request builds the RAPID route database from Mapillary (two to three minutes, then cached under %USERPROFILE%\.cache\rapidtools).

  3. Open the port: in Windows Defender Firewall with Advanced Security add an inbound rule for TCP port 8765, restricted to the Domain and Private profiles so it is not reachable from a public network, or in an administrator prompt:

    netsh advfirewall firewall add rule name="rapidtools GUI" dir=in action=allow protocol=TCP localport=8765 profile=domain,private
    
  4. Keep it running: save a batch file such as D:\rapidtools\start-gui.bat:

    @echo off
    call %USERPROFILE%\anaconda3\Scripts\activate.bat rapidtools
    set RAPIDTOOLS_GUI_TOKEN=<token>
    set RAPIDTOOLS_SMTP_HOST=smtp.example.edu
    set RAPIDTOOLS_SMTP_USER=me@example.edu
    set RAPIDTOOLS_SMTP_PASSWORD=<password>
    set RAPIDTOOLS_SMTP_FROM=me@example.edu
    rapidtools-gui --host 0.0.0.0 --port 8765 --no-browser --data-root D:\rapidtools\data --output-dir D:\rapidtools\output >> D:\rapidtools\gui.log 2>&1
    

    then in Task Scheduler create a task that runs it At startup (or At log on), with Run whether user is logged on or not and Restart the task if it fails enabled. Under Power Options set the machine never to sleep, or the server disappears with it. The SMTP lines are optional.

Notes for this setup:

  • Colleagues connect over plain HTTP on the intranet. The token still protects the app, but browser alerts need HTTPS, so users get email or webhook notifications instead. To add HTTPS, install the Windows build of Caddy with a Caddyfile of LAB-PC-07 { tls internal reverse_proxy 127.0.0.1:8765 }; colleagues then trust Caddy’s local certificate once.

  • Paths in the GUI are Windows paths under the data folder, for example D:\rapidtools\data\eaton\ortho.tif. Colleagues can drop files in through a network share of that folder.

  • One job at a time, as on any other server. The GPU is shared with whatever else runs on the workstation, so close other GPU work before large inference runs.

Running without Docker#

The container only wraps the console script. On a machine where you would rather use a conda environment, install the package and run:

RAPIDTOOLS_GUI_TOKEN=<token> RAPIDTOOLS_SMTP_HOST=... rapidtools-gui \
    --host 127.0.0.1 --port 8765 --no-browser \
    --data-root /srv/rapidtools/data --output-dir /srv/rapidtools/output \
    --public-url https://gui.example.edu/

then point Caddy or nginx at 127.0.0.1:8765 for HTTPS. A systemd unit with Restart=always keeps it up across reboots.

On a cloud machine#

On AWS, Deploying on AWS sets up everything (the machine, an HTTPS address, the access token, idle shutdown and a wake link) from one CloudFormation template, with step-by-step instructions. On another cloud, follow the steps above on a GPU instance with a static address and a persistent disk, and install deploy/idle-shutdown.sh as a cron job so the machine stops itself when nobody is using it.

Security notes#

The token is the only protection, and everyone shares it. Serve the site over HTTPS only (the compose setup does), keep port 8765 closed, rotate the token when someone leaves, and keep the address on your institution’s network or a VPN if you can. API keys pasted into the page are sent to the server for the length of a job and are not stored.