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:
DATABASE_PASSWORD=/run/secrets/database-passwordBFast 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:
DATABASE_PASSWORD_FILE=/run/secrets/database-passwordStartup 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
PORT(default:3000)MODE(git,npm,url,local; default in starter isgit)GIT_CLONE_URLGIT_USERNAMEGIT_TOKENNPM_TARURL_TARSTART_SCRIPTFUNCTIONS_DIR_PATH(used whenMODE=local)BFAST_JSON_PATH(optional, used whenMODE=local)ASSETS_PATH(optional, used whenMODE=local)BFAST_BODY_LIMIT(JSON/form body size limit; default:2mb)BFAST_ACCESS_LOG(offturns the per-request access log off;dev,combined,common,shortortinypick the format; default:dev)BFAST_SHUTDOWN_TIMEOUT_MS(how long running requests may finish after SIGTERM or SIGINT before the process exits anyway; default:8000, below Docker's 10 s stop wait)BFAST_HEALTHCHECK(set tooffto disable the image health check, for example whenSTART_SCRIPTruns a server that does not serve/functions-healthonPORT)BFAST_RAW_BODY(set totrueto expose the original JSON bytes as a Buffer atrequest.rawBodyfor webhook signature verification; disabled by default)
Examples
Git mode:
PORT=3000 \
MODE=git \
GIT_CLONE_URL=https://github.com/acme/functions.git \
GIT_USERNAME=acme-bot \
GIT_TOKEN=*** \
node src/start.mjsNPM mode:
PORT=3000 MODE=npm NPM_TAR=acme-functions node src/start.mjsRemote tarball mode:
PORT=3000 MODE=url URL_TAR=https://example.com/functions.tgz node src/start.mjsCustom script mode:
START_SCRIPT="node custom-server.js" node src/start.mjsLocal mode:
PORT=3000 \
MODE=local \
FUNCTIONS_DIR_PATH=./specs/sample_functions \
BFAST_JSON_PATH=./specs/sample_functions/bfast.json \
node src/start.mjs