Use the BSB Image

Service images should extend the official BSB Node image. The base image already contains @bsb/base, the core config/events/observable plugins, and bundled @bsb/config-vault.

FROM code.bettercorp.dev/bettercorp/service-base:node

WORKDIR /app
COPY package*.json ./
RUN npm ci

COPY . .
RUN npm run build

RUN node /home/bsb/node_modules/@bsb/base/lib/scripts/list-plugin-search-paths.js

Build Command

Your project npm run build should call bsb-plugin-cli build. That build step extracts schemas, generates clients, runs hooks, validates source restrictions, compiles TypeScript, copies assets, writes schemas, and writes BSB metadata.

{
  "scripts": {
    "build": "bsb-plugin-cli build"
  }
}
Do not replace the BSB build. Plain tsc, node scripts/build.js, tsx, or ts-node bypasses BSB schema extraction, generated clients, hooks, copied assets, and metadata generation.

Self-Contained Plugins

Each plugin package should be self-contained. Keep plugin schemas, static assets, generated clients, and runtime files inside the package that owns the plugin. Other packages can reference the built plugin client or schema output, but should not require shared source files from another plugin package at runtime.

Build-Time Checks

After copying or installing plugins in a derived image, print the BSB package search report. It shows package names, versions, plugin ids, plugin types, paths, schema metadata, and config snippets.

RUN node /home/bsb/node_modules/@bsb/base/lib/scripts/list-plugin-search-paths.js

Do Not Restate Runtime Defaults

The official BSB Node image already sets the standard runtime defaults. Only override these when you intentionally need different behavior.

NODE_ENV=production
BSB_CONTAINER=true
BSB_LIVE=true
BSB_PLUGIN_DIRS=/mnt/plugins

Secrets

If the build needs private npm packages, pass credentials through CI/build secrets. Do not bake npm tokens, registry tokens, Vault API secrets, or deployment config into the final image. Runtime config belongs in deployment env, mounted config, or Vault.

Deployment is separate

This page covers building a service image. For production runtime config, writable volumes, Vault keys, and Compose examples, use Production Deployment.