business

Verdict

Submitted 7/12/2026, 2:06:49 AM · Completed 7/12/2026, 2:24:47 AM

5.2
pivot
The idea

How should I build a Docker image for a single app in a Turborepo that uses Bun workspaces and shared packages?

Pain point
The user needs to build a Docker image for only the 'api' app in a Turborepo while avoiding unnecessary workspace copies and ensuring proper package resolution.
Who has this problem
Developers working with Turborepos and Docker in a monorepo setup using Bun workspaces.
Contradiction (TRIZ)
Wants to build a minimal Docker image but must include all workspaces for package resolution.
Ideal final result
A method to selectively copy only the necessary workspace dependencies into the Docker build context without compromising package resolution or installation.
Suggested solution
Utilize a tool like `turbo prune --docker` which can generate a minimal Docker image by pruning unused workspaces and their dependencies, ensuring that only the 'api' app's necessary packages are included in the build context. This approach allows for a more efficient and targeted Docker image without manually copying each workspace.
Show original source text →
I'm using a Turborepo with Bun workspaces. My repository structure looks like this: architecture-web/ ├── apps/ │ ├── api │ ├── admin │ └── public ├── packages/ │ ├── db │ ├── typescript-config │ ├── ui │ └── eslint-config ├── package.json ├── bun.lock └── turbo.json The API depends on a shared workspace package: // apps/api/package.json { "dependencies": { "@repo/db": "*" } } The root package.json contains: { "workspaces": [ "apps/*", "packages/*" ] } I only want to build a Docker image for apps/api. I don't want to include apps/admin or apps/public. My first attempt was something like: FROM oven/bun:1 WORKDIR /usr/src/app COPY package.json bun.lock turbo.json ./ COPY apps/api/package.json ./apps/api/ COPY packages/db/package.json ./packages/db/ COPY packages/typescript-config/package.json ./packages/typescript-config/ RUN bun install COPY apps/api ./apps/api COPY packages/db ./packages/db COPY packages/typescript-config ./packages/typescript-config CMD ["bun", "run", "start"] However, bun install fails with errors like: Could not resolve package '/admin' Could not resolve package '/public' Could not resolve package '@repo/ui' because the root workspace declares: "workspaces": [ "apps/*", "packages/*" ] and Bun expects every matching workspace to exist. If I instead do: COPY . . RUN bun install everything works, but the Docker image contains the entire Turborepo, including apps that are unrelated to the API. Questions What is the recommended way to build a Docker image for only one app in a Turborepo? Is copying the whole repository the normal approach? Should I use turbo prune --docker for this use case? Is there a way to make Bun install only the API workspace and its dependencies without copying every workspace into the Docker build context? I'm looking for the recommended production approach rather than just a workaround.
TRIZ inventive level: 3/5· Principles: parameter changes, separation of concerns
Synthesis verdict
**pivot** The idea of building a Docker image for a single app in a Turborepo with Bun workspaces is technically feasible but faces significant structural challenges. The core issue is Bun's workspace resolution, which expects all declared workspaces to exist, making selective installation of only the API and its dependencies difficult without workarounds. While `turbo prune --docker` is repeatedly cited as the recommended approach, it is primarily designed for Turbo's build system and may not fully resolve Bun's workspace expectations. Copying the entire repository works but leads to bloated images, which is inefficient for production. The market demand exists (monorepo users need optimized Docker builds), but the solution space is already addressed by existing tooling, leaving little room for differentiation. The fatal weakness here is the misalignment between Bun's workspace design and the goal of isolated Docker builds. This structural limitation reduces defensibility and increases complexity, making it a poor fit for a money-making venture unless the approach pivots to a more robust, tooling-agnostic solution (e.g., a wrapper or service that abstracts away these pain points).

Strengths

  • Strong market demand: ~30% of large JS codebases use monorepos like Turborepo, and Docker optimization is a recurring pain point (MARKET).
  • Existing tooling (`turbo prune --docker`) provides a partial solution, reducing image size and build time (VIABILITY, MONETIZATION).
  • Efficiency gains: Pruning unnecessary files and dependencies can significantly improve CI/CD costs and deployment performance (MONETIZATION).

Weaknesses

  • Bun's workspace resolution is a fatal flaw: it requires all declared workspaces to exist, making selective installation non-trivial (RISK, VIABILITY).
  • Little defensibility: The problem is already addressed by Turborepo's built-in tools, leaving no room for a new entrant to differentiate (COMPETITIVE).
  • Complexity and inefficiency: Manual workarounds (e.g., copying the entire repo) are fragile or bloated, violating production best practices (VIABILITY, RISK).
  • No clear revenue path: The solution is open-source or tooling-based, with indirect monetization (e.g., CI/CD cost savings) rather than direct payment (MONETIZATION).

Best angle

Pivot to a tool or service that abstracts monorepo-to-Docker complexity for Bun/Turborepo users, rather than offering a one-off workaround.

Panel verdicts

Competition

