Skip to content

Commit a85a721

Browse files
authored
Add Dockerfile and docker-compose for unified server (#60)
1 parent a95e146 commit a85a721

3 files changed

Lines changed: 151 additions & 0 deletions

File tree

‎Dockerfile‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
FROM rust:1.85-bookworm AS chef
2+
3+
WORKDIR /app
4+
5+
# System dependencies (for prost-build and rocksdb)
6+
RUN apt-get update && apt-get install -y \
7+
protobuf-compiler \
8+
clang \
9+
libclang-dev \
10+
llvm-dev \
11+
build-essential \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
RUN cargo install cargo-chef
15+
16+
# Planner Stage
17+
FROM chef AS planner
18+
19+
COPY Cargo.toml Cargo.lock ./
20+
COPY crates ./crates
21+
22+
RUN cargo chef prepare --recipe-path recipe.json
23+
24+
# Builder Stage
25+
FROM chef AS builder
26+
27+
COPY --from=planner /app/recipe.json recipe.json
28+
29+
# Building only the dependencies
30+
RUN cargo chef cook --release --recipe-path recipe.json
31+
32+
COPY Cargo.toml Cargo.lock ./
33+
COPY crates ./crates
34+
35+
# Building the binary
36+
RUN cargo build --release --bin server
37+
38+
# Runtime Stage
39+
FROM debian:bookworm-slim
40+
41+
RUN apt-get update && apt-get install -y \
42+
ca-certificates \
43+
&& rm -rf /var/lib/apt/lists/*
44+
45+
RUN useradd -m vortexdb
46+
47+
WORKDIR /app
48+
49+
RUN mkdir -p /data && chown -R vortexdb:vortexdb /data
50+
51+
COPY --from=builder /app/target/release/server /usr/local/bin/server
52+
53+
# Safe defualts
54+
ENV HTTP_HOST=0.0.0.0
55+
ENV HTTP_PORT=3000
56+
ENV GRPC_HOST=0.0.0.0
57+
ENV GRPC_PORT=50051
58+
ENV STORAGE_TYPE=inmemory
59+
ENV INDEX_TYPE=flat
60+
ENV LOGGING=true
61+
ENV DISABLE_HTTP=false
62+
63+
EXPOSE 3000
64+
EXPOSE 50051
65+
66+
USER vortexdb
67+
68+
ENTRYPOINT ["server"]

‎README.md‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,53 @@ Interactive terminal user interface built with [Ratatui](https://github.com/rata
5858
- Vector operations (insert, search, delete)
5959
- Modal dialogs for user input
6060

61+
### Unified Server Startup
62+
63+
VortexDB offers a Dockerfile and a docker-compose for starting up the gRPC and HTTP servers
64+
Steps to get the unified server running:
65+
```
66+
cp .env.example .env
67+
```
68+
69+
The following env vars are important, and are required to be set by the user:
70+
`GRPC_ROOT_PASSWORD`
71+
`DIMENSION`
72+
`DATA_PATH`
73+
74+
**NOTE**: `DATA_PATH` is the directory within the container where persistent data is stored
75+
76+
77+
Setting of the following env vars is optional, as they fallback to safe defaults, but recommended:
78+
| .env Var | Function | Safe Default |
79+
| :--- | :--- | :--- |
80+
| `HTTP_HOST` | Host IP for the HTTP Server | `0.0.0.0` |
81+
| `HTTP_PORT` | Port for the HTTP Server | `3000` |
82+
| `GRPC_HOST` | Host IP for the gRPC Server | `0.0.0.0` |
83+
| `GRPC_PORT` | Port for the gRPC Server | `50051` |
84+
| `STORAGE_TYPE` | Store `inmemory` \| `rocksdb` | `inmemory` |
85+
| `INDEX_TYPE` | Type of Indexer: `flat` \| `kdtree` \| `hnsw` | `flat` |
86+
| `LOGGING` | Enable logs | `true` |
87+
| `DISABLE_HTTP` | Bool flag to run the HTTP Server | `false` |
88+
89+
90+
**NOTE**: CLI flags (e.g. `docker compose run --env` ) take precedence over docker-compose environment values, which in turn override `.env` file variables.
91+
92+
Now you're all set up.
93+
94+
To run the unified server:
95+
```
96+
docker compose up
97+
```
98+
To build the image again and run the unified server (recommended after code changes):
99+
```
100+
docker compose up --build
101+
```
102+
To run only the gRPC server (HTTP server disabled):
103+
```
104+
DISABLE_HTTP=true docker compose up
105+
```
106+
107+
61108

62109
## Roadmap
63110

‎docker-compose.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
services:
2+
vortexdb:
3+
build: .
4+
image: vortexdb:latest
5+
container_name: vortexdb
6+
restart: unless-stopped
7+
8+
env_file:
9+
- .env
10+
11+
environment:
12+
HTTP_HOST: ${HTTP_HOST:-0.0.0.0}
13+
HTTP_PORT: ${HTTP_PORT:-3000}
14+
GRPC_HOST: ${GRPC_HOST:-0.0.0.0}
15+
GRPC_PORT: ${GRPC_PORT:-50051}
16+
17+
STORAGE_TYPE: ${STORAGE_TYPE:-inmemory}
18+
INDEX_TYPE: ${INDEX_TYPE:-flat}
19+
LOGGING: ${LOGGING:-true}
20+
DISABLE_HTTP: ${DISABLE_HTTP:-false}
21+
22+
# Required
23+
GRPC_ROOT_PASSWORD: ${GRPC_ROOT_PASSWORD}
24+
DIMENSION: ${DIMENSION}
25+
26+
DATA_PATH: /data
27+
28+
ports:
29+
- "${HTTP_PORT:-3000}:3000"
30+
- "${GRPC_PORT:-50051}:50051"
31+
32+
volumes:
33+
- vortexdb_data:/data
34+
35+
volumes:
36+
vortexdb_data:

0 commit comments

Comments
 (0)