New apps start in the server’s default mode,
screenshot, which you can change with the runtime setting preview.default_mode (metadata or screenshot). A per-app choice always wins.
When a screenshot renders
- Only web and static apps that serve a page render. API, worker, cron and database apps never do: their cards are type specific.
- A render is queued in the background when an app’s card is first listed without a screenshot, and when a new release goes live. It is never done while a request waits, and at most one render is queued per app.
- Renders are rate limited per app by
preview.min_interval_seconds(default one hour), so a burst of redeploys costs one render. A manual recapture ignores the limit. - Only
preview.max_concurrentrenders run at once (default 1). - If the app is not running, answers an error, shows a login or times out, the card shows a quiet text card and the render is not retried in a loop. It tries again on the next deploy, or when you recapture.
- The list API reports
preview.statefor each web or static app:none,queued,rendering,readyorfailed(with areason). The dashboard shows a skeleton while a render is queued or running. - An app on another node is rendered through its public address (its first domain) from the control plane, when it has one. The address goes through the same outbound guard as webhooks: internal addresses are refused, and the host name is pinned to the address that was checked. Without a public address the card says
remote_node.
Memory cost and how to turn it off
The headless browser is started on demand and stoppedpreview.idle_stop_seconds (default 120) after the last render, so nothing sits in memory between bursts. While running it is capped by preview.browser_memory_mb (default 512) and preview.browser_cpu_millis (default 1000). Set preview.idle_stop_seconds to 0 to stop it right after each render.
To turn real renders off, set preview.default_mode to metadata (no browser, ever), or set an app to off. APP_PREVIEW_ENABLED=false switches the whole feature off.
Choose a mode
- UI
- CLI
Open the app, then Deploy settings, then Deploy previews, and pick a mode.
preview enable without --mode means screenshot, as enabled: true always did. The next successful deploy gets a thumbnail. Recapture in deploy history (or levelrail-cli preview capture) redoes the current release on demand. Each thumbnail carries a badge saying where it came from: Screenshot, Site image or Card.
What the metadata mode does
- Requests the configured path (default
/) on the app itself, through the app’s published loopback port, the same route the ingress uses. It never contacts the public internet for the page, and you never supply a URL, only a path. - Sends no cookies or credentials. A 401 or 403, or a redirect to a login page, is recorded as skipped with a reason. Redirects that leave the app are refused, and at most 3 are followed.
- Reads at most 512 KB of HTML with a real HTML tokenizer and keeps the title,
og:title,og:description,og:image,twitter:image,theme-colorand icon links. - If there is an
og:image(ortwitter:image), it is resolved against the page, must be anhttporhttpsURL, and is downloaded through the same outbound guard the webhooks use: loopback, private, link-local and metadata-service addresses are refused at connect time, including after redirects. The app’s own origin and its own domains are read from the app itself. Limit 2 MB. - JPEG and PNG images are supported. The image is decoded, scaled down to fit 640 by 400 (never up) and centered on a neutral background, then stored as a JPEG. Images under 120 pixels on a side and single-color images are rejected.
- When there is no usable image, the preview is a card: the deploy history composes it from the page title, description and theme color, with the app name and commit. A card stores about 100 bytes of text and no image file.
What a screenshot capture does
- Pulls the browser image the first time it is needed (
docker.io/chromedp/headless-shell, pinned to a version, about 140 MB compressed). - Starts one container with a 512 MB memory cap, 1 CPU, a read-only root filesystem, a small tmpfs, all capabilities dropped, a non-root user and a process limit.
- Attaches it to the app’s own Docker network and nothing else. It reaches the app by service name and port. You never supply a URL, only a path on the app.
- Loads the page at 1280x800 without cookies or credentials, waits for the page to settle (at most about 10 seconds), takes a screenshot, and stops the container. The whole capture has a 30 second limit.
- Shrinks the screenshot to a 640 pixel wide JPEG, usually 20 to 60 KB.
Cost
Screenshot captures are skipped, with the reason recorded, when the host has less than 768 MB of free memory or less than 2 GB of free disk. The metadata mode is not gated on either, because it needs neither.
To use a different browser image, point
APP_PREVIEW_IMAGE at it. It must expose the DevTools port on 9222 like headless-shell does.
Privacy
A preview is a picture of what the app served, so treat it like the app.- Screenshots are the default for web and static apps. If you prefer that nothing renders a browser, set
preview.default_modetometadata, which reads only the public head of your page and at most one image the page itself names. - Internal pages can leak. If the path you pick shows internal data to anyone who can reach the app, the thumbnail shows it too. Pick a public page, such as
/. - The browser never logs in. It sends no cookies and no tokens, and a 401 or 403, or a redirect to a login page, is recorded as skipped with no image stored.
- The image has the same access as the app. It is served only to people who can read the app, through the authenticated API. It is never public and never appears on the public status page.
- This is not a sandbox for hostile apps. The page is loaded by a real browser next to the app. The container limits above contain a browser bug, but only capture apps you run.
- The browser’s debugging port is published on the host loopback interface for the length of a capture, on a random port, so other processes on the host can reach it during that window.
What is skipped
The deploy history shows a “No preview” note with the reason when a capture does not produce an image:
Any of these also appears as the
reason of a failed card state. A failed recapture never replaces a preview that already exists (image or card), and a card never replaces a site image or screenshot.
How cards load
The apps list never loads your sites live.GET /api/v1/apps carries each app’s latest thumbnail URL (or card text) and its render state in a preview field, so one request describes every card. A card fetches its image only once it scrolls into view. The image URL carries the capture version, and the server answers it with an ETag, Cache-Control: private, max-age=31536000, immutable (with ?v=) and Range support, so the browser downloads each deploy’s thumbnail once. If the image is missing the card shows the text card, then a plain placeholder. Thumbnails stay JPEG.
Retention and cleanup
These rules apply to every source alike: screenshots, site images and cards.- The newest 5 previews of each app are kept, plus the preview of the release now serving.
- Previews older than 30 days are deleted, except the live release’s.
- If all previews together pass 200 MB, the least recently viewed go first.
- Previews are deleted when the app is deleted.
- Every capture container carries a role label. On startup and every hour, any older than twice the capture timeout (left by a crash) is removed.
- The browser image is removed after 14 idle days, or at the next cleanup pass once the server switch is off, but only if this control plane pulled it and no container uses it. An image you pulled yourself is never touched.
- Prune now (or
levelrail-cli preview prune <app>) applies these rules immediately.--alldeletes every preview of the app.
Settings
The render settings are runtime settings: change them in Settings, withlevelrail-cli settings set <key> <value> or through the API, and they apply to the next render without a restart. The environment variable only seeds the default. See the runtime settings reference.
The variables below are read at start, and unset or malformed values fall back to the default.
API
Reading needs the app read ability. Changing settings, capturing and pruning need write.
GET /api/v1/apps/{name}/deploy-attempts includes preview_image_url on each attempt that has a thumbnail.
Limits
- Apps on other nodes render through their public address only, with no agent change. Without one they are skipped.
- Screenshots skip apps without a per-app network or a declared port. Metadata needs only a running container with a published port.
- WebP and other formats are not decoded for site images, only JPEG and PNG.
- The page is requested by service name, so an app that routes by
Hostheader shows its default site. - Only the viewport is captured, not the full page. Cookie banners and late-loading content appear as the app renders them.