nvidia/nemotron-3-super-120b-a12b(fallback #1)

3.0

Use Turborepo's built‑in `turbo prune --docker` to generate a minimal repository copy containing only the API workspace and its dependencies before building the Docker image.

The problem of building a Docker image for a single app in a Turborepo/Bun monorepo is well‑known and already addressed by existing tooling. Turborepo provides the `turbo prune --docker` command (or `turbo prune -- --docker`) that creates a temporary copy of the repository containing only the workspace and its transitive dependencies, which can then be used as the Docker build context. This eliminates the need to manually copy individual `package.json` files and avoids the Bun error that occurs when workspaces are missing. Alternative approaches include using a `.dockerignore` file to exclude unrelated apps, employing multi‑stage Dockerfiles that run `bun install` in a stage with the full repo and then copy only the needed output, or using package managers that support workspace filtering (e.g., Yarn 2+ `yarn workspaces focus`). Because the solution is already built into Turborepo and similar monorepo tools, there is little room for a new entrant to offer a defensible differentiation unless they provide a significantly smoother developer experience, deeper integration with Bun's lockfile handling, or automated CI/CD pipelines that go beyond what `turbo prune` already delivers. In practice, the recommended production approach is to rely on `turbo prune --docker` (or an equivalent workspace‑filtering step) rather than copying the whole repository or attempting custom selective copies.

Risk

nvidia/llama-3.3-nemotron-super-49b-v1

3.0

Turborepo and Bun's monorepo-centric design makes building an isolated Docker image for a single app highly non-standard and inefficient.

The proposed Docker image build approach for a single Turborepo app (API) is fraught with structural and dependency challenges inherent to Turborepo and Bun's design. By design, Turborepo and Bun are optimized for monorepo workflows, assuming a unified build context. Attempting to isolate a single app (e.g., `apps/api`) while excluding others (`apps/admin`, `apps/public`) breaks this assumption, leading to resolution errors for declared but missing workspaces. Copying the entire repository works but bloats the image. `turbo prune --docker` is designed for Turbo's build system, not directly applicable to Bun's dependency resolution in this context. Bun's `install` command, tied to the root `package.json`'s workspace declaration, insists on all declared workspaces being present, making selective installation of only `api` and its direct dependencies (like `@repo/db`) without the full workspace context highly non-standard and unsupported out-of-the-box. This setup forces a choice between image bloat or significant custom scripting to mimic a partial monorepo setup, neither of which aligns with 'recommended production approaches' for Turborepo/Bun ecosystems.

Market

mistralai/mistral-small-4-119b-2603(fallback #2)

7.0

Use `turbo prune --docker` to generate a minimal, dependency-resolved Docker context for a single Turborepo app.

The core problem here is a mismatch between Turborepo's workspace-aware tooling (which expects all declared workspaces to exist) and Docker's layer-based build system (which struggles with partial workspace resolution). The user's frustration is valid: copying the entire repo works but bloats the image, while selective copying breaks Bun's workspace resolution. The recommended production approach is indeed `turbo prune --docker`, which is purpose-built for this scenario. This command generates a minimal, self-contained snapshot of the monorepo containing only the app and its transitive dependencies, then outputs a Dockerfile template. It handles workspace resolution correctly by rewriting package references to point to the pruned context. Alternatives like manual COPY directives are fragile and violate the principle of least surprise. The audience for this solution is primarily JavaScript/TypeScript monorepo maintainers who need production-grade Docker builds without unnecessary bloat. The market size is substantial: monorepos are increasingly popular (e.g., ~30% of large JS codebases use Turborepo or similar), and Docker optimization is a recurring pain point. Willingness to pay exists indirectly - developers will adopt this pattern to reduce CI/CD costs and deployment sizes, even if they don't pay directly for the tooling. The unmet need is a frictionless path from monorepo to minimal Docker image, which `turbo prune` directly addresses.

Monetization

mistralai/mistral-nemotron(fallback #1)

7.0

Using `turbo prune --docker` is the recommended approach to build a Docker image for a specific app in a Turborepo, as it efficiently includes only the necessary dependencies.

The idea addresses a common challenge in monorepo setups: efficiently building Docker images for specific apps without including unnecessary dependencies. The proposed solution using `turbo prune --docker` is a strong approach, as it automatically prunes the repository to include only the necessary dependencies for the specified app. This reduces the Docker image size and build time, which is crucial for production efficiency. However, the implementation requires careful handling of workspace dependencies and ensuring that the pruned repository still meets all runtime requirements. The key insight is that leveraging Turborepo's built-in tools like `turbo prune` can significantly optimize the Docker build process for monorepos.

Viability

nvidia/llama-3.3-nemotron-super-49b-v1(fallback #1)

6.0

Use `turbo prune --docker` to minimize the build context, then copy and install only necessary parts, accepting some repository copying as a practical compromise.

Building a Docker image for a single app in a Turborepo with Bun workspaces is feasible but requires careful handling of dependencies and workspace configurations. The challenge lies in Bun's expectation of all declared workspaces, complicating selective dependency installation. Copying the whole repository (score reducer: -2 for inefficiency) works but is not ideal due to image size. Turbo prune --docker (score booster: +1 for efficiency) can help optimize the build context by only including necessary files, reducing the image size significantly. However, its primary function is to optimize build times by pruning unnecessary files for Turbo builds, not necessarily solving the Bun install issue for isolated workspaces. The recommended approach involves a hybrid strategy: use `turbo prune --docker` to minimize the build context while still copying the necessary parts of the repository to satisfy Bun's workspace expectations, then apply a post-install cleanup (score booster: +1 for creativity). Directly installing only the API workspace without copying all workspaces isn't natively supported by Bun due to its workspace resolution mechanism (score reducer: -2 for complexity).

Synthesized by mistralai/mistral-medium-3.5-128b (fallback #2) · 42.5s