bun-node Docker Images

repository·main·Indexed 41 days ago

https://github.com/imbios/bun-node

Optimized Docker images combining the Bun runtime and package manager with Node.js, allowing Node.js to act as a reliable fallback for Bun features. Available in alpine, debian, and slim build types with support for advanced version tagging of both Bun and Node.js.

Tokens
2.3K
Snippets
13
Records
17
Agent score
52%

What's inside bun-node

  1. Select a Build Type

    main

    The project provides three main build types to suit different environment needs:

    • alpine: A minimal build designed for the smallest possible footprint.
    • debian: A standard build that balances size and available features.
    • slim: A Debian-based build that is lighter than the standard version by stripping unnecessary files.
  2. Opt out of Telemetry

    main

    By default, the image sends one anonymous ping per container start to bun-node.imbios.dev to track version usage. The payload includes Bun/Node.js versions, CPU architecture, and a rotating random ID. To disable this tracking, use one of the following environment variables when running your container:

    # Option 1: Set BUN_NODE_TELEMETRY to 0
    docker run -e BUN_NODE_TELEMETRY=0 imbios/bun-node
    
    # Option 2: Set DO_NOT_TRACK to 1
    docker run -e DO_NOT_TRACK=1 imbios/bun-node
    docker run -e BUN_NODE_TELEMETRY=0 imbios/bun-node
    # or
    docker run -e DO_NOT_TRACK=1 imbios/bun-node
  3. Quick Start with imbios/bun-node

    main

    To use these pre-configured Docker images that combine Bun and Node.js, pull the base image from Docker Hub:

    docker pull imbios/bun-node

    These images allow you to use Bun as a package manager while using Node.js as the runtime (acting as a fallback for features not yet implemented in Bun).

  4. Build and run Remix for production

    main

    To prepare your Remix application for production deployment, follow these two steps:

    1. Build the application: Generate the production assets.
    2. Start the server: Run the application in production mode.

    Note: The built-in Remix app server is production-ready for Node.js environments.

    npm run build
    npm start
  5. Configure Cloudflare Workers via wrangler.config.ts

    main

    The cloudflare.config.ts file defines the deployment configuration for a Cloudflare Worker. It specifies the worker type, entrypoint, compatibility settings, and environment variables (including KV namespaces and secrets).

    export default {
      type: "worker",
      name: "bun-node-stats",
      entrypoint: "src/index.ts",
      compatibilityDate: "2026-01-01",
      compatibilityFlags: ["nodejs_compat"],
      workersDev: false,
      triggers: [{ type: "scheduled", schedule: "0 0 * * *" }],
      env: {
        STATS_KV: { type: "kv", id: "d7b7957fd5648628bfb61baddff65ec" },
        GITHUB_REPO: { type: "text", value: "ImBIOS/bun-node" },
        DOCKER_REPO: { type: "text", value: "imbios/bun-node" },
        PRIVATE_KEY: { type: "secret" },
        SEED_KEY: { type: "secret" },
      },
    };
  6. Configure Environment Variables for the Stats Dashboard

    main

    The statistics dashboard (deployed as a Cloudflare Worker) requires several environment variables to function correctly. These variables control data sources, authentication, and analytics.

    VariableTypeDescription
    STATS_KVKVNamespaceCloudflare KV namespace for storing cached stats and telemetry
    GITHUB_REPOstringThe GitHub repository path (e.g., ImBIOS/bun-node)
    DOCKER_REPOstringThe Docker Hub repository path (e.g., imbios/bun-node)
    PRIVATE_KEYstring (optional)Key used to access the /private dashboard and /internal/seed endpoint
    SEED_KEYstring (optional)Alternative key for the /internal/seed endpoint
    WEB_ANALYTICS_TOKENstring (optional)Cloudflare Web Analytics token for the dashboard
  7. Use Advanced Image Tagging

    main

    You can specify exact versions for Bun and Node.js, along with the desired build type, using the following tag format:

    imbios/bun-node:<bun-version>-<node-version>-<build-type>[optional -git]

    Tag Components:

    • bun-version: A specific version (e.g., 1.0.0, 1.0.30, 1) or a tag (e.g., latest, canary).
    • node-version: A specific version (e.g., 18, 20.11, 21.7.1) or a tag (e.g., hydrogen, iron, current).
    • build-type: One of alpine, debian, or slim.
    • -git (optional): Appending -git to an alpine image installs git within the container.
    imbios/bun-node:<bun-version>-<node-version>-<build-type>[optional -git]
  8. Use the `/api/stats` endpoint to fetch JSON statistics

    main

    The /api/stats endpoint returns a JSON snapshot of the current Docker and GitHub metrics. It uses a cache-control header with a TTL of 120 seconds.

    Response Schema:

    {
      "docker": {
        "pulls": number | null,
        "stars": number | null,
        "tags": number | null,
        "lastUpdated": string | null
      },
      "github": {
        "stars": number | null,
        "forks": number | null,
        "openIssues": number | null,
        "pushedAt": string | null
      }
    }
    GET /api/stats