Closed alvinchristian7 closed 9 months ago
I'm seeing similar behavior. A discord.js bot builds fine with bun locally, but when built inside a Docker image (to be deployed to fly.io) it fails with the following:
=> CACHED [base 2/5] RUN npm install --location=global npm bun
=> CACHED [base 3/5] WORKDIR /usr/src/app
=> CACHED [base 4/5] COPY ./package.json ./
=> CACHED [base 5/5] COPY ./bun.lockb ./
=> ERROR [dev 1/2] RUN bun install
------
> [dev 1/2] RUN bun install:
#0 0.307 bun install v1.0.18 (36c316a2)
#0 3.913 node:internal/modules/cjs/loader:1147
#0 3.913 throw err;
#0 3.913 ^
#0 3.913
#0 3.913 Error: Cannot find module '/usr/src/app/install.js'
#0 3.913 at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
#0 3.913 at Module._load (node:internal/modules/cjs/loader:985:27)
#0 3.913 at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
#0 3.913 at node:internal/main/run_main_module:28:49 {
#0 3.913 code: 'MODULE_NOT_FOUND',
#0 3.913 requireStack: []
#0 3.913 }
#0 3.913
#0 3.913 Node.js v20.10.0
#0 3.913
#0 3.913 error: postinstall script from "bun" exited with code 1 (SIGHUP)
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c bun install]: exit code: 1
Pinning bun to an earlier version (v1.0.16 or earlier) does work inside of Docker:
=> [base 2/5] RUN npm install --location=global npm bun@1.0.16
=> [base 3/5] WORKDIR /usr/src/app
=> [base 4/5] COPY ./package.json ./
=> [base 5/5] COPY ./bun.lockb ./
=> [dev 1/2] RUN bun install
=> [dev 2/2] COPY . .
=> exporting to image
=> => exporting layers
FWIW, this appears to be resolved for me as of bun v1.0.22
Awesome! If you still experience this issue after upgrading, leave a comment and we'll reopen the issue.
What version of Bun is running?
1.0.18+36c316a24
What platform is your computer?
No response
What steps can reproduce the bug?
When i use above
package.json
and bun version >= 1.0.16, build successful from local device (my laptop environment). But failed to build over Docker using this Dockerfile:What is the expected behavior?
Build successfully till finish
What do you see instead?
Additional information
Build error when Docker install bun starting from version >= 1.0.16, should i include all of my packages into "trustedDependencies" or some packages need to be updated because they are not compatible with newer bun versions similar to this issue ? I'm really clueless to debug this kind of thing, so i need your help guys. Thanks