oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.94k stars 2.75k forks source link

Add Alpine-based Docker images #4611

Closed aradalvand closed 1 year ago

aradalvand commented 1 year ago

Couldn't find an issue specifically about Alpine-based versions for the official Docker image, but let me know if one already exists.

zfben commented 1 year ago

I have tried to install bun in alpine with https://github.com/oven-sh/bun/blob/main/dockerhub/Dockerfile-alpine, but it doesn't work.

 > [stage-1 18/18] RUN bun --version:
0.149 Error relocating /lib/ld-linux-x86-64.so.2: unsupported relocation type 37
0.149 Error relocating /usr/local/bin/bun: __memmove_chk: symbol not found
suchipi commented 1 year ago

related: https://github.com/oven-sh/bun/issues/918

melroy89 commented 1 year ago

I indeed noticed that oven/bun:1.0.0 is 100MB compressed for amd64. While node:lts-alpine3.18 is 51MB compressed for amd64.

I looking forward to see an alpine docker based image, before I migrate my projects to Bun.

polarathene commented 1 year ago

I indeed noticed that oven/bun:1.0.0 is 100MB compressed for amd64. While node:lts-alpine3.18 is 51MB compressed for amd64.

It should be 65MB, there was a mistake/bug in the Dockerfile: https://github.com/oven-sh/bun/issues/5269

Depending on what the bun binary needs, it could possibly use a smaller glibc image (assuming it needs to link to glibc/musl), maybe a distroless variant.

EDIT:

I looking forward to see an alpine docker based image

Sometimes Alpine isn't a good choice for very little savings. musl can introduce various problems, notably in performance and memory usage, but also in compatibility (some NPM packages in the past have installed pre-built binaries for "linux" that expected glibc not musl and broke), and other surprises (DNS is handled a bit differently, especially when IPv6 lookups are involved IIRC).

Maybe you don't notice the performance difference, or run into any of the other issues users encounter, but they're sometimes a bit difficult to troubleshoot when you do hit them. The disk savings can be very minor to justify it (most of the time it's for network transit concern, not disk storage).

aradalvand commented 1 year ago

The disk savings can be very minor to justify it

Image size is not the only reason one might want to use Alpine-based images (albeit it is the primary one for most people), the apk package registry is another big pro.

Nearly all major runtimes and such in all languages provide Alpine-based Docker images, so it would be kind of weird for Bun to not also have them. Leave the actual decision on which image variant to use to the developers, but the option should be there, at least.

suchipi commented 1 year ago

Just me, but for what it's worth, the reason I personally care about musl support in bun is so that I can use it in existing alpine images; images where I compile binaries targeting musl, where I'd like to use bun as a compile-time tool. As a workaround, I could do the bun parts in a separate step in a separate image, but it's fewer moving parts if it's all in one.

Electroid commented 1 year ago

We now publish the oven/bun:alpine image, as well as oven/bun:distroless. https://bun.sh/docs/installation#docker https://hub.docker.com/r/oven/bun/tags

aradalvand commented 1 year ago

@Electroid Thanks. The Alpine version is apparently still installing glibc instead of using musl though, right? Is Bun not compatible with musl? If so, is there an issue tracking that?

suchipi commented 1 year ago

@aradalvand https://github.com/oven-sh/bun/issues/918

aradalvand commented 1 year ago

Oh yeah, sorry you had already mentioned that issue in this comment, missed that! Thanks.