diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1669c09 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,68 @@ +FROM rust:1.85-bookworm AS chef + +WORKDIR /app + +# System dependencies (for prost-build and rocksdb) +RUN apt-get update && apt-get install -y \ + protobuf-compiler \ + clang \ + libclang-dev \ + llvm-dev \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +RUN cargo install cargo-chef + +# Planner Stage +FROM chef AS planner + +COPY Cargo.toml Cargo.lock ./ +COPY crates ./crates + +RUN cargo chef prepare --recipe-path recipe.json + +# Builder Stage +FROM chef AS builder + +COPY --from=planner /app/recipe.json recipe.json + +# Building only the dependencies +RUN cargo chef cook --release --recipe-path recipe.json + +COPY Cargo.toml Cargo.lock ./ +COPY crates ./crates + +# Building the binary +RUN cargo build --release --bin server + +# Runtime Stage +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd -m vortexdb + +WORKDIR /app + +RUN mkdir -p /data && chown -R vortexdb:vortexdb /data + +COPY --from=builder /app/target/release/server /usr/local/bin/server + +# Safe defualts +ENV HTTP_HOST=0.0.0.0 +ENV HTTP_PORT=3000 +ENV GRPC_HOST=0.0.0.0 +ENV GRPC_PORT=50051 +ENV STORAGE_TYPE=inmemory +ENV INDEX_TYPE=flat +ENV LOGGING=true +ENV DISABLE_HTTP=false + +EXPOSE 3000 +EXPOSE 50051 + +USER vortexdb + +ENTRYPOINT ["server"] diff --git a/README.md b/README.md index a2dde54..c7afde2 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,45 @@ Interactive terminal user interface built with [Ratatui](https://github.com/rata - Vector operations (insert, search, delete) - Modal dialogs for user input +### Unified Server Startup + +VortexDB offers a Dockerfile and a docker-compose for starting up the gRPC and HTTP servers +Steps to get the unified server running: +``` +cp .env.example .env +``` + +The following env vars are important, and are required to be set by the user: +`GRPC_ROOT_PASSWORD` +`DIMENSION` +`DATA_PATH` + +**NOTE**: `DATA_PATH` is the directory within the container where persistent data is stored + + +Setting of the following env vars is optional, as they fallback to safe defaults, but recommended: +| .env Var | Function | Safe Default | +| :--- | :--- | :--- | +| `HTTP_HOST` | Host IP for the HTTP Server | `0.0.0.0` | +| `HTTP_PORT` | Port for the HTTP Server | `3000` | +| `GRPC_HOST` | Host IP for the gRPC Server | `0.0.0.0` | +| `GRPC_PORT` | Port for the gRPC Server | `50051` | +| `STORAGE_TYPE` | Store `inmemory` \| `rocksdb` | `inmemory` | +| `INDEX_TYPE` | Type of Indexer: `flat` \| `kdtree` \| `hnsw` | `flat` | +| `LOGGING` | Enable logs | `true` | +| `DISABLE_HTTP` | Bool flag to run the HTTP Server | `false` | + + +**NOTE**: CLI flags (e.g. `docker compose run --env` ) take precedence over docker-compose environment values, which in turn override `.env` file variables. + +Now you're all set up. + +To run the unified server: +``` +docker compose up +``` + + ## Roadmap diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..97a67ba --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +services: + vortexdb: + image: vortexdb:latest + container_name: vortexdb + restart: unless-stopped + + env_file: + - .env + + environment: + HTTP_HOST: ${HTTP_HOST:-0.0.0.0} + HTTP_PORT: ${HTTP_PORT:-3000} + GRPC_HOST: ${GRPC_HOST:-0.0.0.0} + GRPC_PORT: ${GRPC_PORT:-50051} + + STORAGE_TYPE: ${STORAGE_TYPE:-inmemory} + INDEX_TYPE: ${INDEX_TYPE:-flat} + LOGGING: ${LOGGING:-true} + DISABLE_HTTP: ${DISABLE_HTTP:-false} + + # Required + GRPC_ROOT_PASSWORD: ${GRPC_ROOT_PASSWORD} + DIMENSION: ${DIMENSION} + + DATA_PATH: /data + + ports: + - "${HTTP_PORT:-3000}:3000" + - "${GRPC_PORT:-50051}:50051" + + volumes: + - vortexdb_data:/data + +volumes: + vortexdb_data: