Open 0tii opened 6 months ago
FROM oven/bun:1.0.14 as base
This is using Bun v1.0.14
Please try with Bun v1.1.4
Please try with Bun v1.1.4
[+] Building 256.1s (7/9) docker:default
=> [app internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 364B 0.0s
=> [app internal] load metadata for docker.io/oven/bun:1.1.4 2.1s
=> [app internal] load .dockerignore 0.1s
=> => transferring context: 74B 0.0s
=> [app base 1/3] FROM docker.io/oven/bun:1.1.4@sha256:ea572eace71acadb17ea5c408550eafd5ab82f2f6f48c04b906a3091e017cf35 0.0s
=> [app internal] load build context 0.3s
=> => transferring context: 50.98kB 0.2s
=> CACHED [app base 2/3] WORKDIR /usr/src/app 0.0s
=> [app base 3/3] COPY package.json bun.lockb ./ 0.2s
=> [app dev 1/2] RUN bun i --frozen-lockfile 253.3s
=> => # bun install v1.1.4 (fbe2fe0c)
I am having the same issue in my docker image, I tried building from base image oven/bun:1-alpine
and it takes forever to install my svelte app dependencies.
If anyone is stuck at this, as a work-around for this, I install the dependencies using yarn, then build and run using bun.
I added
[install.lockfile]
print = "yarn"
to bunfig.toml
file in project's root, this makes bun create yarn.lock
file as well as bun.lockb
file.
Then I update my docker file to look like this:
# Install using yarn, as bun install has problems with docker
FROM node:lts-alpine AS install
WORKDIR /app
COPY package.json .
COPY yarn.lock .
RUN --mount=type=cache,target=/usr/local/share/.cache yarn install --freeze-lockfile --verbose
# Build and run using bun
FROM oven/bun:1-alpine
WORKDIR /app
COPY --from=install /app /app
COPY . .
RUN bun run build
CMD bun ./build/index.js
The --mount
part in the install command is used to mount yarn cache as a cache-mount, this greatly reduces resulting image size (effectively removes cache from the image), and makes subsequent builds a lot faster.
The end result is that docker build
now finishes in a couple of minutes (from a clean state without any cached images).
Having this too on Bun 1.1.12 (43f0913c). It's inconsistent as sometimes a simple restart of the build will resolve the issue (only taking about 5s instead of 270s).
=> [sync build 4/5] RUN bun install --frozen-lockfile --production 210.5s
=> => # [0.02ms] ".env"
=> => # bun install v1.1.12 (43f0913c)
Very odd, given since 1.1.10 (have not dared upgrading further) the issue is gone for me and I was already about to praise the update to have fixed it for good
Having the same issue, still happening on 1.1.27
. Easily reproducible when starting on clean Docker cache.
Starting a VM and running build will constantly freeze for more than 8 min.
Hitting Ctrl+C and reruning the build command is forcing it to complete faster, but again gets stuck and doing that a couple of times (Ctrl+C, build) bun install completes in about < 40s (Including the restart time of Docker checking the previous layers).
Any new installs after that, when a dependency is changed are fast. Then recreating the VM (colima delete/colima start) hits the same issue. This is on an M1 mac.
NPM completes the same operation (full install without cache) in about 20s.
As seen in the screenshots, verbose logs don't help much as it just prints waiting for N tasks
.
@Jarred-Sumner are there any other logs I can enable here to get more insights on what goes wrong the first time?
What version of Bun is running?
1.1.4+fbe2fe0c3
What platform is your computer?
Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
Use this minimal Dockerfile with a nestjs project
And see a fresh build take 5 minutes for a bun ci
What is the expected behavior?
Fast install, doing the same on my host machine takes a few seconds max even without cache
What do you see instead?
300+ second install
Additional information
No response