bun
bun copied to clipboard
Failed Building Next.js Project with Bun v1.0.3-distroless Images
What version of Bun is running?
1.0.3
What platform is your computer?
RockyLinux 9.2
What steps can reproduce the bug?
docker build -t client-nayud:0.0.1 .
What is the expected behavior?
Upon executing the docker build command, I anticipate a successful build process, resulting in the creation of a Docker image named client-nayud:0.0.1 without any errors. The Bun command inside the Dockerfile should successfully install the necessary dependencies in production mode using the provided lockfile, and any subsequent Dockerfile commands should execute without errors.
What do you see instead?
=> ERROR [builder 5/6] RUN bun i --production --frozen-lockfile --verbose 0.3s
------
> [builder 5/6] RUN bun i --production --frozen-lockfile --verbose:
0.264 runc run failed: unable to start container process: exec: "/bin/sh": stat /bin/sh: no such file or directory
------
Dockerfile:11
--------------------
10 | COPY ./package.json ./bun.lockb ./
11 | >>> RUN bun i --production \
12 | >>> --frozen-lockfile \
13 | >>> --verbose
14 |
--------------------
ERROR: failed to solve: process "/bin/sh -c bun i --production --frozen-lockfile --verbose" did not complete successfully: exit code: 1
Additional information
Hello folks,
First of all, I would like to express my utmost respect and admiration for this project. Your work has been game-changing, and I genuinely appreciate the value it brings to the community. I'm genuinely happy to contribute, even if it's just by raising this issue, and I hope to assist in the continued development and success of this incredible project. Thank you for all your hard work!
So, I recently attempted to build a Next.js project using Bun distroless images (version: 1.0.3-distroless). I cloned the repository from https://github.com/dimasyudhatech/client-nayud and then executed the command:
docker build -t client-nayud:0.0.1 .
However, during the build process, I encountered the following error:
=> ERROR [builder 5/6] RUN bun i --production --frozen-lockfile --verbose 0.3s
------
> [builder 5/6] RUN bun i --production --frozen-lockfile --verbose:
0.264 runc run failed: unable to start container process: exec: "/bin/sh": stat /bin/sh: no such file or directory
------
Dockerfile:11
--------------------
10 | COPY ./package.json ./bun.lockb ./
11 | >>> RUN bun i --production \
12 | >>> --frozen-lockfile \
13 | >>> --verbose
14 |
--------------------
ERROR: failed to solve: process "/bin/sh -c bun i --production --frozen-lockfile --verbose" did not complete successfully: exit code: 1
Here is a snippet of my Dockerfile that produced the error:
FROM oven/bun@sha256:dda877ea04c1d97e7fdc287e902a4c16b027f73ee820ac6d692071df56401e04 AS builder
WORKDIR /home/nonroot
COPY ./package.json ./bun.lockb ./
RUN bun i --production \
--frozen-lockfile \
--verbose
Environment:
- Operating System: RockyLinux 9.2
- Docker version: 24.0.6
Is there a workaround or fix for this issue? Thank you for your assistance.
Try something like this instead, distroless does not have a shell so you can't run RUN commands.
FROM oven/bun:1.0.3-slim AS builder
WORKDIR /app
COPY ./package.json ./bun.lockb ./
RUN bun i --production \
--frozen-lockfile \
--verbose
FROM oven/bun:1.0.3-distroless
COPY /app /
WORKDIR /app
Try something like this instead, distroless does not have a shell so you can't run
RUNcommands.FROM oven/bun:1.0.3-slim AS builder WORKDIR /app COPY ./package.json ./bun.lockb ./ RUN bun i --production \ --frozen-lockfile \ --verbose FROM oven/bun:1.0.3-distroless COPY /app / WORKDIR /app
First of all, thank you so much for the response. I really appreciate it. Well, I understand that the distroless version of the image doesn’t have an in-built shell. Given this, what’s its primary use-case if users can’t utilize bun commands like bun install, bun add, etc. directly?
It looks like this can be changed with: https://docs.docker.com/engine/reference/builder/#shell
You can also use buildah in a shell script instead of writing a dockerfile. This is exactly the kind of situation where buildah run lets you avoid the annoying quirks of dockerfile syntax by not requiring a shell to run a command to build a layer.