Skip to content

Request: Official Dockerfile for Next.js running on Bun Runtime #1

@kaanmertkoc

Description

@kaanmertkoc

First of all, thank you for making a great package manager like Bun and providing this example repository! It has been a game-changer for my workflow.

I would like to request an official reference Dockerfile for this template that correctly handles the Next.js build and runtime using Bun.

As a developer, I have successfully containerized pure backend applications with Bun without issues. However, getting Next.js to play well with the Bun runtime inside Docker has been a significant struggle.

I have attempted various configurations across different infrastructure providers (VPS, standard Docker runners), but I consistently run into friction between:

  1. The Vercel/Next.js build output: Which is heavily optimized for Node.js.
  2. The Bun Runtime: Trying to run the Next.js standalone output or standard build artifacts often leads to obscure errors regarding missing dependencies, sharp/image optimization glibc issues, or entry point mismatches (server.js vs bun start).

I am looking for a "Golden Path" Dockerfile added to this repo that demonstrates the Bun team's recommended way to:

  1. Install dependencies using bun install.
  2. Build the Next.js app (bun run build) specifically for a containerized environment.
  3. Crucially: Serve the application in production using the bun runtime (not falling back to node), ensuring next.config.ts and environment variables are respected.

Currently, most community resources or Vercel documentation assume a Node.js runtime for the final container. Having an official example here would solve a lot of headaches for developers trying to move their full-stack Next.js stack entirely to Bun.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions