Skip to content

feat(bun): upgrade to bun, reduce docker image size by 95%, upgrade docs & ci - #371

Merged
waleedlatif1 merged 15 commits into
mainfrom
bunny
May 18, 2025
Merged

feat(bun): upgrade to bun, reduce docker image size by 95%, upgrade docs & ci#371
waleedlatif1 merged 15 commits into
mainfrom
bunny

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented May 18, 2025

Copy link
Copy Markdown
Collaborator
  • migrate to bun
  • added envvars to drizzle
  • upgrade bun devcontainer feature to a valid one
  • added bun, docker not working
  • updated envvars, updated to bunder and esnext modules
  • fixed build, reinstated otel
  • feat: optimized multi-stage docker images
  • add coerce for boolean envvar
  • feat: add docker-compose configuration for local LLM services and remove legacy Dockerfile and entrypoint script
  • feat: add docker-compose files for local and production environments, and implement GitHub Actions for Docker image build and publish
  • refactor: remove unused generateStaticParams function from various API routes and maintain dynamic rendering
  • cleanup
  • upgraded bun
  • updated ci
  • fixed build

Description

Upgrade to bun, reduce docker image size by 95%, upgrade docs & ci

Type of change

  • New feature (non-breaking change which adds functionality)
  • Documentation update
  • Performance improvement
  • Code refactoring (no functional changes)

How Has This Been Tested?

Tested manually, ensured everything works.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (npm test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

Additional Information:

In a follow-up PR, we will implement the docker container using this new docker image and make the CLI to publish the new docker image.

@vercel

vercel Bot commented May 18, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs 🛑 Canceled (Inspect) May 18, 2025 8:00am
sim 🛑 Canceled (Inspect) May 18, 2025 8:00am

@waleedlatif1 waleedlatif1 changed the title bunny feat(bun): upgrade to bun, reduce docker image size by 95%, upgrade docs & ci May 18, 2025
@waleedlatif1
waleedlatif1 force-pushed the bunny branch 2 times, most recently from 013fcdf to 4994fa7 Compare May 18, 2025 07:53

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR represents a comprehensive migration from Node.js/npm to Bun as the runtime environment and package manager, along with significant Docker configuration improvements and environment variable handling updates.

  • Migrated from npm/yarn to Bun, updating all package management commands, scripts, and configurations across the codebase
  • Introduced new multi-stage Docker builds with separate configurations for local development (docker-compose.local.yml) and production (docker-compose.prod.yml)
  • Added support for local LLM services through docker-compose.ollama.yml with both GPU and CPU configurations
  • Centralized environment variable handling through a new env.ts module using @t3-oss/env-nextjs for type-safe validation
  • Removed local storage mode functionality in favor of always using database synchronization, which could impact offline capabilities

137 file(s) reviewed, 47 comment(s)
Edit PR Review Bot Settings | Greptile

Comment thread .devcontainer/.bashrc
alias sim-start="cd /workspace && bun run dev"
alias sim-migrate="cd /workspace/apps/sim && bunx drizzle-kit push"
alias sim-generate="cd /workspace/apps/sim && bunx drizzle-kit generate"
alias sim-rebuild="cd /workspace && bun run build && bun run start"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: sim-rebuild uses 'bun run start' but earlier aliases use 'bun run dev' - this inconsistency could cause confusion

Comment thread .devcontainer/Dockerfile
RUN bun completions > /etc/bash_completion.d/bun

# Set up shell environment
RUN echo "export PATH=$PATH:/home/$USERNAME/.bun/bin" >> /etc/profile

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: PATH modification doesn't include $USER_HOME variable, could break for different user configurations

Suggested change
RUN echo "export PATH=$PATH:/home/$USERNAME/.bun/bin" >> /etc/profile
RUN echo "export PATH=$PATH:$HOME/.bun/bin" >> /etc/profile

Comment thread .devcontainer/Dockerfile
Comment on lines +16 to 18
ARG USERNAME=bun
ARG USER_UID=1000
ARG USER_GID=$USER_UID

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: User creation commands are missing - need to actually create the user before setting up sudo access

Suggested change
ARG USERNAME=bun
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG USERNAME=bun
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

Comment on lines +32 to 34
bun install || {
echo "⚠️ bun install had issues but continuing setup..."
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Silently continuing after bun install failures could leave the environment in an inconsistent state. Consider failing fast here instead.

Suggested change
bun install || {
echo "⚠️ bun install had issues but continuing setup..."
}
bun install || {
echo "❌ bun install failed. Please check the errors above and try again."
exit 1
}

Comment on lines +41 to +43
for pkg in $(echo $NATIVE_DEPS | grep -oP '"[^"]*"' | tr -d '"' | grep -v "trustedDependencies"); do
echo "Checking compatibility for $pkg..."
done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Native dependency check only logs but takes no action. Should verify/rebuild native dependencies for Bun compatibility.

Comment thread docker/app.Dockerfile
COPY . .

# Installing with full context to prevent missing dependencies error
RUN bun install --omit dev --ignore-scripts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: redundant bun install - already copied node_modules from deps stage

Comment thread docker/app.Dockerfile

# Required for standalone nextjs build
WORKDIR /app/apps/sim
RUN bun install sharp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: sharp installation should be in deps stage to maintain proper layer caching

Comment thread docker/db.Dockerfile

# Copy only package files needed for migrations
COPY package.json bun.lock turbo.json ./
COPY apps/sim/package.json ./apps/sim/db/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Incorrect destination path for package.json - should be './apps/sim/' not './apps/sim/db/'

Suggested change
COPY apps/sim/package.json ./apps/sim/db/
COPY apps/sim/package.json ./apps/sim/

Comment thread docker/db.Dockerfile
Comment on lines +12 to +13
RUN bun install --omit dev --ignore-scripts && \
bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres next-runtime-env

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Running bun install twice is inefficient - combine into single command with all packages

Suggested change
RUN bun install --omit dev --ignore-scripts && \
bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres next-runtime-env
RUN bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres next-runtime-env

Comment thread docker/db.Dockerfile
COPY apps/sim/package.json ./apps/sim/package.json
COPY apps/sim/lib/env.ts ./apps/sim/lib/env.ts

WORKDIR /app/apps/sim No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: No CMD or ENTRYPOINT specified for running migrations

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants