Skip to content

Commit 1cd278f

Browse files
committed
fix(docker): fix distroless build failure and upgrade to debian12
## Problem Distroless Docker image build has been failing in CI/CD since v1.1.45 (4+ months ago). This prevented the distroless image from being published to Docker Hub. Error: `exec /bin/sh: no such file or directory` Root cause: Distroless base image does not contain shell, but Dockerfile used heredoc syntax which requires `/bin/sh` to execute. ## Solution 1. Create all symlinks in build stage (where shell is available) - ln -s /usr/local/bin/bun /usr/local/bin/bunx - ln -s /usr/local/bin/bun /usr/local/bun-node-fallback-bin/node 2. In distroless stage, only COPY symlinks (no RUN commands needed) - COPY --from=build /usr/local/bin/bunx - COPY --from=build /usr/local/bun-node-fallback-bin/ 3. Upgrade base image from debian11 to debian12 - Fixes security vulnerabilities (1 HIGH CVE → 0) - Uses gcr.io/distroless/base-debian12 ## Testing - Local build: ✅ Success (both amd64) - Verified symlinks: ✅ All working (bun, bunx, node) - Image size: ~20 MB (minimal as expected) ## Related Issues Closes oven-sh#20414 Closes oven-sh#16666 Related to oven-sh#22601, oven-sh#19788
1 parent 908ab9c commit 1cd278f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

dockerhub/distroless/Dockerfile

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ RUN apt-get update -qq \
5555
&& which bun \
5656
&& bun --version
5757

58-
FROM gcr.io/distroless/base-nossl-debian11
58+
# Create symlinks in build stage (where shell is available)
59+
RUN ln -s /usr/local/bin/bun /usr/local/bin/bunx \
60+
&& mkdir -p /usr/local/bun-node-fallback-bin \
61+
&& ln -s /usr/local/bin/bun /usr/local/bun-node-fallback-bin/node
62+
63+
FROM gcr.io/distroless/base-debian12
5964

6065
# Disable the runtime transpiler cache by default inside Docker containers.
6166
# On ephemeral containers, the cache is not useful
@@ -67,18 +72,8 @@ ARG BUN_INSTALL_BIN=/usr/local/bin
6772
ENV BUN_INSTALL_BIN=${BUN_INSTALL_BIN}
6873

6974
COPY --from=build /usr/local/bin/bun /usr/local/bin/
70-
ENV PATH "${PATH}:/usr/local/bun-node-fallback-bin"
71-
72-
# Temporarily use the `build`-stage image binaries to create a symlink:
73-
RUN --mount=type=bind,from=build,source=/usr/bin,target=/usr/bin \
74-
--mount=type=bind,from=build,source=/bin,target=/bin \
75-
--mount=type=bind,from=build,source=/usr/lib,target=/usr/lib \
76-
--mount=type=bind,from=build,source=/lib,target=/lib \
77-
<<EOF
78-
ln -s /usr/local/bin/bun /usr/local/bin/bunx
79-
which bunx
80-
mkdir -p /usr/local/bun-node-fallback-bin
81-
ln -s /usr/local/bin/bun /usr/local/bun-node-fallback-bin/nodebun
82-
EOF
75+
COPY --from=build /usr/local/bin/bunx /usr/local/bin/
76+
COPY --from=build /usr/local/bun-node-fallback-bin /usr/local/bun-node-fallback-bin/
77+
ENV PATH="${PATH}:/usr/local/bun-node-fallback-bin"
8378

8479
ENTRYPOINT ["/usr/local/bin/bun"]

0 commit comments

Comments
 (0)