Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions .devcontainer/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@ alias check-db="PGPASSWORD=postgres psql -h db -U postgres -c '\l'"

# Sim Studio specific aliases
alias logs="cd /workspace/apps/sim && tail -f logs/*.log 2>/dev/null || echo 'No log files found'"
alias sim-start="cd /workspace && npm run dev"
alias sim-migrate="cd /workspace/apps/sim && npx drizzle-kit push"
alias sim-generate="cd /workspace/apps/sim && npx drizzle-kit generate"
alias sim-rebuild="cd /workspace && npm run build && npm run dev"
alias docs-dev="cd /workspace/apps/docs && npm run dev"
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

alias docs-dev="cd /workspace/apps/docs && bun run dev"

# Turbo related commands
alias turbo-build="cd /workspace && npx turbo run build"
alias turbo-dev="cd /workspace && npx turbo run dev"
alias turbo-test="cd /workspace && npx turbo run test"
alias turbo-build="cd /workspace && bunx turbo run build"
alias turbo-dev="cd /workspace && bunx turbo run dev"
alias turbo-test="cd /workspace && bunx turbo run test"

# Bun specific commands
alias bun-update="cd /workspace && bun update"
alias bun-add="cd /workspace && bun add"
alias bun-pm="cd /workspace && bun pm"
alias bun-canary="bun upgrade --canary"

# Default to workspace directory
cd /workspace 2>/dev/null || true
Expand All @@ -52,6 +58,12 @@ if [ -z "$SIM_WELCOME_SHOWN" ]; then
echo " turbo-build - Build all apps using Turborepo"
echo " turbo-dev - Start development mode for all apps"
echo " turbo-test - Run tests for all packages"
echo ""
echo "Bun commands:"
echo " bun-update - Update dependencies"
echo " bun-add - Add a new dependency"
echo " bun-pm - Manage dependencies"
echo " bun-canary - Upgrade to the latest canary version of Bun"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
fi
20 changes: 13 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
FROM node:20-bullseye
# Use the latest Bun canary image for development
FROM oven/bun:canary

# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive

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

# Create a non-root user
ARG USERNAME=node
ARG USERNAME=bun
ARG USER_UID=1000
ARG USER_GID=$USER_UID
Comment on lines +16 to 18

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


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

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

# Install global packages
RUN npm install -g drizzle-kit turbo
# Install bun completions
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

RUN echo "source /etc/profile" >> /etc/bash.bashrc

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This directory contains configuration files for Visual Studio Code Dev Container
- Run database migrations
- Configure helpful aliases

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

### Development Commands

Expand Down
12 changes: 6 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"rvest.vs-code-prettier-eslint",
"mikestead.dotenv",
"dsznajder.es7-react-js-snippets",
"steoates.autoimport"
"steoates.autoimport",
"oven.bun-vscode"
]
}
},
Expand All @@ -49,13 +50,12 @@

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

"remoteUser": "node",
"remoteUser": "bun",

"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers-contrib/features/npm-package:1": {
"package": "typescript",
"version": "latest"
}
"ghcr.io/prulloac/devcontainer-features/bun:1": {
"version": "latest"
}
}
}
3 changes: 3 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ services:
dockerfile: .devcontainer/Dockerfile
volumes:
- ..:/workspace:cached
- bun-cache:/home/bun/.bun/cache:delegated
command: sleep infinity
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
- POSTGRES_URL=postgresql://postgres:postgres@db:5432/simstudio
Comment on lines 14 to 15

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: Duplicate database connection strings (DATABASE_URL and POSTGRES_URL) may cause confusion. Consider using only DATABASE_URL.

- BETTER_AUTH_URL=http://localhost:3000
- NEXT_PUBLIC_APP_URL=http://localhost:3000
- BUN_INSTALL_CACHE_DIR=/home/bun/.bun/cache
depends_on:
db:
condition: service_healthy
Expand Down Expand Up @@ -41,3 +43,4 @@ services:

volumes:
postgres-data:
bun-cache:
40 changes: 28 additions & 12 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,34 @@ cp /workspace/.devcontainer/.bashrc ~/.bashrc
echo 'if [ -f ~/.bashrc ]; then . ~/.bashrc; fi' >> ~/.profile

# Clean and reinstall dependencies to ensure platform compatibility
echo "📦 Cleaning and reinstalling npm dependencies..."
echo "📦 Cleaning and reinstalling dependencies..."
if [ -d "node_modules" ]; then
echo "Removing existing node_modules to ensure platform compatibility..."
rm -rf node_modules
rm -rf apps/sim/node_modules
rm -rf apps/docs/node_modules
fi

