Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Update Dockerfile to build rust module

Daoud Clarkea6f881cc11e7
diff --git a/Dockerfile b/Dockerfile
index 525a7e8..38c968e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -17,22 +17,32 @@ FROM base as builder
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
- PIP_NO_CACHE_DIR=1 \
- POETRY_VERSION=1.1.12
+ PIP_NO_CACHE_DIR=1
+# Install Rust toolchain (required by maturin to compile the mwmbl_rank extension)
+# Install clang/libclang-dev for bindgen (used by xgboost_lib-sys)
+RUN apt-get update && \
+ apt-get install -y clang libclang-dev && \
+ rm -rf /var/lib/apt/lists/*
+
+RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
+ | sh -s -- -y --default-toolchain stable
+ENV PATH="/root/.cargo/bin:${PATH}"
# Create a /venv directory & environment.
# This directory will be copied into the final stage of docker build.
RUN python -m venv /venv
-# Copy only the necessary files to build/install the python package
+# Copy only the necessary files to build/install the python package.
+# mwmbl/resources is needed because idf.rs and wiki.rs embed JSON files at
+# compile time via include_str!("../../mwmbl/resources/...").
COPY pyproject.toml poetry.lock /app/
COPY mwmbl /app/mwmbl
+COPY mwmbl_rank /app/mwmbl_rank
# Working directory is /app
-# Use pip to install the mwmbl python package
-# PEP 518, PEP 517 and others have allowed for a standardized python packaging API, which allows
-# pip to be able to install poetry packages.
+# Use pip to install the mwmbl python package including the mwmbl_rank Rust
+# extension. PEP 517/518 allows pip to use maturin as the build backend.
RUN /venv/bin/pip install pip wheel --upgrade && \
/venv/bin/pip install .