forked from qdrant/vector-db-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (62 loc) · 2.92 KB
/
Copy pathDockerfile
File metadata and controls
77 lines (62 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Multi-stage Dockerfile for vector-db-benchmark (Rust)
#
# Build: docker build -t vector-db-benchmark .
# Run: docker run --rm vector-db-benchmark --help
# ============================================================
# Stage 1: Build the Rust binary
# ============================================================
FROM rust:bookworm AS builder
# Install HDF5 development libraries, pkg-config, and dpkg-dev (for dpkg-architecture)
RUN apt-get update && apt-get install -y \
libhdf5-dev \
pkg-config \
dpkg-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
# --- Dependency caching layer ---
# Copy only Cargo manifests and lock file first, then build dependencies
# with dummy source files. This layer is cached unless Cargo.toml/lock change.
COPY Cargo.toml Cargo.lock ./
# Create dummy source structure matching all targets
RUN mkdir -p src/bin/vector_db_benchmark/engine src/readers src/redisearch src/vectorsets \
&& echo "fn main() {}" > src/bin/bench_hdf5.rs \
&& echo "fn main() {}" > src/bin/bench_jsonl.rs \
&& echo "fn main() {}" > src/bin/bench_npy.rs \
&& echo "fn main() {}" > src/bin/vector_db_benchmark/main.rs \
&& touch src/lib.rs \
&& touch src/bin/vector_db_benchmark/engine/mod.rs
# Build dependencies only (this layer is cached)
# HDF5_DIR is set dynamically to support both amd64 and arm64
RUN HDF5_DIR=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/hdf5/serial \
cargo build --release --bin vector-db-benchmark 2>/dev/null || true
# Remove dummy source and binary fingerprints, keep compiled dependencies
RUN rm -rf src target/release/vector-db-benchmark target/release/.fingerprint/vector_db_benchmark-*
# --- Source build layer ---
# Copy real source code
COPY src ./src
# Build the actual binary (dependencies are cached, only project code recompiles)
RUN HDF5_DIR=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/hdf5/serial \
cargo build --release --bin vector-db-benchmark
# ============================================================
# Stage 2: Slim runtime image
# ============================================================
FROM debian:bookworm-slim
# Install HDF5 runtime library
RUN apt-get update && apt-get install -y \
libhdf5-103-1 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& ldconfig
WORKDIR /code
# Copy the binary from builder
COPY --from=builder /build/target/release/vector-db-benchmark /usr/local/bin/vector-db-benchmark
# Copy dataset definitions and experiment configurations into the image.
# project_root() searches for datasets/datasets.json as its marker.
COPY datasets/datasets.json /code/datasets/datasets.json
COPY datasets/random-100 /code/datasets/random-100
COPY experiments/configurations /code/experiments/configurations
# Create mount point directories.
# Downloaded datasets go to project_root/datasets/ (checked first by get_path).
RUN mkdir -p /code/datasets /code/results
ENTRYPOINT ["vector-db-benchmark"]
CMD ["--help"]