From 5189e1c4d17e699d64befac6d6f08b3e79c6cecd Mon Sep 17 00:00:00 2001 From: Haytham Amin Date: Tue, 16 May 2023 06:35:56 -0700 Subject: [PATCH 1/2] add DOcker support --- .gitignore | 3 +++ README.md | 4 ++++ dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 dockerfile diff --git a/.gitignore b/.gitignore index 1759b24fb..0fdbc2cf5 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,6 @@ next-env.d.ts #Notion_db /Notion_DB + +#Docs +/docs \ No newline at end of file diff --git a/README.md b/README.md index 5696be598..c4d0375ff 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,10 @@ 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= -e PINECONE_API_KEY= -e PINECONE_ENVIRONMENT= -e 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) diff --git a/dockerfile b/dockerfile new file mode 100644 index 000000000..d17592f53 --- /dev/null +++ b/dockerfile @@ -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= +# ENV PINECONE_API_KEY= +# ENV PINECONE_ENVIRONMENT= +# ENV 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"] \ No newline at end of file From e2d5df88cf63324d43ab76194654f1a234aa4a13 Mon Sep 17 00:00:00 2001 From: Haytham Amin Date: Tue, 16 May 2023 06:42:01 -0700 Subject: [PATCH 2/2] added missing new line to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c4d0375ff..2403a453b 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ In general, keep an eye out in the `issues` and `discussions` section of this re - `docker build . -t gpt4-pdf-chatbot-langchain` - `docker run -d -p 3000:3000 -e OPENAI_API_KEY= -e PINECONE_API_KEY= -e PINECONE_ENVIRONMENT= -e 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)