Not possible to deploy with new bun version - Nuxt

So i experience some problems yesterday launching a nuxt application. This morning I tried again with a new application - the content of the application is the next:

// app.vue
<template>
  <div>
    This is a test example!
  </div>
</template>

Then tried to deploy the application with fly launch but the builder get stuck at (after 1037s still running):

its the auto generated docker and .toml

Update I deployed another application i have with a previous bun version BUN_VERSION=1.1.34 and the fly builder doesnt work! It gets stuck at the stage:

computer@macbook % fly deploy
==> Verifying app config
Validating /Users/user/Documents/GitHub/nuxtApps/app/fly.toml
âś“ Configuration is valid
--> Verified app config
==> Building image
Waiting for depot builder...

Today is going to be interesting.

Docker file for the newer bun version:

# syntax = docker/dockerfile:1

# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.2.1
FROM oven/bun:${BUN_VERSION}-slim AS base

LABEL fly_launch_runtime="Nuxt"

# Nuxt app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3

# Install node modules
COPY bun.lock package-lock.json package.json ./
RUN bun install

# Copy application code
COPY . .

# Build application
RUN bun --bun run build

# Remove development dependencies
RUN rm -rf node_modules && \
    bun install --ci


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
ENV HOST=0
CMD [ "node", ".output/server/index.mjs" ]

Docker file for the previous BUN_VERSION=1.1.34

# syntax = docker/dockerfile:1

# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.1.34
FROM oven/bun:${BUN_VERSION}-slim AS base

LABEL fly_launch_runtime="Bun"

# Bun app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3

# Install node modules
COPY bun.lock package.json ./
RUN bun install --ci

# Copy application code
COPY . .


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "bun", "index.ts" ]

So, I havent found a solution HOWEVER, for anyone going through this same issue - BUN_VERSION=1.2.1 is highly compatible with BUN_VERSION=1.1.34.
It is possible to deploy an average 1.2.1 application with a 1.1.34 dockerfile version. But you have to change in your docker file the name of the bun.lock file.
The file bun.lockb changes to bun.lock and apparently.

Meaning you can deploy a BUN_VERSION=1.2.1 application with a BUN_VERSION=1.1.34 without any breaking changes.

# syntax = docker/dockerfile:1

# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.1.34
FROM oven/bun:${BUN_VERSION}-slim as base

LABEL fly_launch_runtime="Nuxt"

# Nuxt app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential pkg-config python-is-python3

# Install node modules
COPY bun.lock package.json ./
RUN bun install

# Copy application code
COPY . .

# Build application
RUN bun --bun run build

# Remove development dependencies
RUN rm -rf node_modules && \
    bun install --ci


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
ENV HOST=0
CMD [ "node", ".output/server/index.mjs" ]

I’d like to help, but it is not clear (at least to me) what the problem is. Your first image doesn’t show an obvious error (it shows 110 modules transformed).

It is true that newer versions of bun default to bun.lock (without the “b”), but they still work with the old lockb format.

I’ve upgraded two of my bun apps to the latest version (and to bun.lock) with no problems. They aren’t nuxt apps.

Hi, I’ve corrected the original blog for clarity. The issue is that after 1037 seconds, the builder machine is still running on a vanilla Nuxt app. Since theres no error, as you mentioned, idk how to debug it. The process just doesn’t stop.

With that clarification, I can make a suggestion.

Copy your Dockerfile to Dockerfile.test. In the new file, delete everything from the line that hangs to the end.

Now type:

fly ssh console --dockefile Dockerfile.test -C /bin/bash

A new ephemeral machine will be created and you will be placed at a command prompt at exactly the point where the command would be run. Run whatever command you like, install additional software if it helps. When you exit the shell, the machine will be destroyed.

Depending on your application, you might need additional memory. Add --vm-memory 2048 (or whatever number you need) if you run out of memory.

1 Like

I think the command doesnt exist ?
fly ssh console --dockerfile Dockerfile.test -C /bin/bash throws Error: unknown flag: --dockerfile.

An empty nuxt application still stucks at => CANCELED [build 5/6] RUN bun --bun run build for > 1000 seconds.

Sorry, drop the ssh:

fly console --dockerfile Dockerfile.test -C /bin/bash

Here are my chat-gpt revised notes on the issue for the community :slight_smile:

Conclusion: Fly.io Autogenerated Dockerfile Errors with Nuxt Applications Using BUN_VERSION=1.2.1

The autogenerated Dockerfile for Bun versions 1.2 and above does not work properly. The build process gets stuck at:

RUN bun --bun run build

If anyone else is experiencing this issue, please like this comment so someone can investigate further. I don’t have the capacity or expertise to determine the root cause.

Workaround

I was able to deploy successfully by modifying the autogenerated Dockerfile as follows:

Broken setup (does not work):

ARG BUN_VERSION=1.2.1
...
COPY bun.lock* package-lock.json package.json ./
...

Working setup:

ARG BUN_VERSION=1.1.34
...
COPY bun.lock package.json ./
...

If you only downgrade Bun’s version but keep package-lock.json, the build process still gets stuck.

Additional Issue with Fly.io Builder

Sometimes, after attempting to deploy with Bun 1.2.x, the Fly.io builder itself can break, preventing any deployments. If this happens:

  1. Go to Fly.io Dashboard
  2. Navigate to App Builders
  3. Press the Reset button

:warning: Note: There is no confirmation message after resetting the builder—it just works, but it feels like a leap of faith.

These changes allow Nuxt applications to deploy successfully as of today. Hopefully, someone from the Fly.io team can investigate further, as this seems like a bug introduced between BUN_VERSION=1.2.1 and the Fly.io builder.

Thank you, the command the command fly console --dockerfile Dockerfile.test -C /bin/bash does work.

However, with fly console --dockerfile Dockerfile.test -C /bin/bash no issues happen.
The issues of > 1000s / app never deploys, only happens if you try to launch an application via fly launch or fly launch --no-deploy -> fly deploy

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.