Skip to content

bun run fails in docker ubuntu: script "build" exited with code 1 (SIGHUP) #5007

Closed

Description

@styfle

What version of Bun is running?

1.0.0

What platform is your computer?

Linux 5.10.47-linuxkit x86_64 x86_64

What steps can reproduce the bug?

Dockerfile

FROM --platform=linux/amd64 docker.io/ubuntu:latest
RUN apt-get update && apt-get install -y curl unzip
RUN curl -fsSL https://bun.sh/install | bash
COPY . .
ENV PATH=$PATH:/root/.bun/bin
RUN bun --version
RUN bun run build

package.json

{
  "private": true,
  "scripts": {
    "build": "bun index.mjs"
  }
}

index.mjs

import { join } from 'path'
const abs = join(process.cwd(), './index.mjs')
console.log('reading file', abs)
const file = Bun.file(abs)
const content = await file.text()
console.log(content)

What is the expected behavior?

Should print file contents when building the dockerfile with:

docker build -t test-bun .

What do you see instead?

[+] Building 2.5s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                     0.0s
 => => transferring dockerfile: 74B                                                                                                                                      0.0s
 => [internal] load .dockerignore                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/ubuntu:latest                                                                                                         0.5s
 => [1/6] FROM docker.io/library/ubuntu:latest@sha256:aabed3296a3d45cede1dc866a24476c4d7e093aa806263c27ddaadbdce3c1054                                                   0.0s
 => [internal] load build context                                                                                                                                        0.0s
 => => transferring context: 203B                                                                                                                                        0.0s
 => CACHED [2/6] RUN apt-get update && apt-get install -y curl unzip                                                                                                     0.0s
 => CACHED [3/6] RUN curl -fsSL https://bun.sh/install | bash                                                                                                            0.0s
 => [4/6] COPY . .                                                                                                                                                       0.0s
 => [5/6] RUN bun --version                                                                                                                                              0.2s
 => ERROR [6/6] RUN bun run build                                                                                                                                        1.7s
------
 > [6/6] RUN bun run build:
#10 0.206 $ bun index.mjs
#10 1.566 reading file /index.mjs
#10 1.644 error: script "build" exited with code 1 (SIGHUP)
------
executor failed running [/bin/sh -c bun run build]: exit code: 1

Additional information

I can reproduce the issue on ubuntu and centos.

When I run locally with macOS, it works correctly.

Activity

  1. changed the title [-]bun run build fails in docker ubuntu[/-] [+]`bun run build` fails in docker ubuntu: script "build" exited with code 1 (SIGHUP)[/+] on Sep 11, 2023
  2. changed the title [-]`bun run build` fails in docker ubuntu: script "build" exited with code 1 (SIGHUP)[/-] [+]`bun run` fails in docker ubuntu: script "build" exited with code 1 (SIGHUP)[/+] on Sep 11, 2023
  3. japhex commented on Sep 12, 2023

    @japhex

    There is an official oven/bun image - should you not be using that instead?

    just FROM oven/bun

  4. styfle commented on Sep 12, 2023

    @styfle
    ContributorAuthor

    @japhex It also fails with oven/bun. Try this:

    FROM --platform=linux/amd64 oven/bun
    COPY . .
    RUN bun run build

    The issue is likely related to the kernel version or io_uring of the host machine.

    Oddly enough, bun index.mjs works but bun run build fails (even though these should be the exact same code).

  5. youfun commented on Sep 14, 2023

    @youfun

    i have the same problem with the office bun . sometimes it work,but most of time it fails.

    [6/6] RUN bun run build:
    1.820 at bind (/app/node_modules/rollup/dist/es/shared/node-entry.js:5891:27)
    1.820 at bind (/app/node_modules/rollup/dist/es/shared/node-entry.js:5891:27)
    1.820 at bind (/app/node_modules/rollup/dist/es/shared/node-entry.js:5890:21)
    1.820 at bind (/app/node_modules/rollup/dist/es/shared/node-entry.js:10667:31)
    1.820 at bind (/app/node_modules/rollup/dist/es/shared/node-entry.js:5890:21)
    1.820 at bindReferences (/app/node_modules/rollup/dist/es/shared/node-entry.js:13735:22)
    1.820 at sortModules (/app/node_modules/rollup/dist/es/shared/node-entry.js:25849:13)
    1.820 at (/app/node_modules/rollup/dist/es/shared/node-entry.js:25736:32)
    1.820 at processTicksAndRejections (:1:1302)
    1.838 error: script "build" exited with code 1 (SIGHUP)


    Dockerfile:7

    5 | RUN bun install
    6 | COPY . .
    7 | >>> RUN bun run build
    8 | EXPOSE 3000
    9 | ENTRYPOINT ["bun", "./build"]

    error: failed to solve: process "/bin/sh -c bun run build" did not complete successfully: exit code: 1

  6. youfun commented on Sep 14, 2023

    @youfun

    i try “FROM --platform=linux/amd64” and “ven/bun”, all failed. i check the cpu ,it is amd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions