Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (44 loc) · 1.73 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (44 loc) · 1.73 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
# syntax=docker/dockerfile:1
# =============================================================================
# Phase 4: Docker support for the Vector Search Engine
# Multi-stage build for small production image (~150MB final vs 1GB+)
# =============================================================================
# ---- Builder stage ----
FROM rust:1.80-bookworm AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy manifests first for better caching
COPY Cargo.toml Cargo.lock ./
COPY src ./src
# Build release binary
RUN cargo build --release --bin vector-search-engine
# ---- Runtime stage ----
FROM debian:bookworm-slim
# Install runtime dependencies (for ONNX runtime + TLS for model download + healthcheck)
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 appuser
WORKDIR /app
# Copy the compiled binary
COPY --from=builder /app/target/release/vector-search-engine /usr/local/bin/vector-search-engine
# Create directories for runtime data (models will be downloaded on first use or mounted)
RUN mkdir -p /app/data /app/models && \
chown -R appuser:appuser /app
USER appuser
# Expose default port
EXPOSE 8080
# Default command: run the API server
# You can override with: docker run ... vector-search-engine download-model
ENTRYPOINT ["vector-search-engine"]
CMD ["serve", "--host", "0.0.0.0", "--port", "8080"]
# Healthcheck (uses the /health endpoint we added in Phase 3)
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1