Hot Cell
Process untrusted uploads in a locked-down Hot Cell container beside your app
Updated
Hot Cell runs risky work, like processing uploaded images and PDFs, in a locked-down container beside your app. Dockerfile clusters run it for you.
Setting it up
Install Hot Cell in your app as its README describes. The installer creates a hotcell/ directory with a Dockerfile. Commit it and deploy.
When your repository has hotcell/ with a Dockerfile, Hatchbox builds it and runs the cell beside your app's containers on every server, wired the way the Hot Cell README describes: no network, a read-only filesystem, its own user, and a socket shared with your app. The cell's image is named after the contents of hotcell/, so it's only rebuilt and restarted when that directory changes.
Hot Cell's Active Storage integration needs Rails 8.2 or newer.
Settings
After the first deploy with a cell, the app's settings show a Hot Cell section under Deploys:
- Name is what your app registers the cell under with
HotCell.register. Hatchbox usesactive_storage, the installer's default, unless you change it. - Memory, 2g by default. Hot Cell's own per-request
memoryinhotcell/config.rbhas a 1 GB floor, so keep the container at or above that. - CPUs, 2 by default. A server with fewer CPUs gives the cell all of its own.
- Scratch space, the cell's writable tmpfs, 512m by default.
Changes apply on the next deploy. The HATCHBOX_HOTCELL_NAME, HATCHBOX_HOTCELL_MEMORY, HATCHBOX_HOTCELL_CPUS, HATCHBOX_HOTCELL_TMPFS_SIZE and HATCHBOX_HOTCELL_PIDS_LIMIT env vars set the same things when a field is blank.
Your app finds the cell under $HOTCELL_ROOT/<name>, which Hatchbox sets.
Turning it off
Set the HATCHBOX_SKIP_HOTCELL env var to true to deploy without the cell.
Sizing your servers
The cell runs on every server with your app's processes, on top of the app's own containers, and its memory limit counts against the server. During a deploy the old and new app containers run side by side too, so leave room for both plus the cell.