### Basic Dockerfile Usage with Bun Node Source: https://context7.com/imbios/bun-node/llms.txt A foundational Dockerfile example for a Node.js/Bun application. It utilizes the `imbios/bun-node` image, sets up the working directory, installs dependencies using `bun install`, copies application code, builds the project, and defines the start command. ```dockerfile # Use the official bun-node image FROM imbios/bun-node:latest-22-alpine # Set the working directory WORKDIR /app # Copy package files first for better layer caching COPY package.json bun.lockb ./ # Install dependencies using Bun (faster than npm/yarn) RUN bun install --frozen-lockfile # Copy application source code COPY . . # Build the application RUN bun run build # Expose the application port EXPOSE 3000 # Start the application with Bun CMD ["bun", "run", "start"] ``` -------------------------------- ### Running Bun Node Containers Source: https://context7.com/imbios/bun-node/llms.txt Shows how to run Docker containers based on the Bun Node images. Includes examples for interactive REPL sessions, running scripts, installing dependencies, executing shell commands, and explicitly starting with Node.js. ```bash # Run Bun REPL interactively docker run -it --rm imbios/bun-node:latest # Run a JavaScript file with Bun docker run -it --rm -v $(pwd):/home/bun/app imbios/bun-node:latest run index.ts # Run Bun install in current directory docker run -it --rm -v $(pwd):/home/bun/app imbios/bun-node:latest install # Execute a shell command in the container docker run -it --rm imbios/bun-node:latest /bin/sh -c "bun --version && node --version" # Start with Node.js instead of Bun docker run -it --rm imbios/bun-node:latest node --version ``` -------------------------------- ### Frontend Integration with HTML and React Source: https://github.com/imbios/bun-node/blob/main/CLAUDE.md Shows how to serve HTML files that directly import React components and CSS, leveraging Bun's built-in bundler. ```html

Hello, world!

