Build & Deployment
CrumbJS projects can be compiled into a single production-ready binary using Bun.
The default template also provides a Dockerfile to easily containerize your app.
Build script
You can use the included script to build your project:
bun run build
This is equivalent to running:
bun build \
--compile \
--minify-whitespace \
--minify-syntax \
--target bun \
--outfile server \
./src/index.ts
The result is a compact binary (server) ready for production.
Docker Support
The create-crumbjs template includes a Dockerfile that compiles your project into a binary and packages it into a lightweight container image.
FROM oven/bun AS build
WORKDIR /app
# Cache packages installation
COPY package.json package.json
COPY bun.lock bun.lock
RUN bun install
COPY ./src ./src
ENV NODE_ENV=production
RUN bun build \
--compile \
--minify-whitespace \
--minify-syntax \
--target bun \
--outfile server \
./src/index.ts
FROM gcr.io/distroless/base
WORKDIR /app
COPY --from=build /app/server server
ENV NODE_ENV=production
CMD ["./server"]
EXPOSE 8080
With this setup, you can build and run your containerized CrumbJS app:
docker build -t crumbjs-app .
docker run -p 8080:8080 crumbjs-app