diff --git a/README.md b/README.md index 7ad7a0418..417e7e3a9 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,18 @@ PINECONE_INDEX_NAME= Once you've verified that the embeddings and content have been successfully added to your Pinecone, you can run the app `npm run dev` to launch the local dev environment, and then type a question in the chat interface. +## Docker with Docker Compose + +**Training the Model** +``` +docker-compose build train +``` + +**Running Web** +``` +docker-compose build web && docker-compose up web +``` + ## Troubleshooting In general, keep an eye out in the `issues` and `discussions` section of this repo for solutions. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 000000000..2dc9f0090 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,25 @@ +services: + web: + container_name: gpt4pdf_web + build: + context: ./ + dockerfile: dockerfile-web + working_dir: /app + restart: unless-stopped + volumes: + - .:/app + - ./docs:/app + ports: + - "3000:3000" + train: + container_name: gpt4pdf_train + build: + context: ./ + dockerfile: dockerfile-train + working_dir: /app + restart: unless-stopped + volumes: + - .:/app + - ./docs:/app + ports: + - "3001:3001" \ No newline at end of file diff --git a/dockerfile-train b/dockerfile-train new file mode 100644 index 000000000..d570b35d1 --- /dev/null +++ b/dockerfile-train @@ -0,0 +1,26 @@ +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 + + +# Add some useful tools +RUN apk add --no-cache bash musl curl && \ + npm i -g pm2@5.3.0 + + +# Change directory to project directory +WORKDIR /app + +ADD . /app +RUN source .env +# Install dependancies +RUN yarn add sharp && yarn install && npm cache clean --force && npm cache verify + +# Ingest documents and build Next app +RUN npm run ingest + +USER 1001 + +CMD ["npm", "run", "ingest"] \ No newline at end of file diff --git a/dockerfile-web b/dockerfile-web new file mode 100644 index 000000000..339ae3205 --- /dev/null +++ b/dockerfile-web @@ -0,0 +1,19 @@ +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 + +# Change directory to project directory +WORKDIR /app + +ADD . /app +RUN source .env + +RUN npm install -g next +# Install dependancies +RUN yarn install + +USER 1001 + +CMD ["npm", "run", "dev"] \ No newline at end of file diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 000000000..e69de29bb