mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-23 04:27:11 +00:00
fix: resolve macOS clippy unreachable_code and Docker workspace layout
- Add #[allow(unreachable_code)] for NEON fallback in distance/mod.rs (ARM always returns before the Scalar fallback, causing clippy error on macOS) - Restructure standalone Dockerfile to use workspace layout so dependency crates with workspace inheritance (edition.workspace, version.workspace) can resolve correctly during Docker builds Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
parent
161f890ddb
commit
0dcbebc67c
2 changed files with 76 additions and 31 deletions
|
|
@ -32,30 +32,79 @@ RUN apt-get update && apt-get install -y \
|
|||
# Install cargo-pgrx
|
||||
RUN cargo install cargo-pgrx --version 0.12.9 --locked
|
||||
|
||||
# Set up workspace
|
||||
WORKDIR /build
|
||||
# Set up workspace root — dependency crates use workspace inheritance
|
||||
WORKDIR /workspace
|
||||
|
||||
# Create a minimal standalone Cargo.toml for ruvector-postgres
|
||||
# (not the workspace version)
|
||||
COPY crates/ruvector-postgres/ ./
|
||||
# Create a minimal workspace Cargo.toml so dependency crates can resolve
|
||||
# workspace inheritance (edition.workspace, version.workspace, etc.)
|
||||
RUN cat > /workspace/Cargo.toml << 'WORKSPACE_EOF'
|
||||
[workspace]
|
||||
members = [
|
||||
"crates/ruvector-postgres",
|
||||
"crates/ruvector-solver",
|
||||
"crates/ruvector-math",
|
||||
"crates/ruvector-attention",
|
||||
"crates/sona",
|
||||
"crates/ruvector-domain-expansion",
|
||||
"crates/ruvector-mincut-gated-transformer",
|
||||
]
|
||||
resolver = "2"
|
||||
|
||||
# Copy the ruvector-mincut-gated-transformer dependency (required for gated-transformer feature)
|
||||
COPY crates/ruvector-mincut-gated-transformer /build/../ruvector-mincut-gated-transformer/
|
||||
[workspace.package]
|
||||
version = "2.0.4"
|
||||
edition = "2021"
|
||||
rust-version = "1.77"
|
||||
license = "MIT"
|
||||
authors = ["Ruvector Team"]
|
||||
repository = "https://github.com/ruvnet/ruvector"
|
||||
|
||||
# Copy v0.3 dependencies
|
||||
COPY crates/ruvector-solver /build/../ruvector-solver/
|
||||
COPY crates/ruvector-math /build/../ruvector-math/
|
||||
COPY crates/ruvector-attention /build/../ruvector-attention/
|
||||
COPY crates/sona /build/../sona/
|
||||
COPY crates/ruvector-domain-expansion /build/../ruvector-domain-expansion/
|
||||
[workspace.dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
thiserror = "2.0"
|
||||
rand = "0.8"
|
||||
rand_distr = "0.4"
|
||||
tracing = "0.1"
|
||||
rayon = "1.10"
|
||||
crossbeam = "0.8"
|
||||
dashmap = "6.1"
|
||||
parking_lot = "0.12"
|
||||
once_cell = "1.20"
|
||||
criterion = { version = "0.5", features = ["html_reports"] }
|
||||
proptest = "1.5"
|
||||
nalgebra = { version = "0.33", default-features = false, features = ["std"] }
|
||||
ndarray = "0.16"
|
||||
chrono = "0.4"
|
||||
anyhow = "1.0"
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
lto = "fat"
|
||||
codegen-units = 1
|
||||
strip = true
|
||||
panic = "unwind"
|
||||
WORKSPACE_EOF
|
||||
|
||||
# Copy ruvector-postgres source
|
||||
COPY crates/ruvector-postgres/ /workspace/crates/ruvector-postgres/
|
||||
|
||||
# Copy dependency crates
|
||||
COPY crates/ruvector-mincut-gated-transformer /workspace/crates/ruvector-mincut-gated-transformer/
|
||||
COPY crates/ruvector-solver /workspace/crates/ruvector-solver/
|
||||
COPY crates/ruvector-math /workspace/crates/ruvector-math/
|
||||
COPY crates/ruvector-attention /workspace/crates/ruvector-attention/
|
||||
COPY crates/sona /workspace/crates/sona/
|
||||
COPY crates/ruvector-domain-expansion /workspace/crates/ruvector-domain-expansion/
|
||||
|
||||
# Copy rvf crates (path deps of ruvector-domain-expansion)
|
||||
COPY crates/rvf/rvf-types /build/../rvf/rvf-types/
|
||||
COPY crates/rvf/rvf-wire /build/../rvf/rvf-wire/
|
||||
COPY crates/rvf/rvf-crypto /build/../rvf/rvf-crypto/
|
||||
COPY crates/rvf/rvf-types /workspace/crates/rvf/rvf-types/
|
||||
COPY crates/rvf/rvf-wire /workspace/crates/rvf/rvf-wire/
|
||||
COPY crates/rvf/rvf-crypto /workspace/crates/rvf/rvf-crypto/
|
||||
|
||||
# Use the workspace Cargo.lock to pin dependencies and avoid registry parsing issues
|
||||
COPY Cargo.lock ./
|
||||
COPY Cargo.lock /workspace/crates/ruvector-postgres/
|
||||
|
||||
WORKDIR /workspace/crates/ruvector-postgres
|
||||
|
||||
# Initialize pgrx with system PostgreSQL
|
||||
RUN cargo pgrx init --pg17=/usr/lib/postgresql/17/bin/pg_config
|
||||
|
|
@ -83,15 +132,15 @@ RUN mkdir -p /opt/ruvector/models && \
|
|||
|
||||
# Copy the pre-built SQL schema file (with sparse functions removed)
|
||||
# cargo pgrx schema doesn't work reliably in Docker, so we use the hand-crafted file
|
||||
RUN cp /build/sql/ruvector--0.1.0.sql /build/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ruvector--0.1.0.sql && \
|
||||
echo "SQL schema copied with $(grep -c 'CREATE FUNCTION\|CREATE OR REPLACE FUNCTION' /build/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ruvector--0.1.0.sql) functions"
|
||||
RUN cp /workspace/crates/ruvector-postgres/sql/ruvector--0.1.0.sql /workspace/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ruvector--0.1.0.sql && \
|
||||
echo "SQL schema copied with $(grep -c 'CREATE FUNCTION\|CREATE OR REPLACE FUNCTION' /workspace/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ruvector--0.1.0.sql) functions"
|
||||
|
||||
# Verify the extension files are complete
|
||||
RUN ls -la /build/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ && \
|
||||
RUN ls -la /workspace/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ && \
|
||||
echo "=== First 20 lines of SQL ===" && \
|
||||
head -20 /build/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ruvector--0.1.0.sql && \
|
||||
head -20 /workspace/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ruvector--0.1.0.sql && \
|
||||
echo "=== CREATE FUNCTION count ===" && \
|
||||
grep -c "CREATE FUNCTION\|CREATE OR REPLACE FUNCTION" /build/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ruvector--0.1.0.sql
|
||||
grep -c "CREATE FUNCTION\|CREATE OR REPLACE FUNCTION" /workspace/target/release/ruvector-pg17/usr/share/postgresql/17/extension/ruvector--0.1.0.sql
|
||||
|
||||
# Runtime stage
|
||||
FROM postgres:17-bookworm
|
||||
|
|
@ -109,22 +158,17 @@ ENV FASTEMBED_CACHE_DIR=/opt/ruvector/models
|
|||
COPY --from=builder /opt/ruvector/models /opt/ruvector/models
|
||||
|
||||
# Copy the built extension from builder
|
||||
# Note: pgrx generates correct SQL from #[pg_extern] macros in target directory
|
||||
# The extension/* directory includes:
|
||||
# - ruvector.control (version info)
|
||||
# - ruvector--*.sql (pgrx-generated SQL with correct function symbols)
|
||||
# - Any additional SQL migration files
|
||||
COPY --from=builder /build/target/release/ruvector-pg17/usr/share/postgresql/17/extension/* \
|
||||
# Note: In a workspace, target/ is at the workspace root /workspace/target/
|
||||
COPY --from=builder /workspace/target/release/ruvector-pg17/usr/share/postgresql/17/extension/* \
|
||||
/usr/share/postgresql/17/extension/
|
||||
COPY --from=builder /build/target/release/ruvector-pg17/usr/lib/postgresql/17/lib/* \
|
||||
COPY --from=builder /workspace/target/release/ruvector-pg17/usr/lib/postgresql/17/lib/* \
|
||||
/usr/lib/postgresql/17/lib/
|
||||
|
||||
# Add initialization scripts
|
||||
RUN mkdir -p /docker-entrypoint-initdb.d
|
||||
|
||||
# Copy the full initialization script with extension creation, role setup, and tests
|
||||
# The init.sql is copied from the builder stage where it was included in the source copy
|
||||
COPY --from=builder /build/docker/init.sql /docker-entrypoint-initdb.d/01-init.sql
|
||||
COPY --from=builder /workspace/crates/ruvector-postgres/docker/init.sql /docker-entrypoint-initdb.d/01-init.sql
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ fn detect_simd_capability() -> SimdCapability {
|
|||
return SimdCapability::Neon;
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
SimdCapability::Scalar
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue