How to use Bun (bun.sh) with Gitlab runner?

Context

Bun (bun.sh) is out and its getting a lot of attention for being an extremely fast Node/npm/yarn drop-in replacement.
How can we use Bun with Gitlab runners?

Reason

I have a fairly simple YML file building my fairly simple React app, but this currently takes ~6 minutes, which I consider very slow. My YML file:

image: node:latest

build:
  script:
    - yarn install
    - yarn build
  artifacts:
    paths:
      - build/

I would like to see if using Bun can speed up things, as it very much does on my local machine.

Additional info

Bun is supported on:
Github actions: Install and run Bun in GitHub Actions | Bun Examples
Vercel: Bun install is now supported with zero configuration – Vercel
Platform.sh: Bun 1.0 support has arrived | Platform.sh
…(probably more)…

Hey,

As far as I see on the official docs, Bun provides their own image. So, I’d probably do something like:

build:
  # alpine is the smallest (fastest to download), but if that one isn't enough, then the slim version
  image: oven/bun:alpine
  script:
    - bun <whatever>...
  artifacts:
    paths:
      - build/

I never used it, so I don’t know the details (you probably know what to do), but that’s the concept.
If bun makes any kind of cache, you could later add that as well to speed up future builds.

Hope this helps! :slight_smile:

2 Likes

Thank you, @paula.kokic

I get this error now in the runner log:

$ react-scripts build
Creating an optimized production build...
RpcIpcMessagePortClosedError: Process 50 doesn't have open IPC channels
Issues checking service aborted - probably out of memory. Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.
If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript or EsLint.
RpcIpcMessagePortClosedError: Process 51 doesn't have open IPC channels
Issues checking service aborted - probably out of memory. Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.
If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript or EsLint.

Would you know how to get around this?

Puuh, don’t know. Never seen this, as I never used Bun, neither am in touch with Node so much.

I assume local build works without issues?

I’d suggest trying out this image locally - mounting your code into container and trying out. E.g you can execute this from the folder where is your project source (Powershell):

docker run -it -v ${pwd}:/src oven/bun:alpine sh

Then try executing the same commands as in the pipeline. If you get the same error, maybe there is an issue in the image. Try using :slim version (or some other version). Or maybe there is issue somewhere else, but at least you know it’s not Runner / memory related (as it states)

If locally you don’t get the same problem, then it’s a bit harder. In any case I believe you’ll have to dig a bit deeper. Unless someone here on community didn’t have exactly the same issue :smiley:

Good luck!