Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker support for easier setup and deployment #28

Merged
merged 3 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
"plugins": ["@typescript-eslint"],
"extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"],
"rules": {
"@typescript-eslint/consistent-type-imports": "warn"
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# database
/prisma/db.sqlite
/prisma/db.sqlite-journal
/db/db.sqlite

# next.js
/.next/
Expand Down
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use the official Node.js image as the base image
FROM node:19-alpine

# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install dependencies
RUN npm ci

# Copy the rest of the application code
COPY . .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure we don't want to be copying everything here (eg: the node modules)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI i made some changes in #34. Node modules are no longer being copied


# Expose the port the app will run on
EXPOSE 3000

# 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"]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,26 @@ 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
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"build": "next build",
"build": "next build --no-lint",
"dev": "next dev",
"postinstall": "prisma generate",
"lint": "next lint",
Expand Down