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 <aditya@climactic.co>
This commit is contained in:
Waleed Latif
2025-05-18 01:01:32 -07:00
committed by GitHub
parent e57d3f79a1
commit 717e17d02a
144 changed files with 5173 additions and 53421 deletions

View File

@@ -214,9 +214,9 @@ If you prefer not to use Docker or Dev Containers:
```
2. **Install Dependencies:**
- Using NPM:
- Using Bun:
```bash
npm install
bun install
```
3. **Set Up Environment:**
@@ -229,14 +229,14 @@ If you prefer not to use Docker or Dev Containers:
- You need a PostgreSQL instance running
- Run migrations:
```bash
npm run db:push
bun run db:push
```
5. **Run the Development Server:**
- With NPM:
- With Bun:
```bash
npm run dev
bun run dev
```
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
1. **Run the Email Preview Server:**
```bash
npm run email:dev
bun run email:dev
```
2. **Access the Preview:**

View File

@@ -26,7 +26,7 @@ Please describe the tests that you ran to verify your changes. Provide instructi
- [ ] 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`)
- [ ] All tests pass locally and in CI (`bun run 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)

View File

@@ -1,7 +1,7 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: 'apps/sim'
- package-ecosystem: 'bun'
directory: '/apps/sim'
schedule:
interval: 'weekly'
day: 'monday'
@@ -21,9 +21,9 @@ updates:
patterns:
- '*'
# Documentation site dependencies (/docs)
- package-ecosystem: 'npm'
directory: 'apps/docs'
# Documentation site dependencies (/apps/docs)
- package-ecosystem: 'bun'
directory: '/apps/docs'
schedule:
interval: 'weekly'
day: 'wednesday'
@@ -42,7 +42,7 @@ updates:
- '*'
# Root-level dependencies (if any)
- package-ecosystem: 'npm'
- package-ecosystem: 'bun'
directory: '/'
schedule:
interval: 'weekly'

64
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,64 @@
name: Build and Publish Docker Image
on:
push:
branches: [main]
tags: ['v*']
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./docker/app.Dockerfile
image: ghcr.io/simstudioai/simstudio
- dockerfile: ./docker/db.Dockerfile
image: ghcr.io/simstudioai/migrations
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: simstudioai
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=sha,format=long
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -15,23 +15,25 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './package-lock.json'
node-version: latest
- name: Install dependencies
run: npm ci
- name: Install Turbo globally
run: npm install -g turbo
run: bun install
- name: Run tests with coverage
env:
NODE_OPTIONS: '--no-warnings'
run: npx turbo run test
NEXT_PUBLIC_APP_URL: 'https://www.simstudio.ai'
ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only
run: bun run test
- name: Build application
env:
@@ -41,7 +43,8 @@ jobs:
STRIPE_WEBHOOK_SECRET: 'dummy_secret_for_ci_only'
RESEND_API_KEY: 'dummy_key_for_ci_only'
AWS_REGION: 'us-west-2'
run: npx turbo run build
ENCRYPTION_KEY: '7cf672e460e430c1fba707575c2b0e2ad5a99dddf9b7b7e3b5646e630861db1c' # dummy key for CI only
run: bun run build
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
@@ -59,18 +62,16 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
- name: Setup Bun
uses: oven-sh/setup-bun@main
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: './package-lock.json'
bun-version: latest
- name: Install dependencies
run: npm ci
run: bun install
- name: Apply migrations
working-directory: ./apps/sim
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: npx drizzle-kit push
run: bunx drizzle-kit push