Merge branch 'development' of github.com:perstarkse/minne into development

This commit is contained in:
Per Stark
2025-11-03 12:40:36 +01:00
5 changed files with 77 additions and 60 deletions
+1
View File
@@ -57,6 +57,7 @@ object_store = { version = "0.11.2" }
bytes = "1.7.1" bytes = "1.7.1"
state-machines = "0.2.0" state-machines = "0.2.0"
fastembed = "5.2.0" fastembed = "5.2.0"
ort = { version = "=2.0.0-rc.8", default-features = false, features = ["load-dynamic"] }
[profile.dist] [profile.dist]
inherits = "release" inherits = "release"
+30 -32
View File
@@ -1,7 +1,10 @@
# === Builder Stage === # === Builder ===
FROM clux/muslrust:1.86.0-stable as builder FROM rust:1.86-bookworm AS builder
WORKDIR /usr/src/minne WORKDIR /usr/src/minne
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config clang cmake git && rm -rf /var/lib/apt/lists/*
# Cache deps
COPY Cargo.toml Cargo.lock ./ COPY Cargo.toml Cargo.lock ./
RUN mkdir -p api-router common composite-retrieval html-router ingestion-pipeline json-stream-parser main worker RUN mkdir -p api-router common composite-retrieval html-router ingestion-pipeline json-stream-parser main worker
COPY api-router/Cargo.toml ./api-router/ COPY api-router/Cargo.toml ./api-router/
@@ -11,43 +14,38 @@ COPY html-router/Cargo.toml ./html-router/
COPY ingestion-pipeline/Cargo.toml ./ingestion-pipeline/ COPY ingestion-pipeline/Cargo.toml ./ingestion-pipeline/
COPY json-stream-parser/Cargo.toml ./json-stream-parser/ COPY json-stream-parser/Cargo.toml ./json-stream-parser/
COPY main/Cargo.toml ./main/ COPY main/Cargo.toml ./main/
RUN cargo build --release --bin main --features ingestion-pipeline/docker || true
# Build with the MUSL target # Build
RUN cargo build --release --target x86_64-unknown-linux-musl --bin main --features ingestion-pipeline/docker || true
# Copy the rest of the source code
COPY . . COPY . .
RUN cargo build --release --bin main --features ingestion-pipeline/docker
# Build the final application binary with the MUSL target # === Runtime ===
RUN cargo build --release --target x86_64-unknown-linux-musl --bin main --features ingestion-pipeline/docker FROM debian:bookworm-slim
# === Runtime Stage === # Chromium + runtime deps + OpenMP for ORT
FROM alpine:latest RUN apt-get update && apt-get install -y --no-install-recommends \
chromium libnss3 libasound2 libgbm1 libxshmfence1 \
ca-certificates fonts-dejavu fonts-noto-color-emoji \
libgomp1 libstdc++6 curl \
&& rm -rf /var/lib/apt/lists/*
RUN apk update && apk add --no-cache \ # ONNX Runtime (CPU). Change if you bump ort.
chromium \ ARG ORT_VERSION=1.21.0
nss \ RUN mkdir -p /opt/onnxruntime && \
freetype \ curl -fsSL -o /tmp/ort.tgz \
harfbuzz \ "https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}/onnxruntime-linux-x64-${ORT_VERSION}.tgz" && \
ca-certificates \ tar -xzf /tmp/ort.tgz -C /opt/onnxruntime --strip-components=1 && rm /tmp/ort.tgz
ttf-freefont \
font-noto-emoji \
&& \
rm -rf /var/cache/apk/*
ENV CHROME_BIN=/usr/bin/chromium-browser \ ENV CHROME_BIN=/usr/bin/chromium \
CHROME_PATH=/usr/lib/chromium/ \ SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt \
SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt ORT_DYLIB_PATH=/opt/onnxruntime/lib/libonnxruntime.so
# Create a non-root user to run the application # Non-root
RUN adduser -D -h /home/appuser appuser RUN useradd -m appuser
WORKDIR /home/appuser
USER appuser USER appuser
WORKDIR /home/appuser
# Copy the compiled binary from the builder stage (note the target path) COPY --from=builder /usr/src/minne/target/release/main /usr/local/bin/main
COPY --from=builder /usr/src/minne/target/x86_64-unknown-linux-musl/release/main /usr/local/bin/main
EXPOSE 3000 EXPOSE 3000
# EXPOSE 8000-9000
CMD ["main"] CMD ["main"]
+3 -2
View File
@@ -12,10 +12,11 @@ services:
SURREALDB_PASSWORD: "root_password" SURREALDB_PASSWORD: "root_password"
SURREALDB_DATABASE: "test" SURREALDB_DATABASE: "test"
SURREALDB_NAMESPACE: "test" SURREALDB_NAMESPACE: "test"
OPENAI_API_KEY: "sk-key" OPENAI_API_KEY: "sk-add-your-key"
DATA_DIR: "./data" DATA_DIR: "./data"
HTTP_PORT: 3000 HTTP_PORT: 3000
RUST_LOG: "info" RUST_LOG: "info"
RERANKING_ENABLED: false ## Change to true to enable reranking
depends_on: depends_on:
- surrealdb - surrealdb
networks: networks:
@@ -31,7 +32,7 @@ services:
- ./database:/database # Mounts a 'database' folder from your project directory - ./database:/database # Mounts a 'database' folder from your project directory
command: > command: >
start start
--log debug --log info
--user root_user --user root_user
--pass root_password --pass root_password
rocksdb:./database/database.db rocksdb:./database/database.db
Generated
+16
View File
@@ -1,5 +1,20 @@
{ {
"nodes": { "nodes": {
"crane": {
"locked": {
"lastModified": 1760924934,
"narHash": "sha256-tuuqY5aU7cUkR71sO2TraVKK2boYrdW3gCSXUkF4i44=",
"owner": "ipetkov",
"repo": "crane",
"rev": "c6b4d5308293d0d04fcfeee92705017537cad02f",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
@@ -36,6 +51,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"crane": "crane",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
+27 -26
View File
@@ -4,60 +4,61 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
flake-utils, flake-utils,
crane,
}: }:
flake-utils.lib.eachDefaultSystem ( flake-utils.lib.eachDefaultSystem (
system: let system: let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
# --- Minne Package Definition --- minne-pkg = craneLib.buildPackage {
minne-pkg = pkgs.rustPlatform.buildRustPackage { src = craneLib.cleanCargoSource ./.;
pname = "minne"; pname = "minne";
version = "0.1.0"; version = "0.1.0";
src = self;
cargoLock = {
lockFile = ./Cargo.lock;
};
# Skip tests due to testing fs operations
doCheck = false; doCheck = false;
nativeBuildInputs = [ nativeBuildInputs = [
pkgs.pkg-config pkgs.pkg-config
pkgs.rustfmt pkgs.rustfmt
pkgs.makeWrapper # For the postInstall hook pkgs.makeWrapper
]; ];
buildInputs = [ buildInputs = [
pkgs.openssl pkgs.openssl
pkgs.chromium # Runtime dependency for the browser pkgs.chromium
pkgs.onnxruntime
]; ];
# Wrap the actual executables to provide CHROME at runtime ORT_STRATEGY = "system";
postInstall = let ORT_LIB_LOCATION = "${pkgs.onnxruntime}/lib";
chromium_executable = "${pkgs.chromium}/bin/chromium"; ORT_SKIP_DOWNLOAD = "1";
in ''
wrapProgram $out/bin/main \
--set CHROME "${chromium_executable}"
wrapProgram $out/bin/worker \
--set CHROME "${chromium_executable}"
'';
meta = with pkgs.lib; { postInstall = ''
description = "Minne Application"; wrapProgram $out/bin/main \
license = licenses.mit; --set CHROME ${pkgs.chromium}/bin/chromium \
}; --set ORT_DYLIB_PATH ${pkgs.onnxruntime}/lib/libonnxruntime.so
if [ -f $out/bin/worker ]; then
wrapProgram $out/bin/worker \
--set CHROME ${pkgs.chromium}/bin/chromium \
--set ORT_DYLIB_PATH ${pkgs.onnxruntime}/lib/libonnxruntime.so
fi
if [ -f $out/bin/server]; then
wrapProgram $out/bin/server\
--set ORT_DYLIB_PATH ${pkgs.onnxruntime}/lib/libonnxruntime.so
fi
'';
}; };
in { in {
packages = { packages = {
minne = minne-pkg; default = self.packages.${system}.minne-pkg;
default = self.packages.${system}.minne;
}; };
apps = { apps = {