Dockerfile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. FROM rust:1.71-bullseye as builder
  2. WORKDIR /usr/src/kuberian
  3. # Install intel-mkl
  4. RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
  5. | gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \
  6. echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | \
  7. tee /etc/apt/sources.list.d/oneAPI.list
  8. RUN apt update
  9. RUN apt install -y intel-oneapi-mkl-devel libomp-dev
  10. # Make cache layers
  11. COPY Cargo.toml .
  12. COPY ci src/
  13. RUN cargo build -r -F mkl
  14. RUN rm -rf src
  15. # Build final binaries
  16. COPY . .
  17. # to make sure that cargo recompile the kuberian
  18. RUN touch src/*
  19. RUN cargo install --path . -F mkl
  20. # Downloads Embedding Models or ETC
  21. ENV HF_HOME=/model
  22. ADD https://s3.iwanhae.kr/kuberian/kuberian.db ./kuberian.db
  23. ADD https://s3.iwanhae.kr/kuberian/kuberian.usearch ./kuberian.usearch
  24. RUN kuberian --ci
  25. FROM debian:11 as sqlite-fetcher
  26. RUN apt update
  27. RUN apt-get install -y sqlite3
  28. FROM gcr.io/distroless/cc-debian11
  29. WORKDIR /app
  30. COPY --from=sqlite-fetcher /usr/lib/x86_64-linux-gnu/libsqlite3.so.* /usr/lib/
  31. COPY --from=builder /opt/intel/oneapi/compiler/latest/linux/compiler/lib/intel64_lin/libiomp5.so /usr/lib/
  32. COPY --from=builder /model /model
  33. COPY --from=builder /usr/local/cargo/bin/kuberian /usr/local/bin/kuberian
  34. COPY --from=builder /usr/src/kuberian/kuberian.db ./kuberian.db
  35. COPY --from=builder /usr/src/kuberian/kuberian.usearch ./kuberian.usearch
  36. EXPOSE 8080
  37. ENV HF_HOME=/model
  38. CMD ["kuberian"]