Skip to content

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

Closed
waleedlatif1 wants to merge 15 commits into
mainfrom
new-bun
Closed

feat(bun): upgrade to bun, reduce docker image size by 95%, upgrade docs & ci#369
waleedlatif1 wants to merge 15 commits into
mainfrom
new-bun

Conversation

@waleedlatif1

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

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
  • [x]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 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 18, 2025 7:15am
sim ❌ Failed (Inspect) May 18, 2025 7:15am

@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 implements a major migration from Node.js/npm to Bun runtime and package manager, along with significant Docker optimizations. The changes span across the entire codebase with key improvements to environment variable handling and deployment configurations.

  • Introduced multi-stage Docker builds in docker/app.Dockerfile and docker/db.Dockerfile, reducing image size by 95%
  • Added new environment variable management system in apps/sim/lib/env.ts using @t3-oss/env-nextjs and Zod for validation
  • Split Docker Compose configurations into separate files for local, production, and Ollama environments with improved health checks
  • Removed local storage mode functionality from sync system (apps/sim/stores/sync*.ts) in favor of server-based synchronization
  • Migrated instrumentation to separate client/server implementations with improved OpenTelemetry and Sentry integration

136 file(s) reviewed, 46 comment(s)
Edit PR Review Bot Settings | Greptile

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: No explicit group creation or user addition commands. Could cause permission issues.

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 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 uses undefined $PATH which could be empty at this point in the build

Comment thread .dockerignore
Comment on lines +10 to +11
LICENSE
NOTICE
.prettierrc
.prettierignore
README.md
.devcontainer No newline at end of file
.gitignore
.husky
.github
.devcontainer
.env.example
node_modules 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: Critical files like .next (build output), .env, and .env.* (environment variables) are no longer excluded. These should remain in .dockerignore to prevent sensitive data leaks and unnecessary files in the build context.

Suggested change
LICENSE
NOTICE
.prettierrc
.prettierignore
README.md
.devcontainer
\ No newline at end of file
.gitignore
.husky
.github
.devcontainer
.env.example
node_modules
LICENSE
NOTICE
.prettierrc
.prettierignore
README.md
.gitignore
.husky
.github
.devcontainer
.env.example
node_modules
.next
.env
.env.*

Comment thread .dockerignore
.github
.devcontainer
.env.example
node_modules 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.

style: Add exclusions for common build artifacts and logs: .next/, build/, dist/, *.log to optimize build context size

Comment thread .github/dependabot.yml
Comment on lines +3 to +4
- package-ecosystem: 'bun'
directory: '/apps/sim'

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: Bun is not currently a supported package-ecosystem value for Dependabot. This will likely cause Dependabot to fail. Consider keeping 'npm' as the package-ecosystem since Bun can still use package.json and npm-style dependencies.

Suggested change
- package-ecosystem: 'bun'
directory: '/apps/sim'
- package-ecosystem: 'npm'
directory: '/apps/sim'

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 - should be ./apps/sim/ instead of ./apps/sim/db/ to match the workspace structure

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: These two bun install commands can be combined into one for better layer caching: 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: Missing ENTRYPOINT/CMD to specify what the container should run (e.g. drizzle migrations)


# Install dependencies local to scripts directory
npm install --save-dev typescript @types/node @types/react ts-node tsx glob
bun install --save-dev typescript @types/node @types/react ts-node tsx glob

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: Consider adding a check for bun installation before running bun install

Suggested change
bun install --save-dev typescript @types/node @types/react ts-node tsx glob
if ! command -v bun &> /dev/null; then
echo "Error: bun is not installed. Please install bun first."
exit 1
fi
bun install --save-dev typescript @types/node @types/react ts-node tsx glob

Comment thread package.json
"@t3-oss/env-nextjs": "0.13.4",
"@types/bun": "^1.2.12",
"@vercel/analytics": "^1.5.0",
"bun": "^1.2.13",

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: Including bun package in dependencies may cause issues since it's meant to be a runtime/CLI tool. Consider moving to devDependencies or removing if not needed for compilation.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

merged in #371

@waleedlatif1
waleedlatif1 deleted the new-bun branch May 18, 2025 08:03
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