Skip to content

New image: bun #14272

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Electroid
Copy link

@Electroid Electroid commented Mar 16, 2023

Bun

Bun is a new JavaScript and TypeScript runtime.

Checklist for Review

  • associated with or contacted upstream?

I work for Oven, the company behind Bun

MIT

  • does it fit into one of the common categories? ("service", "language stack", "base distribution")

Language stack for JavaScript and TypeScript

  • is it reasonably popular, or does it solve a particular use case well?

Yes and yes

  • does a documentation PR exist? (should be reviewed and merged at roughly the same time so that we don't have an empty image page on the Hub for very long)

docker-library/docs#2302

Yes, though if we missed anything, let us know

  • 2+ official-images maintainer dockerization review?

TBD

  • existing official images have been considered as a base? (ie, if foobar needs Node.js, has FROM node:... instead of grabbing node via other means been considered?)

FROM debian

  • if FROM scratch, tarballs only exist in a single commit within the associated history?

N/A

Basic test added

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

Diff for 2c542cf:
diff --git a/_bashbrew-arches b/_bashbrew-arches
index 8b13789..e85a97f 100644
--- a/_bashbrew-arches
+++ b/_bashbrew-arches
@@ -1 +1,2 @@
-
+amd64
+arm64v8
diff --git a/_bashbrew-cat b/_bashbrew-cat
index bdfae4a..4b6d303 100644
--- a/_bashbrew-cat
+++ b/_bashbrew-cat
@@ -1 +1,12 @@
-Maintainers: New Image! :D (@docker-library-bot)
+Maintainers: Jarred Sumner <[email protected]> (@Jarred-Sumner), Ashcon Partovi <[email protected]> (@Electroid)
+GitRepo: https://github.com/oven-sh/bun.git
+
+Tags: debian-slim, 0.5.7-debian-slim, 0.5-debian-slim
+Architectures: amd64, arm64v8
+GitCommit: 37293cb26a8239d4f387218a1fdadc522787835f
+Directory: dockerhub/debian-slim
+
+Tags: latest, debian, 0.5.7, 0.5.7-debian, 0.5, 0.5-debian
+Architectures: amd64, arm64v8
+GitCommit: 37293cb26a8239d4f387218a1fdadc522787835f
+Directory: dockerhub/debian
diff --git a/_bashbrew-list b/_bashbrew-list
index e69de29..0526046 100644
--- a/_bashbrew-list
+++ b/_bashbrew-list
@@ -0,0 +1,9 @@
+bun:0.5
+bun:0.5-debian
+bun:0.5-debian-slim
+bun:0.5.7
+bun:0.5.7-debian
+bun:0.5.7-debian-slim
+bun:debian
+bun:debian-slim
+bun:latest
diff --git a/_bashbrew-list-build-order b/_bashbrew-list-build-order
index e69de29..a98a35f 100644
--- a/_bashbrew-list-build-order
+++ b/_bashbrew-list-build-order
@@ -0,0 +1,2 @@
+bun:0.5-debian-slim
+bun:0.5-debian
diff --git a/bun_0.5-debian-slim/Dockerfile b/bun_0.5-debian-slim/Dockerfile
new file mode 100644
index 0000000..954c48d
--- /dev/null
+++ b/bun_0.5-debian-slim/Dockerfile
@@ -0,0 +1,77 @@
+FROM debian:bullseye-slim AS build
+
+# https://github.com/oven-sh/bun/releases
+ARG BUN_VERSION=0.5.7
+
+RUN apt-get update -qq \
+    && apt-get install -qq --no-install-recommends \
+      ca-certificates \
+      curl \
+      dirmngr \
+      gpg \
+      gpg-agent \
+      unzip \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/* \
+    && arch="$(dpkg --print-architecture)" \
+    && case "${arch##*-}" in \
+      amd64) build="x64-baseline";; \
+      arm64) build="aarch64";; \
+      *) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
+    esac \
+    && version="$BUN_VERSION" \
+    && case "$version" in \
+      latest | canary | bun-v*) tag="$version"; ;; \
+      v*)                       tag="bun-$version"; ;; \
+      *)                        tag="bun-v$version"; ;; \
+    esac \
+    && case "$tag" in \
+      latest) release="latest/download"; ;; \
+      *)      release="download/$tag"; ;; \
+    esac \
+    && curl "https://github.com/oven-sh/bun/releases/$release/bun-linux-$build.zip" \
+      -fsSLO \
+      --compressed \
+      --retry 5 \
+      || (echo "error: unknown release: ($tag)" && exit 1) \
+    && for key in \
+      "F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
+    ; do \
+      gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
+      || gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
+    done \
+    && gpg --update-trustdb \
+    && curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
+      -fsSLO \
+      --compressed \
+      --retry 5 \
+    && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
+      || (echo "error: failed to verify release: ($tag)" && exit 1) \
+    && grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
+      || (echo "error: failed to verify release: ($tag)" && exit 1) \
+    && unzip "bun-linux-$build.zip" \
+    && mv "bun-linux-$build/bun" /usr/local/bin/bun \
+    && rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
+    && chmod +x /usr/local/bin/bun \
+    && ln -s /usr/local/bin/bun /usr/local/bin/bunx \
+    && which bun \
+    && which bunx \
+    && bun --version
+
+FROM debian:bullseye-slim
+
+RUN groupadd bun \
+      --gid 1000 \
+    && useradd bun \
+      --uid 1000 \
+      --gid bun \
+      --shell /bin/sh \
+      --create-home
+
+COPY docker-entrypoint.sh /usr/local/bin
+COPY --from=build /usr/local/bin/bun /usr/local/bin
+COPY --from=build /usr/local/bin/bunx /usr/local/bin
+
+WORKDIR /home/bun/app
+ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
+CMD ["/usr/local/bin/bun"]
diff --git a/bun_0.5-debian-slim/docker-entrypoint.sh b/bun_0.5-debian-slim/docker-entrypoint.sh
new file mode 100755
index 0000000..a0e45cb
--- /dev/null
+++ b/bun_0.5-debian-slim/docker-entrypoint.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
+  set -- /usr/local/bin/bun "$@"
+fi
+
+exec "$@"
diff --git a/bun_0.5-debian/Dockerfile b/bun_0.5-debian/Dockerfile
new file mode 100644
index 0000000..a16befb
--- /dev/null
+++ b/bun_0.5-debian/Dockerfile
@@ -0,0 +1,77 @@
+FROM debian:bullseye-slim AS build
+
+# https://github.com/oven-sh/bun/releases
+ARG BUN_VERSION=0.5.7
+
+RUN apt-get update -qq \
+    && apt-get install -qq --no-install-recommends \
+      ca-certificates \
+      curl \
+      dirmngr \
+      gpg \
+      gpg-agent \
+      unzip \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/* \
+    && arch="$(dpkg --print-architecture)" \
+    && case "${arch##*-}" in \
+      amd64) build="x64-baseline";; \
+      arm64) build="aarch64";; \
+      *) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
+    esac \
+    && version="$BUN_VERSION" \
+    && case "$version" in \
+      latest | canary | bun-v*) tag="$version"; ;; \
+      v*)                       tag="bun-$version"; ;; \
+      *)                        tag="bun-v$version"; ;; \
+    esac \
+    && case "$tag" in \
+      latest) release="latest/download"; ;; \
+      *)      release="download/$tag"; ;; \
+    esac \
+    && curl "https://github.com/oven-sh/bun/releases/$release/bun-linux-$build.zip" \
+      -fsSLO \
+      --compressed \
+      --retry 5 \
+      || (echo "error: unknown release: ($tag)" && exit 1) \
+    && for key in \
+      "F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
+    ; do \
+      gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
+      || gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
+    done \
+    && gpg --update-trustdb \
+    && curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
+      -fsSLO \
+      --compressed \
+      --retry 5 \
+    && gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
+      || (echo "error: failed to verify release: ($tag)" && exit 1) \
+    && grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
+      || (echo "error: failed to verify release: ($tag)" && exit 1) \
+    && unzip "bun-linux-$build.zip" \
+    && mv "bun-linux-$build/bun" /usr/local/bin/bun \
+    && rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
+    && chmod +x /usr/local/bin/bun \
+    && ln -s /usr/local/bin/bun /usr/local/bin/bunx \
+    && which bun \
+    && which bunx \
+    && bun --version
+
+FROM debian:bullseye
+
+RUN groupadd bun \
+      --gid 1000 \
+    && useradd bun \
+      --uid 1000 \
+      --gid bun \
+      --shell /bin/sh \
+      --create-home
+
+COPY docker-entrypoint.sh /usr/local/bin
+COPY --from=build /usr/local/bin/bun /usr/local/bin
+COPY --from=build /usr/local/bin/bunx /usr/local/bin
+
+WORKDIR /home/bun/app
+ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
+CMD ["/usr/local/bin/bun"]
diff --git a/bun_0.5-debian/docker-entrypoint.sh b/bun_0.5-debian/docker-entrypoint.sh
new file mode 100755
index 0000000..a0e45cb
--- /dev/null
+++ b/bun_0.5-debian/docker-entrypoint.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+
+if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ] || { [ -f "${1}" ] && ! [ -x "${1}" ]; }; then
+  set -- /usr/local/bin/bun "$@"
+fi
+
+exec "$@"

@Electroid
Copy link
Author

Hi @tianon, @yosifkit, ready for review and workflow approval at your convenience.

@connerlphillippi
Copy link

@tianon @yosifkit following up here - is this on your radar? It's been over 2 years. What do we need to do on our side to push this forward Thanks! :)

@tianon
Copy link
Member

tianon commented Jun 3, 2025

Thanks for the gentle ping (and the patience, it's really appreciated ❤️) 🙇

Here's some high-level review of what's here to get things started (I imagine there's probably some updates/changes that have already happened that we'll review in the delta):


Tags might want to be more explicit about which debian instead of just debian/debian-slim (ie bookworm vs the near-release trixie or debian 12 vs 13 if you prefer) -- even if you provide generic "latest" aliases like this, it helps users during the transition period (when the "square wheel" rolls from one release to another and inevitably causes some breakage).


Is debian:bullseye vs debian:bullseye-slim really relevant enough to Bun users to justify maintaining separate variants? (most other images have a "slim" variant because the default / non-"slim" variant is from the batteries-included buildpack-deps images for aggressive header file / libraries inclusion) -- I would imagine that just debian:bullseye-slim is probably sufficient and there's not a strong reason to have the other at all unless you want to swap the default to buildpack-deps which would then match node closer (but comes with a whole different set of tradeoffs that may or may not match how users use bun / how modules/extensions work in the bun ecosystem).


I'm not sure a multi-stage build is really warranted here -- if the goal is just to remove the packages used for building, that's pretty easy to do reasonably cleanly (and I'm happy to help with that, if necessary).


apt-get clean is a no-op in the debian (and ubuntu) images: https://github.com/debuerreotype/debuerreotype/blob/c9542ab785e72696eb2908a6dbc9220abbabef39/scripts/debuerreotype-minimizing-config#L87-L109


What's gpg --update-trustdb doing? Is it really necessary? (you probably also want to use a temporary GNUPGHOME and clean it up after verification, although that's not really critical)


which -> command -v 👀 (https://salsa.debian.org/debian/debianutils/-/commit/3a8dd10b4502f7bae8fc6973c13ce23fc9da7efb)

Although alternatively, it could be removed completely, as bun --version is already verifying that bun exists in the PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants