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/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: