Skip to content

Commit

Permalink
✨ Add docker configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
awtkns committed Apr 12, 2023
1 parent 933fccd commit 26828b1
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/.git
**/node_modules
**/idea
**/.next
**/aws
**/.husky
**/venv
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ yarn-error.log*
# 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

# vercel
.vercel
Expand Down
12 changes: 9 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ RUN npm ci

# Copy the rest of the application code
COPY . .
RUN mv .env.docker .env \
&& sed -ie 's/postgresql/sqlite/g' prisma/schema.prisma \
&& sed -ie 's/@db.Text//' prisma/schema.prisma

# Expose the port the app will run on
EXPOSE 3000

# Add Prisma and generate Prisma client
RUN npx prisma generate \
&& npx prisma migrate dev --name init \
&& npx prisma db push

# Build the Next.js app
RUN npm run build

# Add Prisma and generate Prisma client
RUN npx prisma generate

# Start the application
CMD ["npm", "start"]
CMD ["npm", "start"]
36 changes: 12 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</p>

---

<h2 align="center">
💝 Support the Advancement of AgentGPT!! 💝
</h2>
Expand All @@ -35,7 +36,6 @@ By sponsoring this free, open-source project, you not only have the opportunity
<a href="https://github.com/sponsors/reworkd-admin">👉 Click here</a> to support the project
</p>


---

AgentGPT allows you to configure and deploy Autonomous AI agents.
Expand Down Expand Up @@ -65,6 +65,17 @@ More Coming soon...

## 👨‍🚀 Getting Started

### 🐋 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
```

### 🛠️ Manual Setup

> 🚧 You will need [Nodejs +16 (LTS recommended)](https://nodejs.org/en/) installed.
1. Fork this project:
Expand Down Expand Up @@ -112,26 +123,3 @@ npx prisma db push
# Run the project:
npm run dev
```

## Run in docker

```bash
# set the environment variable NEXTAUTH_SECRET and OPENAI_API_KEY
OPENAI_API_KEY="sk..."
NEXTAUTH_SECRET=$(openssl rand -base64 32)

echo "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

# Build docker image
docker build -t agentgpt .

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

# Run docker
docker run -d --name agentgpt -p 3000:3000 -v $(pwd)/db:/app/db agentgpt
```
5 changes: 5 additions & 0 deletions prisma/use_sqllite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
cd "$(dirname "$0")"

sed -ie 's/postgresql/sqlite/g' schema.prisma
sed -ie 's/@db.Text//' schema.prisma
23 changes: 23 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
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\
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

# Build docker image
docker build -t agentgpt .

# 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
5 changes: 0 additions & 5 deletions src/server/api/routers/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ export const exampleRouter = createTRPCRouter({
greeting: `Hello ${input.text}`,
};
}),

getAll: publicProcedure.query(({ ctx }) => {
return ctx.prisma.example.findMany();
}),

getSecretMessage: protectedProcedure.query(() => {
return "you can now see this secret message!";
}),
Expand Down

0 comments on commit 26828b1

Please sign in to comment.