Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to main content
Open console

Bun

A Node.js project run by Bun instead of Node, chosen when it is ordered or with one line in vallic.yaml

3 min read

Bun runs a Node.js project in Node's place: the same project type, port and node_modules in the release, with Bun as the runtime and the package manager. It serves its own HTTP (Bun.serve, Hono, Elysia, Next.js or anything else that listens on a port) and replaces PHP-FPM and nginx, as Node does.

Choosing Bun

In vallic.yaml, write bun: with its version under runtime, in place of node:. The project stays a Node.js project, type: nodejs; to go back to Node, write node: there again. The deploy that changes it builds the release in the new image and replaces the container.

You can also choose Bun when the project is ordered, as what a Node.js application runs on. The suggested vallic.yaml then names bun:, and a repository that names neither runs on Bun. The repository comes first: node: under runtime is Node.js, whatever was chosen when the project was ordered.

To run one beside a backend in another language, see Multi app (beta).

The container

The container runs as vallic. The release is at /var/www/html/current (WEB_ROOT), read-only, with its own node_modules/.bin on PATH. node answers as Bun for scripts whose first line asks for node.

Bun.sql connects to DATABASE_URL when it is given no other address, and the platform sets that for the environment's database.

A Bun project

vallic.yaml at the root of the repository:

version: 1
type: nodejs

runtime:
  bun: '1.4'

build:
  steps:
    - name: Dependencies
      run: bun install --frozen-lockfile
    - name: Production dependencies only
      run: rm -rf node_modules && bun install --frozen-lockfile --production
  cache:
    - node_modules

start: bun index.ts
port: 3000

health:
  path: /
  timeout: 30

Bun.serve listens on PORT when it is given no port, and on every address, so a server written without either needs no port here. Left out, start is bun run start: the start script in your package.json.

Bun's download cache is kept between builds. Bun has no prune, so the last step installs again with --production into an empty node_modules: the release keeps only what production needs. A project with no dependencies has no lockfile and needs no build.

Write uploads and anything else created at runtime under /mnt/files (VALLIC_PUBLIC_DIR, VALLIC_PRIVATE_DIR), which outlives the release; the release itself is read-only. Set environment variables on the environment in the console; they reach the process as ordinary environment variables. Bun also reads .env files from the release, but keep anything secret in the console, not in the repository.

Versions

Version Status
1.4 Supported, and the default
1.3 Supported

Pin the version, not the build: name 1.4 and the platform matches it to the current build, so a security rebuild reaches you without anybody editing a repository.

What you can change

In vallic.yaml — what each one does is on Service settings:

services:
  - bun:
      version: '1.4'
      environment:
        BUN_OPTIONS: …
        BUN_CONFIG_MAX_HTTP_REQUESTS: …

Anything not on this list refuses the deploy, naming the variable — rather than being accepted and quietly ignored.

Need a hand?

Open a ticket from Support in the console. We answer on the ticket.

Open the console How support works