Skip to content

armgit / LEANN

Public Imported from GitHub
0

[MLsys2026 Best Paper]: https://arxiv.org/abs/2506.08276. RAG on Everything with LEANN. Enjoy 97% storage savings while running a fast, accurate, and 100% private RAG application on your personal device.

chore: add devcontainer and docker reference setup (#262)

Andy Lee61cdc55a2620
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000..83cb419
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,43 @@
+{
+ "name": "LEANN Dev",
+ "build": {
+ "context": "..",
+ "dockerfile": "../docker/Dockerfile.dev",
+ "args": {
+ "PYTHON_VERSION": "3.12"
+ }
+ },
+ "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
+ "remoteUser": "root",
+ "overrideCommand": true,
+ "postCreateCommand": "uv sync --group lint --group test",
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "ms-python.python",
+ "ms-python.vscode-pylance",
+ "charliermarsh.ruff",
+ "ms-azuretools.vscode-docker",
+ "ms-toolsai.jupyter",
+ "tamasfe.even-better-toml",
+ "eamodio.gitlens",
+ "EditorConfig.EditorConfig",
+ "DavidAnson.vscode-markdownlint"
+ ],
+ "settings": {
+ "python.defaultInterpreterPath": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin/python",
+ "python.terminal.activateEnvironment": true,
+ "python.testing.pytestEnabled": true,
+ "python.testing.unittestEnabled": false,
+ "python.testing.pytestArgs": [
+ "tests"
+ ],
+ "editor.formatOnSave": true,
+ "editor.codeActionsOnSave": {
+ "source.organizeImports.ruff": "explicit",
+ "source.fixAll.ruff": "explicit"
+ }
+ }
+ }
+ }
+}
diff --git a/.gitignore b/.gitignore
index 47d53ef..46ce36c 100755
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@ demo/experiment_results/**/*.json
*.json
*.png
!.vscode/*.json
+!.devcontainer/*.json
*.sh
*.txt
!CMakeLists.txt
@@ -87,6 +88,11 @@ wheels/
test_indices*/
test_*.py
!tests/**
+# Re-ignore common generated artifacts globally (especially after allowlist rules).
+**/.DS_Store
+**/__pycache__/
+**/*.cpython-*.pyc
+**/*.cpython-*.pyo
packages/leann-backend-diskann/third_party/DiskANN/_deps/
*.meta.json
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..8ca4af6
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,23 @@
+ARG PYTHON_VERSION=3.11
+FROM python:${PYTHON_VERSION}-slim
+
+ARG LEANN_VERSION=0.3.6
+
+ENV PIP_NO_CACHE_DIR=1 \
+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
+ PIP_ROOT_USER_ACTION=ignore
+
+# Keep runtime image minimal while ensuring common C++ runtime libs are present.
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ libgomp1 \
+ libstdc++6 \
+ && rm -rf /var/lib/apt/lists/*
+
+RUN python -m pip install --upgrade pip \
+ && pip install --prefer-binary "leann==${LEANN_VERSION}" \
+ && python -c "import leann; import leann_backend_hnsw; import leann_backend_diskann"
+
+WORKDIR /workspace
+
+CMD ["python", "-c", "import leann; print('LEANN installed and importable.')"]
diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu
new file mode 100644
index 0000000..cc0873c
--- /dev/null
+++ b/docker/Dockerfile.cpu
@@ -0,0 +1,25 @@
+ARG PYTHON_VERSION=3.11
+FROM python:${PYTHON_VERSION}-slim
+
+ARG LEANN_VERSION=0.3.6
+
+ENV PIP_NO_CACHE_DIR=1 \
+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
+ PIP_ROOT_USER_ACTION=ignore \
+ PIP_INDEX_URL=https://download.pytorch.org/whl/cpu \
+ PIP_EXTRA_INDEX_URL=https://pypi.org/simple
+
+# Keep runtime image minimal while ensuring common C++ runtime libs are present.
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ libgomp1 \
+ libstdc++6 \
+ && rm -rf /var/lib/apt/lists/*
+
+RUN python -m pip install --upgrade pip \
+ && pip install --prefer-binary "leann==${LEANN_VERSION}" \
+ && python -c "import leann; import leann_backend_hnsw; import leann_backend_diskann"
+
+WORKDIR /workspace
+
+CMD ["python", "-c", "import leann; print('LEANN installed and importable (CPU image).')"]
diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev
new file mode 100644
index 0000000..f05b314
--- /dev/null
+++ b/docker/Dockerfile.dev
@@ -0,0 +1,38 @@
+ARG PYTHON_VERSION=3.11
+FROM python:${PYTHON_VERSION}-slim
+
+ENV DEBIAN_FRONTEND=noninteractive \
+ PIP_NO_CACHE_DIR=1 \
+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
+ PIP_ROOT_USER_ACTION=ignore
+
+# Build + test toolchain for local development in container.
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ build-essential \
+ cmake \
+ git \
+ swig \
+ libomp-dev \
+ libboost-all-dev \
+ protobuf-compiler \
+ libzmq3-dev \
+ pkg-config \
+ libabsl-dev \
+ libaio-dev \
+ libprotobuf-dev \
+ libopenblas-dev \
+ liblapack-dev \
+ liblapacke-dev \
+ && rm -rf /var/lib/apt/lists/*
+
+RUN python -m pip install --upgrade pip \
+ && pip install uv
+
+WORKDIR /workspace
+COPY . /workspace
+
+# Keep dependency install explicit; default includes lint + test groups.
+RUN uv sync --group lint --group test
+
+CMD ["/bin/bash"]
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..eb36cc4
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,50 @@
+# Docker Setup
+
+This folder provides reference Docker images for LEANN.
+
+## Build (default)
+
+Default image (no forced CPU index):
+
+```bash
+docker build -f docker/Dockerfile docker -t leann:latest
+```
+
+## Build (CPU)
+
+CPU-optimized image (forces PyTorch CPU index):
+
+```bash
+docker build \
+ --build-arg PYTHON_VERSION=3.12 \
+ --build-arg LEANN_VERSION=0.3.6 \
+ -f docker/Dockerfile.cpu docker -t leann:cpu
+```
+
+## Build (development)
+
+Development image (source tree + build/test toolchain + `uv sync`):
+
+```bash
+docker build -f docker/Dockerfile.dev . -t leann:dev
+```
+
+## Run
+
+```bash
+docker run --rm leann:latest
+docker run --rm leann:cpu
+docker run --rm -it leann:dev
+```
+
+Expected output:
+
+```text
+LEANN installed and importable.
+```
+
+## Notes
+
+- Both images keep LEANN package semantics unchanged (`pip install leann` with both backends).
+- `Dockerfile.cpu` uses the PyTorch CPU index to avoid downloading CUDA wheels.
+- `Dockerfile.dev` is for local development, not production deployment.