Skip to content

Commit

Permalink
🔨 Improve local development setup to be SQLite compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
awtkns committed Apr 12, 2023
1 parent b904d5d commit 8d24dec
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 25 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ yarn-error.log*

# local env files
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
.env
.env*.local
.env*.docker
.env*

# vercel
.vercel
Expand Down
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ This platform is currently in beta, we are currently working on:
- Users and authentication 🔐
- Stripe integration for a lower limit paid version (So we can stop worrying about infra costs) 💵


More Coming soon...

## 🚀 Tech Stack
Expand All @@ -70,18 +69,27 @@ More Coming soon...

## 👨‍🚀 Getting Started

### 🐋 Docker Setup
### 🐳 Docker Setup

The easiest way to run AgentGPT locally is by using docker.
A convenient setup script is provided to help you get started.

```bash
./setup.sh
./setup.sh --docker
```

### 👷 Local Development Setup

If you wish to develop AgentGPT locally, the easiest way is to
use the provided setup script.

```bash
./setup.sh --local
```

### 🛠️ Manual Setup

> 🚧 You will need [Nodejs +16 (LTS recommended)](https://nodejs.org/en/) installed.
> 🚧 You will need [Nodejs +18 (LTS recommended)](https://nodejs.org/en/) installed.
1. Fork this project:

Expand Down Expand Up @@ -112,15 +120,21 @@ NODE_ENV=development
# Generate a secret with `openssl rand -base64 32`
NEXTAUTH_SECRET=changeme
NEXTAUTH_URL=http://localhost:3000

# Prisma
DATABASE_URL=file:./db.sqlite

# External APIs:
# Your open api key
OPENAI_API_KEY=changeme
```

5. Ready 🥳, now run:
5. Modify prisma schema to use sqlite:

```bash
./prisma/useSqlite.sh
```

**Note:** This only needs to be done if you wish to use sqlite.

6. Ready 🥳, now run:

```bash
# Create database migrations
Expand Down
8 changes: 4 additions & 4 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ generator client {
}

datasource db {
provider = "postgresql"
provider = "sqlite"
url = env("DATABASE_URL")
}

Expand All @@ -20,12 +20,12 @@ model Account {
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
id_token String?
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Expand Down
File renamed without changes.
23 changes: 13 additions & 10 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ cd "$(dirname "$0")" || exit
echo -n "Enter your OpenAI Key (eg: sk...): "
read OPENAI_API_KEY

# set the environment variable NEXTAUTH_SECRET and OPENAI_API_KEY
NEXTAUTH_SECRET=$(openssl rand -base64 32)

printf "NODE_ENV=development\n\
ENV="NODE_ENV=development\n\
NEXTAUTH_SECRET=$NEXTAUTH_SECRET\n\
NEXTAUTH_URL=http://localhost:3000\n\
OPENAI_API_KEY=$OPENAI_API_KEY\n\
DATABASE_URL=file:../db/db.sqlite\n" > .env.docker
DATABASE_URL=file:../db/db.sqlite\n"

# Build docker image
docker build -t agentgpt .
printf $ENV > .env

# Create db dir for db.sqlite
mkdir -p $(pwd)/db

# Run docker
docker run -d --name agentgpt -p 3000:3000 -v $(pwd)/db:/app/db agentgpt
if [ "$1" = "--docker" ]; then
printf $ENV > .env.docker
docker build -t agentgpt .
docker run -d --name agentgpt -p 3000:3000 -v $(pwd)/db:/app/db agentgpt
else
printf $ENV > .env
./prisma/useSqlite.sh
npm install
npm run dev
fi

0 comments on commit 8d24dec

Please sign in to comment.