Skip to content

Commit 62daa89

Browse files
authored
Merge pull request #38 from longtngo/fix/docker-example-build-deps
fix(docs): fix Docker example and document hnswlib C++ build requirement
2 parents ae661c8 + 693deb4 commit 62daa89

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

docs/proxy.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,12 @@ Or with Docker:
248248

249249
```dockerfile
250250
FROM python:3.11-slim
251-
RUN pip install headroom[proxy]
251+
RUN apt-get update && apt-get install -y --no-install-recommends build-essential \
252+
&& pip install "headroom-ai[proxy]" \
253+
&& apt-get purge -y build-essential && apt-get autoremove -y \
254+
&& rm -rf /var/lib/apt/lists/*
252255
EXPOSE 8787
253256
CMD ["headroom", "proxy", "--host", "0.0.0.0"]
254257
```
258+
259+
> **Note:** `build-essential` is required at install time because `headroom-ai` includes `hnswlib`, a C++ extension that must be compiled from source. It is removed after installation to keep the image slim.

docs/troubleshooting.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,39 @@ client = HeadroomClient(
219219

220220
## Import/Installation Issues
221221

222+
### "pip install fails with C++ compilation error"
223+
224+
**Symptom**: Installation fails with an error like:
225+
226+
```
227+
RuntimeError: Unsupported compiler -- at least C++11 support is needed!
228+
ERROR: Failed building wheel for hnswlib
229+
```
230+
231+
**Cause**: `headroom-ai` depends on `hnswlib`, a C++ extension that must be compiled from source. Slim environments (Docker slim images, minimal CI runners) lack the required build tools.
232+
233+
**Solutions**:
234+
235+
```bash
236+
# Linux / Debian-based (including Docker)
237+
apt-get install -y build-essential && pip install headroom-ai
238+
239+
# macOS (Xcode command line tools)
240+
xcode-select --install && pip install headroom-ai
241+
```
242+
243+
In a Dockerfile, install and remove build tools in one layer to keep the image slim:
244+
245+
```dockerfile
246+
FROM python:3.11-slim
247+
RUN apt-get update && apt-get install -y --no-install-recommends build-essential \
248+
&& pip install "headroom-ai[proxy]" \
249+
&& apt-get purge -y build-essential && apt-get autoremove -y \
250+
&& rm -rf /var/lib/apt/lists/*
251+
```
252+
253+
---
254+
222255
### "ModuleNotFoundError: No module named 'headroom'"
223256

224257
```bash

0 commit comments

Comments
 (0)