Skip to content

Conversation

@wojtek-fintek
Copy link

@wojtek-fintek wojtek-fintek commented May 20, 2025

What does this PR do?

Fix distroless build by not using ln -s in distroless environment. fixes #19786 and fixes #20414

  • Documentation or TypeScript types (it's okay to leave the rest blank in this case)
  • Code changes

How did you verify your code works?

@RiskyMH RiskyMH added the docker An issue that occurs when running in Docker label May 20, 2025
@RiskyMH RiskyMH requested a review from Electroid May 22, 2025 15:00
shendongming added a commit to sdm2025/bun that referenced this pull request Nov 27, 2025
## 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
shendongming added a commit to sdm2025/bun that referenced this pull request Nov 27, 2025
## 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 (linux/amd64)
- Azure-dev build: ✅ Success (linux/amd64)
- Verified symlinks: ✅ All working (bun, bunx, node)
- Image size: 228MB (comparable to debian variant at 221MB)

## Related Issues
Closes oven-sh#20414
Closes oven-sh#16666
Related to oven-sh#22601, oven-sh#19788
@nektro
Copy link
Contributor

nektro commented Nov 29, 2025

fixed by #24055

@nektro nektro closed this Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker An issue that occurs when running in Docker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Distroless docker image is very outdated

3 participants