Environment Variables

src/start.mjs maps environment variables to start(options).

Before the function project is loaded, BFast resolves application environment values that point to Docker secrets. For example, when a service has a secret mounted as /run/secrets/database-password:

bash
DATABASE_PASSWORD=/run/secrets/database-password

BFast reads that file and exposes its contents through process.env.DATABASE_PASSWORD. The content is preserved exactly, including whitespace and a trailing newline. Create secrets without a trailing newline when that matters.

Only values below /run/secrets/ are resolved. Other absolute paths remain paths. Variables whose names end in _FILE also remain paths, allowing applications and libraries that support the conventional file-based setting to read them directly:

bash
DATABASE_PASSWORD_FILE=/run/secrets/database-password

Startup fails if an automatically resolved secret is missing or unreadable. The error names the environment variable and file path but never logs the secret value.

Supported Variables

Examples

Git mode:

bash
PORT=3000 \
MODE=git \
GIT_CLONE_URL=https://github.com/acme/functions.git \
GIT_USERNAME=acme-bot \
GIT_TOKEN=*** \
node src/start.mjs

NPM mode:

bash
PORT=3000 MODE=npm NPM_TAR=acme-functions node src/start.mjs

Remote tarball mode:

bash
PORT=3000 MODE=url URL_TAR=https://example.com/functions.tgz node src/start.mjs

Custom script mode:

bash
START_SCRIPT="node custom-server.js" node src/start.mjs

Local mode:

bash
PORT=3000 \
MODE=local \
FUNCTIONS_DIR_PATH=./specs/sample_functions \
BFAST_JSON_PATH=./specs/sample_functions/bfast.json \
node src/start.mjs
View source on GitHub ↗ · synced 2026-11-21 13:08 UTC