|
1 | | -# docker build -t ghcr.io/pyprophet/pyprophet:3.0.2 . |
| 1 | +# docker build --no-cache -t ghcr.io/pyprophet/pyprophet:3.0.2 . |
2 | 2 | # docker push ghcr.io/pyprophet/pyprophet:3.0.2 |
3 | 3 |
|
4 | | -# PyProphet Dockerfile (Ubuntu 24.04 + venv) |
5 | | -FROM ubuntu:24.04 |
6 | | - |
7 | | -ENV DEBIAN_FRONTEND=noninteractive \ |
8 | | - PYTHONUNBUFFERED=1 |
| 4 | +# ---------- builder: create venv and install ---------- |
| 5 | +FROM ubuntu:24.04 AS builder |
| 6 | +ENV DEBIAN_FRONTEND=noninteractive PYTHONUNBUFFERED=1 |
9 | 7 |
|
| 8 | +# System Python + toolchain for building wheels (builder only) |
10 | 9 | RUN apt-get update && apt-get install -y --no-install-recommends \ |
11 | 10 | ca-certificates python3 python3-pip python3-dev python3-venv \ |
12 | | - build-essential git \ |
13 | | - # --- runtime libs needed by pyopenms --- |
14 | | - libglib2.0-0 \ |
15 | | - libgomp1 \ |
16 | | - # these are rarely needed, but harmless and useful if pyopenms/OpenMS is present |
17 | | - libxerces-c3.2 \ |
18 | | - zlib1g \ |
19 | | - libbz2-1.0 \ |
20 | | - libsqlite3-0 \ |
21 | | - && rm -rf /var/lib/apt/lists/* |
22 | | - |
23 | | -# venv |
| 11 | + build-essential git curl && \ |
| 12 | + rm -rf /var/lib/apt/lists/* |
| 13 | + |
| 14 | +# Virtualenv (avoid PEP 668 issues) |
24 | 15 | RUN python3 -m venv /opt/venv |
25 | 16 | ENV VIRTUAL_ENV=/opt/venv |
26 | 17 | ENV PATH="/opt/venv/bin:${PATH}" |
27 | 18 |
|
28 | | -# toolchain (pins optional) |
| 19 | +# Upgrade pip and install toolchain/runtime deps |
| 20 | +# Pins chosen to have manylinux wheels for Python 3.12 |
29 | 21 | RUN python -m pip install --no-cache-dir --upgrade pip && \ |
30 | | - python -m pip install --no-cache-dir "numpy==1.26.4" "cython==0.29.36" duckdb seaborn psutil |
| 22 | + python -m pip install --no-cache-dir --prefer-binary \ |
| 23 | + "numpy==1.26.4" "cython==0.29.36" "scipy==1.12.*" \ |
| 24 | + duckdb seaborn psutil |
| 25 | + |
| 26 | +# Bring in the PyProphet source tree |
| 27 | +WORKDIR /src |
| 28 | +COPY pyproject.toml setup.py requirements.txt README* LICENSE* ./ |
| 29 | +COPY pyprophet ./pyprophet |
| 30 | + |
| 31 | +# Ensure setuptools/wheel are present (and avoid latest setuptools breaking flags) |
| 32 | +RUN python -m pip install --no-cache-dir "setuptools<75" wheel |
31 | 33 |
|
32 | | -# install PyProphet |
33 | | -ADD . /pyprophet |
34 | | -WORKDIR /pyprophet |
35 | | -RUN pip install . |
| 34 | +# --- force-build the Cython extension before installing --- |
| 35 | +# This compiles pyprophet/scoring/_optimized.pyx into a .so in-place. |
| 36 | +RUN python setup.py build_ext --inplace |
| 37 | + |
| 38 | +# Install PyProphet into the venv (reuse prebuilt wheels, no isolation) |
| 39 | +RUN pip install --no-cache-dir --no-build-isolation . |
| 40 | + |
| 41 | +# Verify the optimized module is importable (fail-fast if not) |
| 42 | +RUN python - <<'PY' |
| 43 | +import importlib, sys |
| 44 | +m = importlib.import_module('pyprophet.scoring._optimized') |
| 45 | +print("Found optimized extension:", m.__file__) |
| 46 | +PY |
36 | 47 |
|
37 | | -# warm up duckdb sqlite_scanner (optional) |
| 48 | +# Pre-install DuckDB sqlite_scanner extension (as requested) |
38 | 49 | RUN python - <<'PY' |
39 | 50 | import duckdb |
40 | 51 | con = duckdb.connect() |
41 | 52 | con.execute("INSTALL 'sqlite_scanner'") |
42 | 53 | con.execute("LOAD 'sqlite_scanner'") |
| 54 | +print("duckdb sqlite_scanner installed & loadable") |
43 | 55 | PY |
44 | 56 |
|
| 57 | +# Optional: trim pyc/caches |
| 58 | +RUN python -m compileall -q "${VIRTUAL_ENV}" || true && \ |
| 59 | + find "${VIRTUAL_ENV}" -type d -name "__pycache__" -prune -exec rm -rf {} + && \ |
| 60 | + find "${VIRTUAL_ENV}" -type f -name "*.pyc" -delete |
| 61 | + |
| 62 | +# ---------- runtime: only the venv + runtime libs ---------- |
| 63 | +FROM ubuntu:24.04 AS runtime |
| 64 | +ENV DEBIAN_FRONTEND=noninteractive PYTHONUNBUFFERED=1 |
| 65 | + |
| 66 | +# Minimal native libs needed by pyopenms/pyprophet (safe superset) |
| 67 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 68 | + ca-certificates python3 \ |
| 69 | + libglib2.0-0 libgomp1 \ |
| 70 | + libxerces-c3.2 zlib1g libbz2-1.0 libsqlite3-0 \ |
| 71 | + && rm -rf /var/lib/apt/lists/* |
| 72 | + |
| 73 | +# Bring the venv |
| 74 | +COPY --from=builder /opt/venv /opt/venv |
| 75 | +ENV VIRTUAL_ENV=/opt/venv |
| 76 | +ENV PATH="/opt/venv/bin:${PATH}" |
| 77 | + |
| 78 | +# Default workdir |
45 | 79 | WORKDIR /data/ |
0 commit comments