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

Docker support #19

Open
wants to merge 5 commits into
base: master
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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ go.opencensus.io
go.uber.org
testfiles
gopkg.in

Dockerfile
61 changes: 61 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Stage 1: Build Go backend
FROM golang:1.19 AS go-builder

WORKDIR /go/src/app

# Set environment variables for Go
ENV GO111MODULE=on \
GOBIN=/go/src/app/bin \
GOPATH=/root/go \
PATH=$PATH:/go/src/app/bin:/go/src/app/tools/protoc-3.6.1/bin \
DOCKER_BUILDKIT=1

# Copy Go files and dependencies
COPY go.mod go.sum ./
RUN go mod download

# Copy the Go source files
COPY errorlist errorlist/
COPY form form/
COPY serverutil serverutil/
COPY validator validator/
COPY vault-web-server vault-web-server/


# Build the Go application
RUN go build -o main ./vault-web-server

# Stage 2: Build React frontend
FROM node:19 AS js-builder

WORKDIR /app

# Copy JavaScript files and dependencies
COPY package*.json ./
RUN npm install

# Copy the React source files and other assets
COPY components components/
COPY config config/
COPY static static/
COPY webpack.config.js .

# Build the React frontend
RUN npx webpack --config webpack.config.js

# Stage 3: Assemble the final image
FROM debian:buster-slim

RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates poppler-utils && \
rm -rf /var/lib/apt/lists/*


COPY --from=go-builder /go/src/app/main /app/main
COPY --from=js-builder /app/static /static

COPY config/websites.json /config/websites.json

EXPOSE 8100

CMD ["/app/main"]
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,19 @@ With quick setup, you can launch your own version of this Golang server along wi

With The Vault, you can:

- Upload a variety of popular document types via a simple react frontend to create a custom knowledge base
- Upload a variety of popular document types via a simple react frotnend to create a custom knowledge base
- Retrieve accurate and relevant answers based on the content of your uploaded documents
- See the filenames and specific context snippets that inform the answer
- Explore the power of the OP Stack (OpenAI + Pinecone Vector Database) in a user-friendly interface
- Load entire libraries' worth of books into The Vault

## Manual Dependencies

- node: v19
- node: v19.2.0
- go: v1.18.9 darwin/arm64
- poppler

## Setup

### Install manual dependencies

1. Install go:

Follow the go docs [here](https://go.dev/doc/install)

2. Install node v19

I recommend [installing nvm and using it to install node v19](https://medium.com/@iam_vinojan/how-to-install-node-js-and-npm-using-node-version-manager-nvm-143165b16ce1)

3. Install poppler

`sudo apt-get install -y poppler-utils` on Ubuntu, or `brew install poppler` on Mac

### Set up your API keys and endpoints in the `secret` folder

1. Create a new file `secret/openai_api_key` and paste your [OpenAI API key](https://platform.openai.com/docs/api-reference/authentication) into it:
Expand All @@ -52,8 +37,6 @@ I recommend [installing nvm and using it to install node v19](https://medium.com

`echo "your_pinecone_api_key_here" > secret/pinecone_api_key`

When setting up your pinecone index, use a vector size of `1536` and keep all the default settings the same.

3. Create a new file `secret/pinecone_api_endpoint` and paste your [Pinecone API endpoint](https://app.pinecone.io/organizations/) into it:

`echo "https://example-50709b5.svc.asia-southeast1-gcp.pinecone.io" > secret/pinecone_api_endpoint`
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3.8"

services:
vault-web-server:
build: .
image: vault-web-server:latest
ports:
- "8100:8100"
environment:
- OPENAI_API_KEY=your_openai_api_key
- PINECONE_API_KEY=your_pinecone_api_key
- PINECONE_API_ENDPOINT=your_pinecone_api_endpoint
- MAX_FILE_SIZE=3145728 # 3 MB, change as needed
- MAX_TOTAL_UPLOAD_SIZE=3145728 # 3 MB, change as needed
Loading