# Ensure Bun cache directory exists and has correct permissions
mkdir -p ~/.bun/cache
chmod 700 ~/.bun ~/.bun/cache

# Install dependencies with platform-specific binaries
npm install || {
echo "⚠️ npm install had issues but continuing setup..."
echo "Installing dependencies with Bun..."
bun install || {
echo "⚠️ bun install had issues but continuing setup..."
}
Comment on lines +32 to 34

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
}


# Check for native dependencies
echo "Checking for native dependencies compatibility..."
NATIVE_DEPS=$(grep '"trustedDependencies"' apps/sim/package.json || echo "")
if [ ! -z "$NATIVE_DEPS" ]; then
echo "⚠️ Native dependencies detected. Ensuring compatibility with Bun..."
for pkg in $(echo $NATIVE_DEPS | grep -oP '"[^"]*"' | tr -d '"' | grep -v "trustedDependencies"); do
echo "Checking compatibility for $pkg..."
done
Comment on lines +41 to +43

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.

fi

# Set up environment variables if .env doesn't exist for the sim app
if [ ! -f "apps/sim/.env" ]; then
echo "📄 Creating .env file from template..."
Expand All @@ -42,7 +57,7 @@ fi
echo "🗃️ Running database schema generation and migrations..."
echo "Generating schema..."
cd apps/sim
npx drizzle-kit generate
bunx drizzle-kit generate
cd ../..

echo "Waiting for database to be ready..."
Expand All @@ -53,7 +68,7 @@ echo "Waiting for database to be ready..."
if PGPASSWORD=postgres psql -h db -U postgres -c '\q' 2>/dev/null; then
echo "Database is ready!"
cd apps/sim
DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio npx drizzle-kit push
DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio bunx drizzle-kit push
cd ../..
break
fi
Expand All @@ -71,13 +86,14 @@ echo "Waiting for database to be ready..."
cat << EOF >> ~/.bashrc

# Additional Sim Studio Development Aliases
alias migrate="cd /workspace/apps/sim && DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio npx drizzle-kit push"
alias generate="cd /workspace/apps/sim && npx drizzle-kit generate"
alias dev="cd /workspace && npm run dev"
alias build="cd /workspace && npm run build"
alias start="cd /workspace && npm run dev"
alias lint="cd /workspace/apps/sim && npm run lint"
alias test="cd /workspace && npm run test"
alias migrate="cd /workspace/apps/sim && DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio bunx drizzle-kit push"
alias generate="cd /workspace/apps/sim && bunx drizzle-kit generate"
alias dev="cd /workspace && bun run dev"
alias build="cd /workspace && bun run build"
alias start="cd /workspace && bun run dev"
alias lint="cd /workspace/apps/sim && bun run lint"
alias test="cd /workspace && bun run test"
alias bun-update="cd /workspace && bun update"
EOF

# Source the .bashrc to make aliases available immediately
Expand Down
21 changes: 10 additions & 11 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Exclude files from Docker build
.git
.github
node_modules
.next
.vercel
.husky
.env
.env.*
npm-debug.log
LICENSE
NOTICE
.prettierrc
.prettierignore
README.md
.devcontainer
.gitignore
.husky
.github
.devcontainer
.env.example
node_modules
12 changes: 6 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand All @@ -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.**
Expand All @@ -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:**
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: 'apps/sim'
- package-ecosystem: 'bun'
directory: '/apps/sim'
Comment on lines +3 to +4

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: Verify that GitHub's dependabot officially supports 'bun' as a package-ecosystem value. This may cause dependabot to fail if not supported.

Suggested change
- package-ecosystem: 'bun'
directory: '/apps/sim'
- package-ecosystem: 'npm'
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.

style: Leading slash in directory path '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/apps/sim' may cause issues with dependabot's directory resolution. Consider removing the leading slash.

schedule:
interval: 'weekly'
day: 'monday'
Expand All @@ -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'
Expand All @@ -42,7 +42,7 @@ updates:
- '*'

# Root-level dependencies (if any)
- package-ecosystem: 'npm'
- package-ecosystem: 'bun'
directory: '/'
schedule:
interval: 'weekly'
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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

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: registry value should be 'ghcr.io' not 'simstudioai' to match the image names being used

Suggested change
registry: simstudioai
registry: ghcr.io

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
Loading