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
# Build stage
FROM rust:1.76-slim-bookworm as builder
WORKDIR /usr/src/app
# Install build dependencies
# build-essential for gcc/linker
# pkg-config and libssl-dev for some dependencies (reqwest/actix)
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy manifests first for caching dependencies
COPY Cargo.toml Cargo.lock ./
# Create dummy src/lib.rs and src/main.rs to build dependencies
RUN mkdir -p src \
&& echo "fn main() {}" > src/main.rs \
&& echo "pub fn dummy() {}" > src/lib.rs
# Build dependencies only (release mode)
# Include features needed for server
RUN cargo build --release --bin vecmindb-server --features http-server
# Now copy the actual source code
COPY src ./src
COPY examples ./examples
# Touch main.rs to force rebuild of the binary
RUN touch src/main.rs
# Build the actual application
RUN cargo build --release --bin vecmindb-server --features http-server
# Runtime stage
FROM debian:bookworm-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Copy the binary from builder
COPY --from=builder /usr/src/app/target/release/vecmindb-server /usr/local/bin/vecmindb-server
# Create data directory
RUN mkdir -p /data
ENV VECMINDB_STORAGE_PATH=/data
ENV VECMINDB_HOST=0.0.0.0
ENV VECMINDB_PORT=8080
# Expose port
EXPOSE 8080
# Run the server
CMD ["vecmindb-server"]