#AstroJS in a dockerfile with bun

1 messages · Page 1 of 1 (latest)

foggy fjord
#

Howdy! I cannot figure out if this is an AstroJS problem, a Docker problem, or a Bun problem; but any help would be appreciated.

# https://docs.astro.build/en/recipes/bun/
FROM oven/bun:alpine
WORKDIR /home/bun/app

ENV HOST=0.0.0.0
ENV PORT=4321

COPY package.json ./ 
COPY bun.lockb ./
RUN bun install

COPY . .
RUN mkdir -p /home/bun/.config && chown -R bun:bun /home/bun/.config
RUN chown -R bun:bun /home/bun
RUN bunx --bun astro build

EXPOSE 4321
CMD bunx --bun ./dist/server/entry.mjs
 > [8/8] RUN bunx --bun astro build:
0.428  error   Bad file descriptor
0.428   File:
0.428     /home/bun/app/node_modules/@astrojs/telemetry/dist/config.js:59:69
0.428   Code:
0.428     58 |   }
0.428     > 59 |   write() {
0.428          |                                                                     ^
0.428       60 |     fs.writeFileSync(this.file, JSON.stringify(this.store, null, "  "));
0.428       61 |   }
0.428       62 |   clear() {
0.428   Stacktrace:
0.428 EBADF: Bad file descriptor
0.428     at writeFileSync (native)
0.428     at write (/home/bun/app/node_modules/@astrojs/telemetry/dist/config.js:59:69)
0.428     at store (/home/bun/app/node_modules/@astrojs/telemetry/dist/config.js:49:16)
0.428     at get (/home/bun/app/node_modules/@astrojs/telemetry/dist/config.js:71:31)
0.428     at getConfigWithFallback (/home/bun/app/node_modules/@astrojs/telemetry/dist/index.js:38:30)
0.428     at isDisabled (/home/bun/app/node_modules/@astrojs/telemetry/dist/index.js:66:28)
0.428     at <anonymous> (/home/bun/app/node_modules/@astrojs/telemetry/dist/index.js:83:11)
0.428     at notify (/home/bun/app/node_modules/@astrojs/telemetry/dist/index.js:82:13)
0.428     at <anonymous> (/home/bun/app/node_modules/astro/dist/cli/telemetry/index.js:6:16)
0.428     at processTicksAndRejections (:55:39)
surreal crestBOT
#

Hi @foggy fjord. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the error stack trace you provided, it seems like the issue is related to Astro's telemetry feature. The error is thrown when the telemetry feature tries to write to a file and encounters a "Bad file descriptor" error. This could be due to a permissions issue or a problem with the file system in your Docker environment.

However, the extracts provided do not contain specific information on how to resolve this issue. I would recommend checking the permissions of the directories and files in your Docker environment, and ensuring that the user running the bunx --bun astro build command has the necessary permissions to write to the file system.

If the issue persists, you might want to consider reaching out to the Astro community for support. You can do this by checking out the #support channel on Discord (https://astro.build/chat) or opening an issue on Astro's GitHub repository (https://github.com/withastro/astro/issues/new/choose).

For more information on using Bun with Astro, you can refer to the official documentation (https://docs.astro.build/en/recipes/bun/).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@foggy fjord kapa.ai is still learning and improving, please let us know how it did by reacting below