| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4d07eaf commit 652e0b2
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ alias ..="cd .." | |||
| 14 | 14 | alias ...="cd ../.." | |
| 15 | 15 | ||
| 16 | 16 | # Database aliases | |
| 17 | - alias pgc="PGPASSWORD=postgres psql -h db -U postgres -d postgres" | ||
| 17 | + alias pgc="PGPASSWORD=postgres psql -h db -U postgres -d simstudio" | ||
| 18 | 18 | alias check-db="PGPASSWORD=postgres psql -h db -U postgres -c '\l'" | |
| 19 | 19 | ||
| 20 | 20 | # Sim Studio specific aliases | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,15 +3,10 @@ FROM node:20-bullseye | |||
| 3 | 3 | # Avoid warnings by switching to noninteractive | |
| 4 | 4 | ENV DEBIAN_FRONTEND=noninteractive | |
| 5 | 5 | ||
| 6 | - # Configure apt and install packages | ||
| 6 | + # Install necessary packages for development | ||
| 7 | 7 | RUN apt-get update \ | |
| 8 | - && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ | ||
| 9 | - # Install git, process tools, lsb-release | ||
| 10 | - && apt-get -y install git procps lsb-release \ | ||
| 11 | - # Install other dependencies | ||
| 12 | - && apt-get -y install curl wget jq sudo \ | ||
| 13 | - # Clean up | ||
| 14 | - && apt-get autoremove -y \ | ||
| 8 | + && apt-get -y install --no-install-recommends \ | ||
| 9 | + git curl wget jq sudo postgresql-client \ | ||
| 15 | 10 | && apt-get clean -y \ | |
| 16 | 11 | && rm -rf /var/lib/apt/lists/* | |
| 17 | 12 | ||
@@ -20,10 +15,8 @@ ARG USERNAME=node | |||
| 20 | 15 | ARG USER_UID=1000 | |
| 21 | 16 | ARG USER_GID=$USER_UID | |
| 22 | 17 | ||
| 23 | - # [Optional] Add sudo support | ||
| 24 | - RUN apt-get update \ | ||
| 25 | - && apt-get install -y sudo \ | ||
| 26 | - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
| 18 | + # Add sudo support | ||
| 19 | + RUN echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME \ | ||
| 27 | 20 | && chmod 0440 /etc/sudoers.d/$USERNAME | |
| 28 | 21 | ||
| 29 | 22 | # Make sure we have the latest npm | |
@@ -32,15 +25,10 @@ RUN npm install -g npm@latest | |||
| 32 | 25 | # Install global packages | |
| 33 | 26 | RUN npm install -g drizzle-kit | |
| 34 | 27 | ||
| 35 | - # Install dependencies for Postgres client | ||
| 36 | - RUN apt-get update && apt-get -y install --no-install-recommends \ | ||
| 37 | - postgresql-client \ | ||
| 38 | - && rm -rf /var/lib/apt/lists/* | ||
| 39 | - | ||
| 40 | 28 | # Switch back to dialog for any ad-hoc use of apt-get | |
| 41 | 29 | ENV DEBIAN_FRONTEND=dialog | |
| 42 | 30 | ||
| 43 | 31 | WORKDIR /workspace | |
| 44 | 32 | ||
| 45 | 33 | # Expose the ports we're interested in | |
| 46 | - EXPOSE 3000 | ||
| 34 | + EXPOSE 3000 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,9 +52,6 @@ | |||
| 52 | 52 | "remoteUser": "node", | |
| 53 | 53 | ||
| 54 | 54 | "features": { | |
| 55 | - "ghcr.io/devcontainers/features/node:1": { | ||
| 56 | - "version": "20" | ||
| 57 | - }, | ||
| 58 | 55 | "ghcr.io/devcontainers/features/git:1": {}, | |
| 59 | 56 | "ghcr.io/devcontainers-contrib/features/npm-package:1": { | |
| 60 | 57 | "package": "typescript", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,26 +9,34 @@ services: | |||
| 9 | 9 | - ..:/workspace:cached | |
| 10 | 10 | command: sleep infinity | |
| 11 | 11 | environment: | |
| 12 | - - DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres | ||
| 13 | - - NEXT_PUBLIC_SUPABASE_URL=${NEXT_PUBLIC_SUPABASE_URL:-http://db:5432} | ||
| 14 | - - NEXT_PUBLIC_SUPABASE_ANON_KEY=${NEXT_PUBLIC_SUPABASE_ANON_KEY:-your-anon-key} | ||
| 12 | + - NODE_ENV=development | ||
| 13 | + - DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio | ||
| 14 | + - POSTGRES_URL=postgresql://postgres:postgres@db:5432/simstudio | ||
| 15 | + - BETTER_AUTH_URL=http://localhost:3000 | ||
| 16 | + - NEXT_PUBLIC_APP_URL=http://localhost:3000 | ||
| 15 | 17 | depends_on: | |
| 16 | - - db | ||
| 17 | - network_mode: service:db | ||
| 18 | + db: | ||
| 19 | + condition: service_healthy | ||
| 20 | + ports: | ||
| 21 | + - "3000:3000" | ||
| 18 | 22 | working_dir: /workspace/sim | |
| 19 | 23 | ||
| 20 | 24 | db: | |
| 21 | - image: postgres:14 | ||
| 25 | + image: postgres:16 | ||
| 22 | 26 | restart: unless-stopped | |
| 23 | 27 | volumes: | |
| 24 | 28 | - postgres-data:/var/lib/postgresql/data | |
| 25 | 29 | environment: | |
| 26 | - POSTGRES_PASSWORD: postgres | ||
| 27 | - POSTGRES_USER: postgres | ||
| 28 | - POSTGRES_DB: postgres | ||
| 30 | + - POSTGRES_USER=postgres | ||
| 31 | + - POSTGRES_PASSWORD=postgres | ||
| 32 | + - POSTGRES_DB=simstudio | ||
| 29 | 33 | ports: | |
| 30 | 34 | - "5432:5432" | |
| 31 | - - "3000:3000" | ||
| 35 | + healthcheck: | ||
| 36 | + test: ["CMD-SHELL", "pg_isready -U postgres"] | ||
| 37 | + interval: 5s | ||
| 38 | + timeout: 5s | ||
| 39 | + retries: 5 | ||
| 32 | 40 | ||
| 33 | 41 | volumes: | |
| 34 | 42 | postgres-data: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,19 +29,22 @@ npm install || { | |||
| 29 | 29 | # Set up environment variables if .env doesn't exist | |
| 30 | 30 | if [ ! -f ".env" ]; then | |
| 31 | 31 | echo "📄 Creating .env file from template..." | |
| 32 | - cp .env.example .env 2>/dev/null || echo "DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres" > .env | ||
| 32 | + cp .env.example .env 2>/dev/null || echo "DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio" > .env | ||
| 33 | 33 | fi | |
| 34 | 34 | ||
| 35 | - # Run database migrations | ||
| 36 | - echo "🗃️ Running database migrations..." | ||
| 35 | + # Generate schema and run database migrations | ||
| 36 | + echo "🗃️ Running database schema generation and migrations..." | ||
| 37 | + echo "Generating schema..." | ||
| 38 | + npx drizzle-kit generate | ||
| 39 | + | ||
| 37 | 40 | echo "Waiting for database to be ready..." | |
| 38 | 41 | # Try to connect to the database, but don't fail the script if it doesn't work | |
| 39 | 42 | ( | |
| 40 | 43 | timeout=60 | |
| 41 | 44 | while [ $timeout -gt 0 ]; do | |
| 42 | 45 | if PGPASSWORD=postgres psql -h db -U postgres -c '\q' 2>/dev/null; then | |
| 43 | 46 | echo "Database is ready!" | |
| 44 | - npx drizzle-kit push | ||
| 47 | + DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio npx drizzle-kit push | ||
| 45 | 48 | break | |
| 46 | 49 | fi | |
| 47 | 50 | echo "Database is unavailable - sleeping (${timeout}s remaining)" | |
@@ -58,7 +61,7 @@ echo "Waiting for database to be ready..." | |||
| 58 | 61 | cat << EOF >> ~/.bashrc | |
| 59 | 62 | ||
| 60 | 63 | # Additional Sim Studio Development Aliases | |
| 61 | - alias migrate="cd /workspace/sim && npx drizzle-kit push" | ||
| 64 | + alias migrate="cd /workspace/sim && DATABASE_URL=postgresql://postgres:postgres@db:5432/simstudio npx drizzle-kit push" | ||
| 62 | 65 | alias generate="cd /workspace/sim && npx drizzle-kit generate" | |
| 63 | 66 | alias dev="cd /workspace/sim && npm run dev" | |
| 64 | 67 | alias build="cd /workspace/sim && npm run build" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,16 @@ COPY sim/ ./ | |||
| 9 | 9 | # Install dependencies | |
| 10 | 10 | RUN npm install | |
| 11 | 11 | ||
| 12 | + # Generate database schema | ||
| 13 | + RUN npx drizzle-kit generate | ||
| 14 | + | ||
| 12 | 15 | EXPOSE 3000 | |
| 13 | 16 | ||
| 17 | + # Create a startup script that will run migrations and then start the app | ||
| 18 | + RUN echo '#!/bin/sh\nnpx drizzle-kit push\nexec "$@"' > /app/docker-entrypoint.sh && \ | ||
| 19 | + chmod +x /app/docker-entrypoint.sh | ||
| 20 | + | ||
| 21 | + ENTRYPOINT ["/app/docker-entrypoint.sh"] | ||
| 22 | + | ||
| 14 | 23 | # Default to development mode | |
| 15 | 24 | CMD ["npm", "run", "dev"] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ There are several ways to self-host Sim Studio: | |||
| 36 | 36 | git clone https://github.com/YOUR_USERNAME/sim.git | |
| 37 | 37 | cd sim | |
| 38 | 38 | ||
| 39 | - # Create environment file | ||
| 39 | + # Create environment file and update with required environment variables (BETTER_AUTH_SECRET) | ||
| 40 | 40 | cp sim/.env.example sim/.env | |
| 41 | 41 | ||
| 42 | 42 | # Start the Docker environment | |
@@ -140,4 +140,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file | |||
| 140 | 140 | ||
| 141 | 141 | ## | |
| 142 | 142 | ||
| 143 | - <p align="center">Made with ❤️ by the Sim Studio Team</p> | ||
| 143 | + <p align="center">Made with ❤️ by the Sim Studio Team</p> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,11 +18,11 @@ services: | |||
| 18 | 18 | - BETTER_AUTH_URL=http://localhost:3000 | |
| 19 | 19 | - NEXT_PUBLIC_APP_URL=http://localhost:3000 | |
| 20 | 20 | depends_on: | |
| 21 | - - db | ||
| 22 | - command: npm run dev | ||
| 21 | + db: | ||
| 22 | + condition: service_healthy | ||
| 23 | 23 | ||
| 24 | 24 | db: | |
| 25 | - image: postgres:16-alpine | ||
| 25 | + image: postgres:16 | ||
| 26 | 26 | restart: always | |
| 27 | 27 | ports: | |
| 28 | 28 | - "5432:5432" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,12 +5,12 @@ DATABASE_URL="postgresql://postgres:password@localhost:5432/postgres" | |||
| 5 | 5 | BETTER_AUTH_SECRET=your_secret_key # Use `openssl rand -hex 32` to generate, or visit https://www.better-auth.com/docs/installation | |
| 6 | 6 | BETTER_AUTH_URL=http://localhost:3000 | |
| 7 | 7 | ||
| 8 | + ## Security (Required) | ||
| 9 | + ENCRYPTION_KEY=your_encryption_key # Use `openssl rand -hex 64` to generate | ||
| 10 | + | ||
| 8 | 11 | # Email Provider (Optional) | |
| 9 | 12 | # RESEND_API_KEY= # Uncomment and add your key from https://resend.com to send actual emails | |
| 10 | 13 | # If left commented out, emails will be logged to console instead | |
| 11 | 14 | ||
| 12 | - # App URL (Required) | ||
| 13 | - NEXT_PUBLIC_APP_URL=http://localhost:3000 | ||
| 14 | - | ||
| 15 | 15 | # StackBlitz (Webcontainer) API Key (Optional, for handling sandboxed code execution for functions/custom-tools) | |
| 16 | 16 | # WEBCONTAINER_CLIENT_ID= # Uncomment and add your key from https://stackblitz.com/docs/webcontainer-api#webcontainer-client-id | |
| Back | FazBrowse Home | New Git URL |
0 commit comments