forked from ElricLiu/AutoGPT-Next-Web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·42 lines (35 loc) · 1.07 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
cd "$(dirname "$0")" || exit
is_valid_sk_key() {
local api_key=$1
local pattern="^sk-[a-zA-Z0-9]{48}$"
[[ $api_key =~ $pattern ]] && return 0 || return 1
}
echo -n "Enter your OpenAI Key (eg: sk...) or press enter to continue with no key: "
read OPENAI_API_KEY
if is_valid_sk_key $OPENAI_API_KEY || [ -z "$OPENAI_API_KEY" ]; then
echo "Valid API key"
else
echo "Invalid API key. Please ensure that you have billing set up on your OpenAI account"
exit
fi
NEXTAUTH_SECRET=$(openssl rand -base64 32)
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"
printf $ENV > .env
if [ "$1" = "--docker" ]; then
printf $ENV > .env.docker
source .env.docker
docker build --build-arg NODE_ENV=$NODE_ENV -t agentgpt .
docker run -d --name agentgpt -p 3000:3000 -v $(pwd)/db:/app/db agentgpt
elif [ "$1" = "--docker-compose" ]; then
docker-compose up -d --remove-orphans
else
printf $ENV > .env
./prisma/useSqlite.sh
npm install
npm run dev
fi