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 #296

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ next-env.d.ts

#Notion_db
/Notion_DB

#Docs
/docs
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ In general, keep an eye out in the `issues` and `discussions` section of this re
- Pinecone indexes of users on the Starter(free) plan are deleted after 7 days of inactivity. To prevent this, send an API request to Pinecone to reset the counter before 7 days.
- Retry from scratch with a new Pinecone project, index, and cloned repo.

## Build Docker image and run the app

- `docker build . -t gpt4-pdf-chatbot-langchain`
- `docker run -d -p 3000:3000 -e OPENAI_API_KEY= <OPENAI_API_KEY> -e PINECONE_API_KEY=<PINECONE_API_KEY> -e PINECONE_ENVIRONMENT=<PINECONE_ENVIRONMENT> -e PINECONE_INDEX_NAME=<PINECONE_INDEX_NAME> --name gpt4-pdf-chatbot-langchain gpt4-pdf-chatbot-langchain:latest`

## Credit

Frontend of this repo is inspired by [langchain-chat-nextjs](https://github.com/zahidkhawaja/langchain-chat-nextjs)
39 changes: 39 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From node:20.1.0-alpine3.17

# Create non-root group and user
RUN addgroup -S bot \
&& adduser -D -S -h /var/cache/bot -s /sbin/nologin -G bot --uid 1001 bot

# Make Port accessable
EXPOSE 3000/tcp

# Setting env.Variables
ENV PORT=3000
ENV HOST='localhost'
# ENV OPENAI_API_KEY= <OPENAI_API_KEY>
# ENV PINECONE_API_KEY=<PINECONE_API_KEY>
# ENV PINECONE_ENVIRONMENT=<PINECONE_ENVIRONMENT>
# ENV PINECONE_INDEX_NAME=<PINECONE_INDEX_NAME>


# Add some useful tools
RUN apk add --no-cache bash musl curl && \
npm i -g pm2@5.3.0

# Copy project files to directory path
COPY . /usr/share/gpt4-pdf-chatbot-langchain

# Change directory to project directory
WORKDIR /usr/share/gpt4-pdf-chatbot-langchain

# Install dependancies
RUN yarn add sharp && yarn install && npm cache clean --force && npm cache verify && \
# workaround for Nextjs cache folder issue https://github.com/vercel/next.js/issues/10111
mkdir -p /usr/share/gpt4-pdf-chatbot-langchain/.next/cache/images && chmod -R 777 /usr/share/gpt4-pdf-chatbot-langchain/.next/cache/images

# Ingest documents and build Next app
RUN npm run ingest & npm run build

USER 1001

CMD ["pm2-runtime", "start", "yarn --interpreter bash start"]