Skip to content
Draft
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
38 changes: 38 additions & 0 deletions .cursor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV BUN_INSTALL=/home/ubuntu/.bun
ENV PATH=/home/ubuntu/.bun/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash \
ca-certificates \
curl \
docker-compose-v2 \
docker.io \
g++ \
git \
iptables \
jq \
make \
openssh-client \
openssl \
postgresql-client \
pkg-config \
python3 \
ripgrep \
sudo \
tmux \
unzip \
&& rm -rf /var/lib/apt/lists/*

RUN if ! getent passwd ubuntu >/dev/null; then useradd -m -s /bin/bash ubuntu; fi \
&& usermod -aG docker ubuntu \
&& echo "ubuntu ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ubuntu \
&& chmod 0440 /etc/sudoers.d/ubuntu

USER ubuntu
WORKDIR /workspace

RUN curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.13"
11 changes: 11 additions & 0 deletions .cursor/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://www.cursor.com/schemas/environment.schema.json",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"install": "bash scripts/cursor-cloud-install.sh",
"start": "bash scripts/cursor-cloud-start.sh",
"ports": [3000, 3001, 3002, 3003, 5432],
"user": "ubuntu"
}
57 changes: 33 additions & 24 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,56 @@
FROM oven/bun:1.3.13-alpine
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04

# Install necessary packages for development
RUN apk add --no-cache \
ENV DEBIAN_FRONTEND=noninteractive
ENV BUN_INSTALL=/home/bun/.bun
ENV TMPDIR=/home/bun/.cache/tmp
ENV PATH=/home/bun/.bun/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash \
bash-completion \
ca-certificates \
git \
g++ \
curl \
wget \
make \
jq \
sudo \
postgresql-client \
vim \
nano \
bash \
bash-completion \
zsh \
zsh-vcs \
ca-certificates \
shadow
pkg-config \
python3 \
postgresql-client \
unzip \
&& rm -rf /var/lib/apt/lists/*

# Create a non-root user with matching UID/GID
ARG USERNAME=bun
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create user group if it doesn't exist
RUN if ! getent group $USER_GID >/dev/null; then \
addgroup -g $USER_GID $USERNAME; \
fi
RUN if getent passwd vscode >/dev/null; then userdel -r vscode; fi \
&& if getent group $USER_GID >/dev/null; then groupmod -n $USERNAME "$(getent group $USER_GID | cut -d: -f1)"; else groupadd --gid $USER_GID $USERNAME; fi \
&& useradd --uid $USER_UID --gid $USER_GID --create-home --shell /bin/bash $USERNAME \
&& echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& mkdir -p /home/$USERNAME/.cache/tmp /home/$USERNAME/.cursor-server \
&& chown -R $USERNAME:$USERNAME /home/$USERNAME/.cache /home/$USERNAME/.cursor-server

# Create user if it doesn't exist
RUN if ! getent passwd $USER_UID >/dev/null; then \
adduser -D -u $USER_UID -G $(getent group $USER_GID | cut -d: -f1) $USERNAME; \
fi
RUN echo "export PATH=\$PATH:/home/$USERNAME/.bun/bin" >> /etc/profile

# Add sudo support
RUN echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
USER bun
RUN curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.13"
USER root

# Set up shell environment
RUN echo "export PATH=\$PATH:/home/$USERNAME/.bun/bin" >> /etc/profile
COPY .devcontainer/install-commands.sh /tmp/install-commands.sh
RUN bash /tmp/install-commands.sh && rm /tmp/install-commands.sh

WORKDIR /workspace

# Expose the ports we're interested in
EXPOSE 3000
EXPOSE 3001
EXPOSE 3002
EXPOSE 3002
EXPOSE 3003
6 changes: 4 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "Sim Dev Environment",
"dockerComposeFile": "docker-compose.yml",
"runServices": ["app", "db"],
"service": "app",
"workspaceFolder": "/workspace",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"containerUser": "bun",

"customizations": {
"vscode": {
Expand All @@ -29,9 +31,9 @@
}
},

"forwardPorts": [3000, 3002, 5432],
"forwardPorts": [3000, 3001, 3002, 3003, 5432],

"postCreateCommand": "bash -c 'bash .devcontainer/post-create.sh || true'",
"postCreateCommand": "bash -c 'true'",

"remoteUser": "bun"
}
18 changes: 13 additions & 5 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,35 @@ services:
- ..:/workspace:cached
- bun-cache:/home/bun/.bun/cache:delegated
command: sleep infinity
user: bun
deploy:
resources:
limits:
memory: 8G
environment:
- NODE_ENV=development
- HOME=/home/bun
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
- BETTER_AUTH_URL=http://localhost:3000
- NEXT_PUBLIC_APP_URL=http://localhost:3000
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your_auth_secret_here}
- ENCRYPTION_KEY=${ENCRYPTION_KEY:-your_encryption_key_here}
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-dev-secret-at-least-32-characters-long}
- ENCRYPTION_KEY=${ENCRYPTION_KEY:-dev-encryption-key-at-least-32-chars}
- API_ENCRYPTION_KEY=${API_ENCRYPTION_KEY:-}
- INTERNAL_API_SECRET=${INTERNAL_API_SECRET:-dev-internal-api-secret-min-32-chars}
- COPILOT_API_KEY=${COPILOT_API_KEY}
- SIM_AGENT_API_URL=${SIM_AGENT_API_URL}
- OLLAMA_URL=${OLLAMA_URL:-http://localhost:11434}
- SOCKET_SERVER_URL=${SOCKET_SERVER_URL:-http://realtime:3002}
- NEXT_PUBLIC_SOCKET_URL=${NEXT_PUBLIC_SOCKET_URL:-}
- BUN_INSTALL_CACHE_DIR=/home/bun/.bun/cache
- TMPDIR=/home/bun/.cache/tmp
depends_on:
db:
condition: service_healthy
migrations:
condition: service_completed_successfully
ports:
- "3000:3000"
- "3001:3001"
- "3003:3003"
working_dir: /workspace

realtime:
Expand All @@ -50,7 +55,10 @@ services:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio
- BETTER_AUTH_URL=http://localhost:3000
- NEXT_PUBLIC_APP_URL=http://localhost:3000
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-your_auth_secret_here}
- BETTER_AUTH_SECRET=${BETTER_AUTH_SECRET:-dev-secret-at-least-32-characters-long}
- INTERNAL_API_SECRET=${INTERNAL_API_SECRET:-dev-internal-api-secret-min-32-chars}
- REDIS_URL=${REDIS_URL:-}
- TMPDIR=/home/bun/.cache/tmp
depends_on:
db:
condition: service_healthy
Expand Down
86 changes: 86 additions & 0 deletions .devcontainer/install-commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash
set -euo pipefail

cat > /usr/local/bin/sim-setup <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
export TMPDIR="${TMPDIR:-$HOME/.cache/tmp}"
mkdir -p "$TMPDIR" ~/.bun/cache
sudo chown -R "$(id -u):$(id -g)" "$TMPDIR" ~/.bun >/dev/null 2>&1 || true
chmod 700 "$TMPDIR" >/dev/null 2>&1 || true
cd /workspace
bash fork-kit/bootstrap-fork.sh
bun install
cd packages/db
bun run db:migrate
EOF

cat > /usr/local/bin/sim-start <<'EOF'
#!/usr/bin/env bash
export TMPDIR="${TMPDIR:-$HOME/.cache/tmp}"
mkdir -p "$TMPDIR"
cd /workspace && exec bun run dev:full
EOF

cat > /usr/local/bin/sim-app <<'EOF'
#!/usr/bin/env bash
export TMPDIR="${TMPDIR:-$HOME/.cache/tmp}"
mkdir -p "$TMPDIR"
cd /workspace && exec bun run dev
EOF

cat > /usr/local/bin/sim-sockets <<'EOF'
#!/usr/bin/env bash
export TMPDIR="${TMPDIR:-$HOME/.cache/tmp}"
mkdir -p "$TMPDIR"
cd /workspace && exec bun run dev:sockets
EOF

cat > /usr/local/bin/sim-migrate <<'EOF'
#!/usr/bin/env bash
export TMPDIR="${TMPDIR:-$HOME/.cache/tmp}"
mkdir -p "$TMPDIR"
cd /workspace/packages/db && exec bun run db:migrate
EOF

cat > /usr/local/bin/sim-generate <<'EOF'
#!/usr/bin/env bash
export TMPDIR="${TMPDIR:-$HOME/.cache/tmp}"
mkdir -p "$TMPDIR"
cd /workspace/packages/db && exec bunx drizzle-kit generate --config=./drizzle.config.ts
EOF

cat > /usr/local/bin/sim-rebuild <<'EOF'
#!/usr/bin/env bash
export TMPDIR="${TMPDIR:-$HOME/.cache/tmp}"
mkdir -p "$TMPDIR"
cd /workspace && bun run build && exec bun run start
EOF

cat > /usr/local/bin/docs-dev <<'EOF'
#!/usr/bin/env bash
export TMPDIR="${TMPDIR:-$HOME/.cache/tmp}"
mkdir -p "$TMPDIR"
cd /workspace/apps/docs && exec bun run dev
EOF

cat > /usr/local/bin/pgc <<'EOF'
#!/usr/bin/env bash
exec env PGPASSWORD=postgres psql -h db -U postgres -d simstudio "$@"
EOF

cat > /usr/local/bin/check-db <<'EOF'
#!/usr/bin/env bash
exec env PGPASSWORD=postgres psql -h db -U postgres -c '\l'
EOF

chmod +x /usr/local/bin/sim-setup \
/usr/local/bin/sim-start \
/usr/local/bin/sim-app \
/usr/local/bin/sim-sockets \
/usr/local/bin/sim-migrate \
/usr/local/bin/sim-generate \
/usr/local/bin/sim-rebuild \
/usr/local/bin/docs-dev \
/usr/local/bin/pgc \
/usr/local/bin/check-db
Loading
Loading