``` ```tsx import React from "react"; import './index.css'; import { createRoot } from "react-dom/client"; const root = createRoot(document.body); export default function Frontend() { return

Hello, world!

; } root.render(); ``` -------------------------------- ### Remix Application Start Command (Node.js) Source: https://context7.com/imbios/bun-node/llms.txt This snippet shows the Docker CMD instruction to start a Remix application using bun run start. It assumes the application is configured to use the Node.js runtime and Bun for execution. ```dockerfile CMD ["bun", "run", "start"] ``` -------------------------------- ### Run Bun Tests Source: https://github.com/imbios/bun-node/blob/main/CLAUDE.md Demonstrates how to write and execute unit tests using the built-in bun:test module, replacing Jest or Vitest. ```typescript import { test, expect } from "bun:test"; test("hello world", () => { expect(1).toBe(1); }); ``` -------------------------------- ### Create Web Server with Bun.serve Source: https://github.com/imbios/bun-node/blob/main/CLAUDE.md Demonstrates setting up a web server using Bun's native API, which supports routing, WebSockets, and HMR without external dependencies like Express. ```typescript import index from "./index.html" Bun.serve({ routes: { "/": index, "/api/users/:id": { GET: (req) => { return new Response(JSON.stringify({ id: req.params.id })); }, }, }, websocket: { open: (ws) => { ws.send("Hello, world!"); }, message: (ws, message) => { ws.send(message); }, close: (ws) => {} }, development: { hmr: true, console: true, } }) ``` -------------------------------- ### Execute Bun with Hot Reloading Source: https://github.com/imbios/bun-node/blob/main/CLAUDE.md Command-line instruction to run a Bun server with hot module replacement enabled. ```bash bun --hot ./index.ts ``` -------------------------------- ### Run Next.js Development Server Source: https://github.com/imbios/bun-node/blob/main/examples/next/default-app-dir/README.md Commands to start the local development server for the Next.js application. Supports multiple package managers including npm, yarn, pnpm, and bun. ```bash npm run dev yarn dev pnpm dev bun dev ``` -------------------------------- ### Custom Image Building Commands Source: https://context7.com/imbios/bun-node/llms.txt Shell commands to build custom Docker images from the repository source. Includes examples for specific versions, Alpine/Debian variants, and multi-platform builds using buildx. ```bash docker build --build-arg BUN_VERSION=latest -t my-bun-node:22-alpine ./src/base/22/alpine docker build --build-arg BUN_VERSION=1.1.0 -t my-bun-node:1.1.0-22-debian ./src/base/22/debian docker build --build-arg BUN_VERSION=latest -t my-bun-node:22-alpine-git ./src/git/22/alpine docker buildx build --platform linux/amd64,linux/arm64 --build-arg BUN_VERSION=latest -t my-bun-node:22-alpine ./src/base/22/alpine ``` -------------------------------- ### Environment Variable Configuration Source: https://context7.com/imbios/bun-node/llms.txt Demonstrates how to configure Bun runtime behavior using environment variables within a Dockerfile. Settings include cache paths, binary installation paths, and Node environment modes. ```dockerfile FROM imbios/bun-node:latest-22-alpine ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=/tmp/bun-cache ENV BUN_INSTALL_BIN=/usr/local/bin ENV NODE_ENV=production WORKDIR /app ``` -------------------------------- ### Docker Compose Development Configuration Source: https://context7.com/imbios/bun-node/llms.txt Configures a development environment with volume mounting for hot reloading and environment variable support. Includes a secondary service example for CI/CD operations. ```yaml version: '3.8' services: app: image: imbios/bun-node:latest-22-alpine working_dir: /home/bun/app volumes: - .:/home/bun/app - node_modules:/home/bun/app/node_modules ports: - "3000:3000" environment: - NODE_ENV=development - BUN_RUNTIME_TRANSPILER_CACHE_PATH=/tmp/bun-cache command: bun run dev ci: image: imbios/bun-node:latest-22-alpine-git working_dir: /home/bun/app volumes: - .:/home/bun/app command: | sh -c "bun install && bun test && bun run build" volumes: node_modules: ``` -------------------------------- ### Remix Application Package.json Configuration (Node.js) Source: https://context7.com/imbios/bun-node/llms.txt This JSON snippet defines the package.json configuration for a Remix application. It includes scripts for building, developing, and starting the application, along with essential dependencies for Remix and React, all intended to run within a Node.js environment. ```json { "name": "remix-app", "type": "module", "scripts": { "build": "remix build", "dev": "remix dev --manual", "start": "remix-serve ./build/index.js" }, "dependencies": { "@remix-run/node": "^2.3.1", "@remix-run/react": "^2.3.1", "@remix-run/serve": "^2.3.1", "react": "^18.2.0", "react-dom": "^18.2.0" } } ``` -------------------------------- ### Remix Application Docker Configuration Source: https://context7.com/imbios/bun-node/llms.txt A specialized Dockerfile for deploying Remix applications. It uses Bun for dependency installation and build processes while maintaining compatibility with the Node.js runtime. ```dockerfile FROM imbios/bun-node:latest WORKDIR /app COPY package.json bun.lockb ./ RUN bun install COPY . . RUN bun run build EXPOSE 3000 ``` -------------------------------- ### Pulling Bun Node Docker Images Source: https://context7.com/imbios/bun-node/llms.txt Demonstrates how to pull pre-configured Docker images from Docker Hub. Supports various tags for specific Bun, Node.js, and build type combinations, including optional Git installation for Alpine images. ```bash # Pull the default latest image (Bun latest + Node.js 20 + Debian) docker pull imbios/bun-node:latest # Pull specific version combinations docker pull imbios/bun-node:1.1.0-22-alpine docker pull imbios/bun-node:latest-20-slim docker pull imbios/bun-node:canary-24-debian # Pull using Node.js codename docker pull imbios/bun-node:latest-iron-alpine # Pull Alpine image with Git pre-installed docker pull imbios/bun-node:latest-22-alpine-git ``` -------------------------------- ### Multi-stage Docker Build for Bun Applications Source: https://context7.com/imbios/bun-node/llms.txt A production-ready Dockerfile using multi-stage builds to minimize image size. It separates the build environment from the runtime environment and runs the application as a non-root user. ```dockerfile # Build stage FROM imbios/bun-node:latest-22-debian AS builder WORKDIR /app COPY package.json bun.lockb ./ RUN bun install --frozen-lockfile COPY . . RUN bun run build # Production stage - use slim image for smaller footprint FROM imbios/bun-node:latest-22-slim AS production WORKDIR /app # Copy only production dependencies COPY package.json bun.lockb ./ RUN bun install --frozen-lockfile --production # Copy built artifacts from builder stage COPY --from=builder /app/dist ./dist COPY --from=builder /app/public ./public # Run as non-root user for security USER bun EXPOSE 3000 CMD ["bun", "run", "dist/server.js"] ``` -------------------------------- ### Next.js Application Dockerfile with Bun Node Source: https://context7.com/imbios/bun-node/llms.txt Illustrates a Dockerfile for deploying a Next.js application using the `imbios/bun-node` image. It configures Bun for package management and build processes while ensuring compatibility with Node.js runtime requirements for Next.js. ```dockerfile FROM imbios/bun-node:latest WORKDIR /app # Copy dependency files COPY package.json bun.lockb ./ # Install dependencies with Bun RUN bun install # Copy the entire application COPY . . # Build the Next.js application RUN bun run build # Expose Next.js default port EXPOSE 3000 # Start the Next.js production server CMD ["bun", "run", "start"] ``` -------------------------------- ### CI/CD Pipeline Integration with GitHub Actions Source: https://context7.com/imbios/bun-node/llms.txt A GitHub Actions workflow configuration for testing and building applications inside a containerized environment. It utilizes the Alpine-Git variant to support repository cloning and dependency management. ```yaml name: Test on: [push, pull_request] jobs: test: runs-on: ubuntu-latest container: image: imbios/bun-node:latest-22-alpine-git steps: - uses: actions/checkout@v4 - name: Install dependencies run: bun install --frozen-lockfile - name: Run linting run: bun run lint - name: Run tests run: bun test - name: Build application run: bun run build ``` -------------------------------- ### Version Checking Utility Script Source: https://context7.com/imbios/bun-node/llms.txt Executes a TypeScript utility to verify the latest available versions of Bun and Node.js. Useful for maintaining automated release workflows. ```bash bun run check-bun-node.ts --bun canary,latest bun run check-bun-node.ts --node 20,22,24,25 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.