Skip to content

Commit 717e17d

Browse files
feat(bun): upgrade to bun, reduce docker image size by 95%, upgrade docs & ci (#371)
* 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 --------- Co-authored-by: Aditya Tripathi <[email protected]>
1 parent e57d3f7 commit 717e17d

File tree

144 files changed

+5173
-53421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+5173
-53421
lines changed

.devcontainer/.bashrc

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@ alias check-db="PGPASSWORD=postgres psql -h db -U postgres -c '\l'"
1919

2020
# Sim Studio specific aliases
2121
alias logs="cd /workspace/apps/sim && tail -f logs/*.log 2>/dev/null || echo 'No log files found'"
22-
alias sim-start="cd /workspace && npm run dev"
23-
alias sim-migrate="cd /workspace/apps/sim && npx drizzle-kit push"
24-
alias sim-generate="cd /workspace/apps/sim && npx drizzle-kit generate"
25-
alias sim-rebuild="cd /workspace && npm run build && npm run dev"
26-
alias docs-dev="cd /workspace/apps/docs && npm run dev"
22+
alias sim-start="cd /workspace && bun run dev"
23+
alias sim-migrate="cd /workspace/apps/sim && bunx drizzle-kit push"
24+
alias sim-generate="cd /workspace/apps/sim && bunx drizzle-kit generate"
25+
alias sim-rebuild="cd /workspace && bun run build && bun run start"
26+
alias docs-dev="cd /workspace/apps/docs && bun run dev"
2727

2828
# Turbo related commands
29-
alias turbo-build="cd /workspace && npx turbo run build"
30-
alias turbo-dev="cd /workspace && npx turbo run dev"
31-
alias turbo-test="cd /workspace && npx turbo run test"
29+
alias turbo-build="cd /workspace && bunx turbo run build"
30+
alias turbo-dev="cd /workspace && bunx turbo run dev"
31+
alias turbo-test="cd /workspace && bunx turbo run test"
32+
33+
# Bun specific commands
34+
alias bun-update="cd /workspace && bun update"
35+
alias bun-add="cd /workspace && bun add"
36+
alias bun-pm="cd /workspace && bun pm"
37+
alias bun-canary="bun upgrade --canary"
3238

3339
# Default to workspace directory
3440
cd /workspace 2>/dev/null || true
@@ -52,6 +58,12 @@ if [ -z "$SIM_WELCOME_SHOWN" ]; then
5258
echo " turbo-build - Build all apps using Turborepo"
5359
echo " turbo-dev - Start development mode for all apps"
5460
echo " turbo-test - Run tests for all packages"
61+
echo ""
62+
echo "Bun commands:"
63+
echo " bun-update - Update dependencies"
64+
echo " bun-add - Add a new dependency"
65+
echo " bun-pm - Manage dependencies"
66+
echo " bun-canary - Upgrade to the latest canary version of Bun"
5567
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
5668
echo ""
5769
fi

.devcontainer/Dockerfile

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
1-
FROM node:20-bullseye
1+
# Use the latest Bun canary image for development
2+
FROM oven/bun:canary
23

34
# Avoid warnings by switching to noninteractive
45
ENV DEBIAN_FRONTEND=noninteractive
56

67
# Install necessary packages for development
78
RUN apt-get update \
89
&& apt-get -y install --no-install-recommends \
9-
git curl wget jq sudo postgresql-client \
10+
git curl wget jq sudo postgresql-client vim nano \
11+
bash-completion ca-certificates lsb-release gnupg \
1012
&& apt-get clean -y \
1113
&& rm -rf /var/lib/apt/lists/*
1214

1315
# Create a non-root user
14-
ARG USERNAME=node
16+
ARG USERNAME=bun
1517
ARG USER_UID=1000
1618
ARG USER_GID=$USER_UID
1719

1820
# Add sudo support
1921
RUN echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME \
2022
&& chmod 0440 /etc/sudoers.d/$USERNAME
2123

22-
# Make sure we have the latest npm
23-
RUN npm install -g npm@latest
24+
# Install global packages for development
25+
RUN bun install -g turbo drizzle-kit typescript @types/node
2426

25-
# Install global packages
26-
RUN npm install -g drizzle-kit turbo
27+
# Install bun completions
28+
RUN bun completions > /etc/bash_completion.d/bun
29+
30+
# Set up shell environment
31+
RUN echo "export PATH=$PATH:/home/$USERNAME/.bun/bin" >> /etc/profile
32+
RUN echo "source /etc/profile" >> /etc/bash.bashrc
2733

2834
# Switch back to dialog for any ad-hoc use of apt-get
2935
ENV DEBIAN_FRONTEND=dialog

.devcontainer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This directory contains configuration files for Visual Studio Code Dev Container
3333
- Run database migrations
3434
- Configure helpful aliases
3535

36-
5. Start the application with `sim-start` (alias for `npm run dev`)
36+
5. Start the application with `sim-start` (alias for `bun run dev`)
3737

3838
### Development Commands
3939

.devcontainer/devcontainer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"rvest.vs-code-prettier-eslint",
3939
"mikestead.dotenv",
4040
"dsznajder.es7-react-js-snippets",
41-
"steoates.autoimport"
41+
"steoates.autoimport",
42+
"oven.bun-vscode"
4243
]
4344
}
4445
},
@@ -49,13 +50,12 @@
4950

5051
"postStartCommand": "bash -c 'if [ ! -f ~/.bashrc ] || ! grep -q \"sim-start\" ~/.bashrc; then cp .devcontainer/.bashrc ~/.bashrc; fi'",
5152

52-
"remoteUser": "node",
53+
"remoteUser": "bun",
5354

5455
"features": {
5556
"ghcr.io/devcontainers/features/git:1": {},
56-
"ghcr.io/devcontainers-contrib/features/npm-package:1": {
57-
"package": "typescript",
58-
"version": "latest"
59-
}
57+
"ghcr.io/prulloac/devcontainer-features/bun:1": {
58+
"version": "latest"
59+
}
6060
}
6161
}

.devcontainer/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ services:
77
dockerfile: .devcontainer/Dockerfile
88
volumes:
99
- ..:/workspace:cached
10+
- bun-cache:/home/bun/.bun/cache:delegated
1011
command: sleep infinity
1112
environment:
1213
- NODE_ENV=development
1314
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
1415
- POSTGRES_URL=postgresql://postgres:postgres@db:5432/simstudio
1516
- BETTER_AUTH_URL=http://localhost:3000
1617
- NEXT_PUBLIC_APP_URL=http://localhost:3000
18+
- BUN_INSTALL_CACHE_DIR=/home/bun/.bun/cache
1719
depends_on:
1820
db:
1921
condition: service_healthy
@@ -41,3 +43,4 @@ services:
4143

4244
volumes:
4345
postgres-data:
46+
bun-cache:

.devcontainer/post-create.sh

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,34 @@ cp /workspace/.devcontainer/.bashrc ~/.bashrc
1515
echo 'if [ -f ~/.bashrc ]; then . ~/.bashrc; fi' >> ~/.profile
1616

1717
# Clean and reinstall dependencies to ensure platform compatibility
18-
echo "📦 Cleaning and reinstalling npm dependencies..."
18+
echo "📦 Cleaning and reinstalling dependencies..."
1919
if [ -d "node_modules" ]; then
2020
echo "Removing existing node_modules to ensure platform compatibility..."
2121
rm -rf node_modules
2222
rm -rf apps/sim/node_modules
2323
rm -rf apps/docs/node_modules
2424
fi
2525

26+
# Ensure Bun cache directory exists and has correct permissions
27+
mkdir -p ~/.bun/cache
28+
chmod 700 ~/.bun ~/.bun/cache
29+
2630
# Install dependencies with platform-specific binaries
27-
npm install || {
28-
echo "⚠️ npm install had issues but continuing setup..."
31+
echo "Installing dependencies with Bun..."
32+
bun install || {
33+
echo "⚠️ bun install had issues but continuing setup..."
2934
}
3035

36+
# Check for native dependencies
37+
echo "Checking for native dependencies compatibility..."
38+
NATIVE_DEPS=$(grep '"trustedDependencies"' apps/sim/package.json || echo "")
39+
if [ ! -z "$NATIVE_DEPS" ]; then
40+
echo "⚠️ Native dependencies detected. Ensuring compatibility with Bun..."
41+
for pkg in $(echo $NATIVE_DEPS | grep -oP '"[^"]*"' | tr -d '"' | grep -v "trustedDependencies"); do
42+
echo "Checking compatibility for $pkg..."
43+
done
44+
fi
45+
3146
# Set up environment variables if .env doesn't exist for the sim app
3247
if [ ! -f "apps/sim/.env" ]; then
3348
echo "📄 Creating .env file from template..."
@@ -42,7 +57,7 @@ fi
4257
echo "🗃️ Running database schema generation and migrations..."
4358
echo "Generating schema..."
4459
cd apps/sim
45-
npx drizzle-kit generate
60+
bunx drizzle-kit generate
4661
cd ../..
4762

4863
echo "Waiting for database to be ready..."
@@ -53,7 +68,7 @@ echo "Waiting for database to be ready..."
5368
if PGPASSWORD=postgres psql -h db -U postgres -c '\q' 2>/dev/null; then
5469
echo "Database is ready!"
5570
cd apps/sim
56-
DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio npx drizzle-kit push
71+
DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio bunx drizzle-kit push
5772
cd ../..
5873
break
5974
fi
@@ -71,13 +86,14 @@ echo "Waiting for database to be ready..."
7186
cat << EOF >> ~/.bashrc
7287
7388
# Additional Sim Studio Development Aliases
74-
alias migrate="cd /workspace/apps/sim && DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio npx drizzle-kit push"
75-
alias generate="cd /workspace/apps/sim && npx drizzle-kit generate"
76-
alias dev="cd /workspace && npm run dev"
77-
alias build="cd /workspace && npm run build"
78-
alias start="cd /workspace && npm run dev"
79-
alias lint="cd /workspace/apps/sim && npm run lint"
80-
alias test="cd /workspace && npm run test"
89+
alias migrate="cd /workspace/apps/sim && DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio bunx drizzle-kit push"
90+
alias generate="cd /workspace/apps/sim && bunx drizzle-kit generate"
91+
alias dev="cd /workspace && bun run dev"
92+
alias build="cd /workspace && bun run build"
93+
alias start="cd /workspace && bun run dev"
94+
alias lint="cd /workspace/apps/sim && bun run lint"
95+
alias test="cd /workspace && bun run test"
96+
alias bun-update="cd /workspace && bun update"
8197
EOF
8298

8399
# Source the .bashrc to make aliases available immediately

.dockerignore

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Exclude files from Docker build
2-
.git
3-
.github
4-
node_modules
5-
.next
6-
.vercel
7-
.husky
8-
.env
9-
.env.*
10-
npm-debug.log
1+
LICENSE
2+
NOTICE
3+
.prettierrc
4+
.prettierignore
115
README.md
12-
.devcontainer
6+
.gitignore
7+
.husky
8+
.github
9+
.devcontainer
10+
.env.example
11+
node_modules

.github/CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,9 @@ If you prefer not to use Docker or Dev Containers:
214214
```
215215
2. **Install Dependencies:**
216216
217-
- Using NPM:
217+
- Using Bun:
218218
```bash
219-
npm install
219+
bun install
220220
```
221221
222222
3. **Set Up Environment:**
@@ -229,14 +229,14 @@ If you prefer not to use Docker or Dev Containers:
229229
- You need a PostgreSQL instance running
230230
- Run migrations:
231231
```bash
232-
npm run db:push
232+
bun run db:push
233233
```
234234
235235
5. **Run the Development Server:**
236236
237-
- With NPM:
237+
- With Bun:
238238
```bash
239-
npm run dev
239+
bun run dev
240240
```
241241
242242
6. **Make Your Changes and Test Locally.**
@@ -248,7 +248,7 @@ When working on email templates, you can preview them using a local email previe
248248
1. **Run the Email Preview Server:**
249249
250250
```bash
251-
npm run email:dev
251+
bun run email:dev
252252
```
253253
254254
2. **Access the Preview:**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Please describe the tests that you ran to verify your changes. Provide instructi
2626
- [ ] I have performed a self-review of my own code
2727
- [ ] I have commented my code, particularly in hard-to-understand areas
2828
- [ ] I have added tests that prove my fix is effective or that my feature works
29-
- [ ] All tests pass locally and in CI (`npm test`)
29+
- [ ] All tests pass locally and in CI (`bun run test`)
3030
- [ ] My changes generate no new warnings
3131
- [ ] Any dependent changes have been merged and published in downstream modules
3232
- [ ] I have updated version numbers as needed (if needed)

.github/dependabot.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2
22
updates:
3-
- package-ecosystem: 'npm'
4-
directory: 'apps/sim'
3+
- package-ecosystem: 'bun'
4+
directory: '/apps/sim'
55
schedule:
66
interval: 'weekly'
77
day: 'monday'
@@ -21,9 +21,9 @@ updates:
2121
patterns:
2222
- '*'
2323

24-
# Documentation site dependencies (/docs)
25-
- package-ecosystem: 'npm'
26-
directory: 'apps/docs'
24+
# Documentation site dependencies (/apps/docs)
25+
- package-ecosystem: 'bun'
26+
directory: '/apps/docs'
2727
schedule:
2828
interval: 'weekly'
2929
day: 'wednesday'
@@ -42,7 +42,7 @@ updates:
4242
- '*'
4343

4444
# Root-level dependencies (if any)
45-
- package-ecosystem: 'npm'
45+
- package-ecosystem: 'bun'
4646
directory: '/'
4747
schedule:
4848
interval: 'weekly'

0 commit comments

Comments
 (0)