- Updated the Dockerfile to rename the built binary from `mf-fitter` to `fit_model` for clarity. - Introduced a new `fit_model_args.rs` file to define command-line arguments for the fit model process, including parameters for matrix factorization. - Added `pg_types.rs` and `pgvector.rs` files to handle PostgreSQL type interactions and vector serialization/deserialization. - Implemented the main logic for the fit model in `fit_model.rs`, including data loading, model training, and embedding saving. - Enhanced `visualize_embeddings.rs` to load embeddings and clusters more efficiently. These changes improve the organization and functionality of the model fitting process, making it more intuitive and maintainable.
59 lines
1.3 KiB
Docker
59 lines
1.3 KiB
Docker
FROM rust:1.75-slim-bullseye as builder
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && \
|
|
apt-get install -y \
|
|
pkg-config \
|
|
libssl-dev \
|
|
libpq-dev \
|
|
gcc \
|
|
g++ \
|
|
make \
|
|
clang \
|
|
lld \
|
|
libomp-dev \
|
|
libopenblas-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create a new empty project
|
|
WORKDIR /app
|
|
|
|
# Create a dummy project to cache dependencies
|
|
COPY Cargo.toml Cargo.lock ./
|
|
RUN mkdir src && \
|
|
echo "fn main() {println!(\"dummy\")}" > src/main.rs && \
|
|
cargo build --release && \
|
|
rm -rf src
|
|
|
|
# Now copy the real source code
|
|
COPY . .
|
|
|
|
# Build the application in release mode with cargo cache
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
--mount=type=cache,target=/app/target \
|
|
cargo build --release && \
|
|
cp target/release/fit_model /app/fit_model
|
|
|
|
# Create the runtime image
|
|
FROM debian:bullseye-slim
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && \
|
|
apt-get install -y \
|
|
libpq5 \
|
|
ca-certificates \
|
|
libomp5 \
|
|
libopenblas0 \
|
|
libgomp1 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy the binary from builder
|
|
COPY --from=builder /app/fit_model /usr/local/bin/
|
|
COPY --from=builder /app/.env.example /app/.env
|
|
|
|
WORKDIR /app
|
|
|
|
# Set environment variables
|
|
ENV RUST_LOG=info
|
|
|
|
ENTRYPOINT ["/usr/local/bin/fit_model"] |