Bunjs Docker Starter Kit
- From Bunjs Documentation:
- Web APIs like
fetch
,WebSocket
, andReadableStream
are built-in node_modules
bun implements Node.js' module resolution algorithm, so you can usenpm
packages in Bun.ESM
andCommonJS
are supported, but Bun internally usesESM
- In Bun, every file is transpiled.
TypeScript
&JSX
just work - Bun supports "paths", "jsxImportSource"and more from
tsconfig.json
files - Bun.Transpiler Bun's
JSX
&TypeScript
transpiler is available as an API in Bun - use the fastest system calls available with Bun.write to write, copy, pipe, send and clone files
- Bun automatically loads environment variables from
.env
files. No more require("dotenv").config() - Bun ships with a fast
SQLite3
client built-inbun:sqlite
- Node-API Bun implements most of Node-API (N-API). Many Node.js native modules just work
bun:ffi
call native code from JavaScript with Bun's low-overhead foreign function interfacenode:fs
node:path Bun natively supports a growing list of Node.js core modules along with globals like Buffer and process
- Docker desktop
- Clone the repo and run
cd bunjs-docker-starter
. - Run the following command:
docker compose up --build, and optionally add
-d` to run as a daemon. - Go to http://localhost:3000 to view the server response
Welcome to Bun!
.
- In the
server
directory, there are 2 versions of theDockerfile
:Dockerfile
andDockerfile.custom
.Dockerfile.custom
uses the latest stable version of Ubuntu and custom builds the packages, roles needed to run bunjs.- To use this
Dockerfile.custom
, just update thedocker-compose.yml
file to use this file by replacing as follows:dockerfile: Dockerfile.custom
.