DocsBun

Bun

Deploy a Bun app on Ruust: fast installs with `bun install`, served on HTTPS with no cold starts.

Ruust hands your repo to Nixpacks, whose Bun provider recognises the app from a bun.lockb (or bun.lock) file at the repo root, runs bun install and then your start command (what runs depends on the Nixpacks version on the build host). If you would rather control the build yourself, add a Dockerfile and Ruust builds that instead (in which case Nixpacks is not involved). Either way the result is a long-running Egg, always on, with no cold starts, so Bun.serve handles server-side rendering, background work and websockets without waking up first.

Deploy it

  1. Commit your bun.lockb (or bun.lock) so installs are reproducible.
  2. Add a Procfile with a web: line (see below) and push to a Git repo.
  3. In the dashboard, choose New Egg and connect the repo.
  4. Pick a size and a region (London or Virginia), then lay the Egg.
  5. Watch it incubate (build), hatch (deploy) and go hatched (live).

The port

This is the one thing to get right. Ruust sets a PORT env var and your app must listen on it and bind to 0.0.0.0, not localhost. Bun.serve binds to 0.0.0.0 by default, but pass hostname explicitly to be safe, and always read port from the environment. Binding to localhost or a hard-coded port is the top reason an Egg builds but never hatches.

typescript
Bun.serve({
  port: Number(process.env.PORT),
  hostname: '0.0.0.0',
  fetch(req) {
    return new Response('Hatched on Ruust');
  },
});
Read PORT from the environment and bind to 0.0.0.0.

Start command

Set the start command with a Procfile at the repo root. On the Nixpacks path its web: line is read by Nixpacks during the build and baked into the image as the start command; Ruust itself does not parse the Procfile, and the line is ignored when you supply your own Dockerfile. Bun runs TypeScript directly, so bun index.ts needs no build step. Point the line at a start script in package.json (web: bun run start) or run the entry file directly.

text
web: bun index.ts
Procfile at the repo root.

Environment variables

Set env vars on the Egg. They are available at both build and run time, encrypted at rest and never printed in logs. Bun reads them from process.env (or Bun.env) with no extra library. A value read at build time is baked into the image, so read per-deploy config such as database URLs at run time.