Skip to content

Commit

Permalink
chore: docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
Dogtiti committed Apr 26, 2023
1 parent bbc63e8 commit d38f982
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 14 deletions.
16 changes: 4 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,14 @@ 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/mysql/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

# Expose the port the app will run on
EXPOSE 3000

ENTRYPOINT ["sh", "entrypoint.sh"]

# Start the application
CMD ["npm", "start"]
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ A convenient setup script is provided to help you get started.
./setup.sh --docker
```

### Docker-compose

Using `docker-compose` deploy

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

### 👷 Local Development Setup

If you wish to develop AgentGPT locally, the easiest way is to
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.0"
services:
autogpt:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- .env.docker:/app/.env
- ./db:/app/db
20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/env sh

# copy .env file if not exists
[ ! -f .env ] && cp .env.example .env

# change schema.prisma
sed -ie 's/mysql/sqlite/g' prisma/schema.prisma
sed -ie 's/@db.Text//' prisma/schema.prisma

# Add Prisma and generate Prisma client
npx prisma generate
# Generate db when not exists
source .env
if [[ ! -f "/app/prisma/${DATABASE_URL:5}" ]]; then
npx prisma migrate dev --name init
npx prisma db push
fi

# run cmd
exec "$@"
1 change: 0 additions & 1 deletion prisma/useSqlite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
cd "$(dirname "$0")"

sed -ie 's/mysql/sqlite/g' schema.prisma
sed -ie 's/postgres/sqlite/g' schema.prisma
sed -ie 's/@db.Text//' schema.prisma
2 changes: 2 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ if [ "$1" = "--docker" ]; then
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
Expand Down
10 changes: 9 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"noImplicitAny": false,
"target": "es2017",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
Expand All @@ -16,6 +17,13 @@
"incremental": true,
"noUncheckedIndexedAccess": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.mjs", "**/*.js"],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.cjs",
"**/*.mjs",
"**/*.js"
],
"exclude": ["node_modules", "venv"]
}

0 comments on commit d38f982

Please sign in to comment.