Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running bun amd64 in docker under platform rosetta2 translation breaks Bun.serve #15204

Closed
lil5 opened this issue Nov 17, 2024 · 8 comments
Closed
Labels
bug Something isn't working macOS An issue that occurs on macOS

Comments

@lil5
Copy link

lil5 commented Nov 17, 2024

What version of Bun is running?

1.1.34+5e5e7c60f

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

  1. create a bun project and add the following to index.ts

command: bun init; bun i

file: index.ts

Bun.serve({
  fetch(req) {
    return new Response("Bun!");
  },
});
  1. create a docker file

file: Dockerfile

FROM oven/bun AS base
WORKDIR /app

COPY bun.lockb . 
COPY package.json . 

# Install dependencies
RUN bun install --frozen-lockfile

COPY . . 

EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "./index.ts" ]

file: .dockerignore

/node_modules
  1. create a docker-compose file
    file: docker-compose.yml
services:
  app:
    platform: linux/amd64
    build:
      context: .
    ports:
      - 127.0.0.1:3000:3000
    restart: unless-stopped
    environment:
      - PORT=3000
  1. Build and run docker compose up -d --build
  2. Create a request to bun wget --spider http://localhost:3000/, run this multiple times and it will stop working after a short while.

What is the expected behavior?

200 responses returning the text "Bun!"

What do you see instead?

Request without a response, endlessly stuck with no response, no console errors.

Additional information

Running on M2 15.1 (24B83) with Docker Desktop 4.35.1 (173168)

@lil5 lil5 added bug Something isn't working needs triage labels Nov 17, 2024
@nektro nektro added macOS An issue that occurs on macOS and removed needs triage labels Nov 17, 2024
@Kapsonfire-DE
Copy link
Contributor

Is this really bun related? Seems more like an issue for the apple team emulating amd64 on arm64 (m2)

@lil5
Copy link
Author

lil5 commented Nov 17, 2024

As running an amd64 GoLang or NodeJS server via Rosetta2 works just fine in docker, yes I'd say it's most likely to be an underlying problem in Bun rather than that of Rosetta2.

To be fair I can test this out on a simple Zig Zap server if it's a zig incompatibility.

@lil5
Copy link
Author

lil5 commented Nov 17, 2024

This is effectively a duplicate of #15139

@Jarred-Sumner
Copy link
Collaborator

We no longer provide a macOS x64 binary that supports non-avx CPUs.

On macOS arm64, we recommend using arm64 builds of Bun. If you install via the curl https://bun./sh/install | bash install script, it will automatically do this even in Rosetta.

@Jarred-Sumner Jarred-Sumner closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
@lil5
Copy link
Author

lil5 commented Nov 18, 2024

This isn't running the Mac version at all, as it's inside a docker container with the platform flag set to linux/amd64.

In any case from the issue I linked above it seems to be fixed for the next release.

@lil5
Copy link
Author

lil5 commented Nov 18, 2024

Supporting a non avx docker linux/amd64 would probably fix it. Or a warning must be added to dockerhub oven/bun that Rosetta2 is not supported.

@Jarred-Sumner
Copy link
Collaborator

Docker defaults to the non-AVX build

Hm

@lil5
Copy link
Author

lil5 commented Nov 18, 2024

The strange thing with my particular situation is that the first request responds just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working macOS An issue that occurs on macOS
Projects
None yet
Development

No branches or pull requests

4 participants