# This Dockerfile builds Faiss from source with CPU-only support and Python bindings.
FROM ubuntu:22.04
# Non-interactive frontend for APT
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-dev \
gcc \
g++ \
make \
cmake \
swig \
git \
wget \
libomp-dev \
libopenblas-dev \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies required for building Python bindings and tests
RUN pip3 install --no-cache-dir numpy==1.26.4 scipy pytest
# Set workdir to repository root and copy source code
WORKDIR /workspace/faiss
COPY . /workspace/faiss
# Configure and build Faiss (CPU, tests enabled, Release)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build --target faiss -- -j8 || make -C build -j8 faiss
RUN cmake --build build --target swigfaiss -- -j8 || make -C build -j8 swigfaiss
# Build and install the Python bindings
WORKDIR /workspace/faiss/build/faiss/python
RUN python3 setup.py install
# Default to an interactive shell
CMD ["/bin/bash"]
# Ignore version control and unnecessary files in docker build context .git .github/ .github*/* __pycache__/ *.pyc *.pyo *.pyd venv/ dist/ build/ *.egg-info/ *.log *.tmp *.tar.gz *.zip *.so *.a *.o *.dylib # Faiss-specific build artifacts (placeholders, safe to ignore in context) faiss/build/ faiss/*.o faiss/*.so
- Exact error message and exit code:
- CMake Error at CMakeLists.txt:22 (cmake_minimum_required):
CMake 3.24.0 or higher is required. You are running version 3.22.1
- Exit code: 1
- Failing command/step:
- Dockerfile step: RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
- Context: Step [ 6/10], later shown as the cmake configure command failing with exit code 1
- Missing packages or files mentioned:
- None reported as missing; the failure is due to a version mismatch (CMake version too old).
- Version mismatch information:
- Required: CMake 3.24.0 or higher
- Found: 3.22.1
- Source of mismatch: The image provides cmake 3.22.1 from the Ubuntu jammy repository; Faiss build requires 3.24.0+.# This Dockerfile builds Faiss from source with CPU-only support and Python bindings.
FROM ubuntu:22.04
# Non-interactive frontend for APT
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-dev \
gcc \
g++ \
make \
cmake \
swig \
git \
wget \
libomp-dev \
libopenblas-dev \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Install Python dependencies required for building Python bindings and tests
RUN pip3 install --no-cache-dir numpy==1.26.4 scipy pytest
# Set workdir to repository root and copy source code
WORKDIR /workspace/faiss
COPY . /workspace/faiss
# Configure and build Faiss (CPU, tests enabled, Release)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build --target faiss -- -j8 || make -C build -j8 faiss
RUN cmake --build build --target swigfaiss -- -j8 || make -C build -j8 swigfaiss
# Build and install the Python bindings
WORKDIR /workspace/faiss/build/faiss/python
RUN python3 setup.py install
# Default to an interactive shell
CMD ["/bin/bash"]
Smoke [FAIL]: python3 -c \"import faiss; print('faiss import OK')\
Output: sh: 1: Syntax error: word unexpected (expecting ")")
Smoke [FAIL]: python3 -c \"import faiss, numpy as np; d=32; xb=np.random.rand(4,d).astype(np.float32); ix=faiss.IndexFlatL2(d); ix.add(xb); D,I=ix.search(xb,2); print(D.shape, I.shape)\
Output: sh: 1: Syntax error: "(" unexpected# This Dockerfile builds Faiss from source with CPU-only support and Python bindings.
FROM ubuntu:22.04
# Non-interactive frontend for APT
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-dev \
gcc \
g++ \
make \
cmake \
swig \
git \
wget \
libomp-dev \
libopenblas-dev \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Install Python dependencies required for building Python bindings and tests
RUN pip3 install --no-cache-dir numpy==1.26.4 scipy pytest
# Set workdir to repository root and copy source code
WORKDIR /workspace/faiss
COPY . /workspace/faiss
# Configure and build Faiss (CPU, tests disabled, Release)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build --target faiss -- -j8 || make -C build -j8 faiss
RUN cmake --build build --target swigfaiss -- -j8 || make -C build -j8 swigfaiss
# Build and install the Python bindings
WORKDIR /workspace/faiss/build/faiss/python
RUN python3 setup.py install
# Default to an interactive shell
CMD ["/bin/bash"]
Concerns: Single-stage build may produce a large image with build-time dependencies; consider a multi-stage build to create a smaller runtime image., Python bindings install into system site-packages; consider using a virtual environment or user-local install if needed for isolation., The build relies on network access to fetch dependencies (CMake tarball, Python packages); ensure CI environments have stable network access or provide caching. Smoke [FAIL]: python3 -c 'import faiss, numpy as np; d=32; idx=faiss.IndexFlatL2(d); xb=np.random.rand(4,d).astype(np.float32); idx.add(xb); xq=np.random.rand(1,d).astype(np.float32); D,I=idx.search(xq,1); print(I[0][0], D[0][0]) Output: sh: 1: Syntax error: Unterminated quoted string
# This Dockerfile builds Faiss from source with CPU-only support and Python bindings.
FROM ubuntu:22.04
# Non-interactive frontend for APT
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-dev \
gcc \
g++ \
make \
cmake \
swig \
git \
wget \
libomp-dev \
libopenblas-dev \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Install Python dependencies required for building Python bindings and tests
RUN pip3 install --no-cache-dir numpy==1.26.4 scipy pytest
# Set workdir to repository root and copy source code
WORKDIR /workspace/faiss
COPY . /workspace/faiss
# Configure and build Faiss (CPU, tests disabled, Release)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build --target faiss -- -j8 || make -C build -j8 faiss
RUN cmake --build build --target swigfaiss -- -j8 || make -C build -j8 swigfaiss
# Build and install the Python bindings
WORKDIR /workspace/faiss/build/faiss/python
RUN python3 setup.py install
# Default to an interactive shell
CMD ["/bin/bash"]
Smoke [FAIL]: python3 -c 'import faiss, numpy as np; d=64; xb=np.random.rand(16,d).astype(np.float32); index = faiss.IndexFlatL2(d); index.add(xb); print(index.ntotal) Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: python3 -c 'import faiss, numpy as np; d=32; xb=np.random.rand(4,d).astype(np.float32); index = faiss.IndexFlatL2(d); index.add(xb); q=xb[:2]; D,I = index.search(q, 2); print(D.shape, I.shape) Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: python3 -c 'import faiss; print(1) Output: sh: 1: Syntax error: Unterminated quoted string
# Multi-stage Dockerfile: build Faiss from source in builder stage, then copy artifacts to a slim runtime image.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies in builder
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-dev \
gcc \
g++ \
make \
swig \
git \
wget \
libomp-dev \
libopenblas-dev \
libgflags-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Install Python build tooling
RUN pip3 install --no-cache-dir numpy==1.26.4 scipy pytest
# Set workdir to repository root and copy source code
WORKDIR /workspace/faiss
COPY . /workspace/faiss
# Build Faiss (CPU, tests disabled, Release)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build --target faiss -- -j8
RUN cmake --build build --target swigfaiss -- -j8
# Build and install the Python bindings
WORKDIR /workspace/faiss/build/faiss/python
RUN python3 -m pip install --no-deps --upgrade pip
RUN pip3 install --no-cache-dir .
# Stage: runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
libomp-dev \
libopenblas-dev \
wget \
ca-certificates \
git \
swig \
gcc \
g++ \
# keep python headers out of final image
&& rm -rf /var/lib/apt/lists/*
# Copy Python Faiss package and libs from builder
COPY --from=builder /workspace/faiss/build/faiss/python /usr/local/lib/python3.11/dist-packages/faiss
# Also copy shared libraries that Faiss depends on
COPY --from=builder /usr/local/lib /usr/local/lib
# Ensure the faiss package is importable by Python3
ENV PYTHONPATH=/usr/local/lib/python3.11/site-packages:$PYTHONPATH
# Default command: drop into a shell
CMD ["/bin/bash"]
Concerns: Potential Python version mismatch: the runtime image assumes Python 3.11 site-packages (/usr/local/lib/python3.11/site-packages) but Ubuntu 22.04 commonly ships Python 3.10. The build step installs into a Python environment in the builder, and the runtime copies seem tailored to Python 3.11 (dist-packages/site-packages paths). This may prevent importing faiss in the runtime image., COPY path for Python package uses /usr/local/lib/python3.11/dist-packages/faiss. This mixes dist-packages (Debian/apt convention) with site-packages naming. If the runtime Python uses site-packages, imports may fail. Consider aligning to /usr/local/lib/python3.X/site-packages/faiss based on the actual Python version used in the runtime., The runtime image installs build tools (swig, gcc, g++) which are unnecessary after building Faiss. This increases image size and surface area. If size is a concern, consider a slimmer runtime with only runtime dependencies.
Smoke [FAIL]: python3 -c "import faiss; print('faiss import ok:', faiss.__name__)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [PASS]: python3 - <<'PY'
import numpy as np, faiss
D = 32
xb = np.random.rand(10, D).astype('float32')
idx = faiss.IndexFlatL2(D)
idx.add(xb)
print('faiss index size:', idx.ntotal)
PY
Smoke [FAIL]: python3 -c "import faiss, sys; v = getattr(faiss, '__version__', 'unknown'); print('faiss version:', v)
Output: sh: 1: Syntax error: Unterminated quoted string# Stage 1: build Faiss from source in a dedicated builder image
FROM ubuntu:22.04 as builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-dev \
gcc \
g++ \
make \
swig \
git \
wget \
libomp-dev \
libopenblas-dev \
libgflags-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Install Python build tooling and numpy for building Python bindings
RUN python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir numpy==1.26.4 scipy
# Set workdir to repository root and copy source code
WORKDIR /workspace/faiss
COPY . /workspace/faiss
# Configure and build Faiss (CPU, tests enabled, Release)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -- -j8
# Build the Python bindings and install into the builder image's Python site-packages
WORKDIR /workspace/faiss/build/faiss/python
RUN python3 -m pip install --no-cache-dir --upgrade pip
RUN python3 -m pip install --no-deps --ignore-installed .
# Stage 2: runtime image (lean)
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime Python and essential libraries
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
libomp-dev \
libopenblas-dev \
ca-certificates \
wget \
git \
swig \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy Python Faiss package and shared libraries from builder
# Python package location is /usr/local/lib/python3.10/site-packages/faiss on Ubuntu 22.04 defaults
# We explicitly copy to Python 3.10 site-packages; adjust if Python version differs in your environment
COPY --from=builder /usr/local/lib/python*/site-packages/faiss /usr/local/lib/python3.10/site-packages/faiss
COPY --from=builder /usr/local/lib /usr/local/lib
# Ensure Python can find Faiss
ENV PYTHONPATH=/usr/local/lib/python3.10/site-packages:$PYTHONPATH
# Default command
CMD ["/bin/bash"]
Concerns: COPY from builder to runtime uses a wildcard path: COPY --from=builder /usr/local/lib/python*/site-packages/faiss /usr/local/lib/python3.10/site-packages/faiss. Docker COPY does not expand wildcards, so this may fail at build time or copy an unexpected path. Use an exact path like /usr/local/lib/python3.10/site-packages/faiss and adjust if Python version differs., Runtime image installs Python but does not install numpy explicitly. The Faiss Python package installed in build stage used --no-deps; if numpy (a common dependency) is required at runtime, imports may fail unless numpy is installed in the runtime image., Copying /usr/local/lib from builder to runtime may bring in extra libraries not strictly needed, increasing image size and potential conflicts. Consider copying only the specific Faiss-related libs or ensuring minimal runtime dependencies.
# Stage 1: build Faiss from source in a dedicated builder image
FROM ubuntu:22.04 as builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
python3-pip \
python3-dev \
gcc \
g++ \
make \
swig \
git \
wget \
libomp-dev \
libopenblas-dev \
libgflags-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Install Python build tooling and numpy for building Python bindings
RUN python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir numpy==1.26.4 scipy
# Set workdir to repository root and copy source code
WORKDIR /workspace/faiss
COPY . /workspace/faiss
# Configure and build Faiss (CPU, tests enabled, Release)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -- -j8
# Build the Python bindings and install into the builder image's Python site-packages
WORKDIR /workspace/faiss/build/faiss/python
RUN python3 -m pip install --no-cache-dir --upgrade pip
RUN python3 -m pip install --no-deps --ignore-installed .
# Stage 2: runtime image (lean)
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime Python and essential libraries
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-pip \
libomp-dev \
libopenblas-dev \
ca-certificates \
wget \
git \
swig \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy Python Faiss package and shared libraries from builder
COPY --from=builder /workspace/faiss/build/faiss/python /usr/local/lib/python3.10/site-packages/faiss
COPY --from=builder /usr/local/lib /usr/local/lib
# Ensure Python can find Faiss
ENV PYTHONPATH=/usr/local/lib/python3.10/site-packages:$PYTHONPATH
# Default command
CMD ["/bin/bash"]
Concerns: COPY --from=builder /workspace/faiss/build/faiss/python /usr/local/lib/python3.10/site-packages/faiss may not place the Python package in the correct layout; the Faiss Python bindings are typically installed into /usr/local/lib/python3.10/site-packages/faiss as a top-level directory. This COPY could result in an incorrect structure (e.g., faiss/faiss) or missing shared object files, causing import failures., COPY --from=builder /usr/local/lib /usr/local/lib duplicates runtime libraries but relies on the builder having compiled extensions compatible with the runtime Python; ensure the exact native extensions (.so files) are copied and compatible with the runtime Python version., The runtime image installs build tools (gcc/g++) and swig unnecessary for runtime; not a functional issue but increases image size.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev \
libomp-dev libopenblas-dev wget mc libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy source code
WORKDIR /workspace/faiss
COPY . .
# Install Python build dependencies (NumPy header for building Python bindings)
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Configure and build Faiss (CPU-only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Install the Python bindings
RUN cd build/faiss/python && python3 setup.py install
# Save the installed Python package to a temporary location for copying to runtime
RUN mkdir -p /tmp/faiss/python && cp -a /usr/local/lib/python3.10/site-packages/faiss /tmp/faiss/python/
# Final runtime image (minimal)
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python Faiss package from the builder stage
COPY --from=builder /tmp/faiss/python /usr/local/lib/python3.10/site-packages/
# Basic sanity test to verify import at container startup
CMD ["bash", "-lc", "python3 -c 'import faiss; print(\"faiss OK\")'"]
Summary: - Exact error message and exit code - Exit code: 1 - Error: "CMake 3.24.0 or higher is required. You are running version 3.22.1" - Context: CMake error reported at CMakeLists.txt:22 (cmake_minimum_required) - Failing command/step - [builder 6/10] RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release . - Missing packages or files mentioned - None explicitly mentioned as missing; the issue is a version mismatch in CMake rather than a missing package/file. - Version mismatch info - CMake minimum required: 3.24.0 - Installed: 3.22.1 - The log shows the exact line: "CMake 3.24.0 or higher is required. You are running version 3.22.1" and references CMakeLists.txt:22.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc gflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by the build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Install Python bindings into the builder's Python environment
RUN cd build/faiss/python && python3 setup.py install
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy Python Faiss package from the builder
COPY --from=builder /usr/local/lib/python3.10/site-packages/faiss /usr/local/lib/python3.10/site-packages/faiss
# Sanity check at container start
CMD ["bash","-lc","python3 -c 'import faiss; print("faiss OK")'"]
- Exact error message and exit code - E: Unable to locate package gflags-dev - The build failed: exit code 100 - Failing command/step - [builder 2/10] RUN apt-get update && apt-get install -y --no-install-recommends build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc gflags-dev && rm -rf /var/lib/apt/lists/* - Missing packages or files mentioned - Missing package: gflags-dev - Likely correct package for Ubuntu 22.04 (Jammy) should be libgflags-dev (gflags-dev is not available) - Version mismatch / upgrades - The install would upgrade core libs: gcc-12-base, libgcc-s1, libstdc++6 (3 upgraded, 36 newly installed) - Example upgraded versions shown: gcc-12-base 12.3.0-1ubuntu1~22.04.3, libstdc++6 12.3.0-1ubuntu1~22.04.3 - Note: No explicit mismatch reported beyond the package name issue; the failure is due to the non-existent gflags-dev package.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by the build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Install Python bindings into the builder's Python environment
RUN cd build/faiss/python && python3 setup.py install
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy Python Faiss package from the builder
COPY --from=builder /usr/local/lib/python3.10/site-packages/faiss /usr/local/lib/python3.10/site-packages/faiss
# Sanity check at container start
CMD ["bash","-lc","python3 -c 'import faiss; print("faiss OK")'" ]
- Exact error message and exit code - ERROR: failed to build: failed to solve: failed to compute cache key: failed to calculate checksum of ref mqpnlh3la2bzegxdamkvycc7g::yqk3wk69ws20sium9jrqdc63x: "/usr/local/lib/python3.10/site-packages/faiss": not found - Failing command/step - Stage-1 3/3: COPY --from=builder /usr/local/lib/python3.10/site-packages/faiss /usr/local/lib/python3.10/site-packages/faiss - Missing packages or files mentioned - The Faiss package directory expected at /usr/local/lib/python3.10/site-packages/faiss is not present in the builder image. - The build log shows Faiss installed as faiss-1.14.1-py3.10.egg under /usr/local/lib/python3.10/dist-packages (not site-packages), leading to the missing target for the COPY. - Version mismatch info - Faiss version used: faiss==1.14.1 (egg) installed to /usr/local/lib/python3.10/dist-packages/faiss-1.14.1-py3.10.egg - The final image expects Faiss under /usr/local/lib/python3.10/site-packages/faiss, causing a path/version mismatch during the COPY from builder.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by the build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Install Python bindings into the builder's Python environment
RUN cd build/faiss/python && python3 setup.py install
# Copy Python bindings to a staging area for final image
RUN mkdir -p /tmp/faiss-python
RUN cp -a /usr/local/lib/python3.10/dist-packages/faiss* /tmp/faiss-python/ 2>/dev/null || true
RUN cp -a /usr/local/lib/python3.10/site-packages/faiss* /tmp/faiss-python/ 2>/dev/null || true
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy Python Faiss bindings from builder
COPY --from=builder /tmp/faiss-python /usr/local/lib/python3.10/site-packages/
# Ensure numpy is available in runtime
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Sanity check at container start
CMD ["bash","-lc","python3 -c 'import faiss; print("faiss OK")'" ]
Concerns: The CMD instruction uses nested quotes and will likely fail to run due to quoting in the Dockerfile; it should escape inner quotes, for example: CMD ["bash","-lc","python3 -c 'import faiss; print(\"faiss OK\")'"] or use a simpler test., The final image copies Python bindings to /usr/local/lib/python3.10/site-packages, assuming Python 3.10. If the base image uses a different Python version, the path may differ and the bindings may not be found.
Smoke [FAIL]: python3 -c \"import faiss, numpy as np; xb = np.random.rand(10, 128).astype('float32'); idx = faiss.IndexFlatL2(128); idx.add(xb); print('faiss OK', idx.ntotal)\
Output: sh: 1: Syntax error: "(" unexpected
Smoke [FAIL]: python3 -c \"import faiss, numpy as np; xb = np.random.rand(5, 64).astype('float32'); idx = faiss.IndexFlatIP(64); idx.add(xb); print(idx.ntotal)\
Output: sh: 1: Syntax error: "(" unexpectedFROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by the build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Build Python wheel for FAISS Python bindings
RUN cd build/faiss/python && python3 setup.py bdist_wheel --dist-dir /tmp/wheel
# Install the wheel into a staging PyPI directory (to ensure compatibility in final image)
RUN mkdir -p /tmp/wheel/dist && cp /tmp/wheel/faiss-*.whl /tmp/wheel/dist/
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python wheel from the builder and install it
COPY --from=builder /tmp/wheel/faiss-*.whl /tmp/faiss-wheels/
RUN python3 -m pip install --no-cache-dir /tmp/faiss-wheels/faiss-*.whl
# Sanity check at container start
CMD ["bash","-lc","python3 -c 'import faiss; print("faiss OK")'" ]
Concerns: COPY --from=builder /tmp/wheel/faiss-*.whl /tmp/faiss-wheels/ uses a wildcard in the source path. Docker COPY does not reliably expand wildcards in multi-stage builds, which will likely fail at build time. Prefer copying a directory (e.g., /tmp/wheel) and then referring to the wheel(s) in a subsequent RUN step.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by the build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Build Python wheel for FAISS Python bindings
RUN cd build/faiss/python && python3 setup.py bdist_wheel --dist-dir /tmp/wheel
# Install the wheel into a staging PyPI directory (to ensure compatibility in final image)
RUN mkdir -p /tmp/wheel/dist && cp /tmp/wheel/faiss-*.whl /tmp/wheel/dist/
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python wheel from the builder and install it
COPY --from=builder /tmp/wheel /tmp/wheel
RUN python3 -m pip install --no-cache-dir /tmp/wheel/faiss-*.whl
# Sanity check at container start
CMD ["bash","-lc","python3 -c 'import faiss; print("faiss OK")'" ]
Concerns: BUILD_TESTING=ON may pull in and require additional test dependencies; consider turning it OFF to speed up builds and reduce potential failure points in minimal environments., The wheel packaging relies on the build output path /tmp/wheel/faiss-*.whl; if the wheel filename differs (versioned name changes), the final COPY/install steps could fail. Ensure the wheel is reliably named as faiss-*.whl.
Smoke [FAIL]: python3 -c \"import faiss; print('faiss OK', faiss.__version__)\
Output: sh: 1: Syntax error: word unexpected (expecting ")")
Smoke [FAIL]: python3 -c \"import faiss, numpy as np; d = 4; xb = np.random.rand(5, d).astype('float32'); index = faiss.IndexFlatL2(d); index.add(xb); D, I = index.search(xb[:2], 3); print('ntotal', index.ntotal)\
Output: sh: 1: Syntax error: "(" unexpectedFROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by the build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Build Python wheel for FAISS Python bindings
RUN cd build/faiss/python && python3 setup.py bdist_wheel --dist-dir /tmp/wheel
# Install the wheel into a staging PyPI directory (to ensure compatibility in final image)
RUN mkdir -p /tmp/wheel/dist && cp /tmp/wheel/faiss-*.whl /tmp/wheel/dist/
# Create a simple test script to verify import without quoting issues
RUN printf '%s
' '#!/usr/bin/env bash' 'python3 -c \'import faiss; print("faiss OK")\'' > /usr/local/bin/faiss-test.sh \
&& chmod +x /usr/local/bin/faiss-test.sh
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python wheel from the builder and install it
COPY --from=builder /tmp/wheel /tmp/wheel
RUN python3 -m pip install --no-cache-dir /tmp/wheel/faiss-*.whl
# Sanity check at container start (robust to quoting in smoke tests)
CMD ["/bin/bash","-lc","/usr/local/bin/faiss-test.sh"]
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.99kB done
#1 DONE 0.1s
Dockerfile:35
--------------------
34 | RUN printf '%s
35 | >>> ' '#!/usr/bin/env bash' 'python3 -c \'import faiss; print("faiss OK")\'' > /usr/local/bin/faiss-test.sh \
36 | >>> && chmod +x /usr/local/bin/faiss-test.sh
37 |
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 35: unknown instruction: 'FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by the build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Install Python packaging tools
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Build Python wheel for FAISS Python bindings
RUN cd build/faiss/python && python3 setup.py bdist_wheel --dist-dir /tmp/wheel
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python wheel from the builder and install it
COPY --from=builder /tmp/wheel /tmp/wheel
RUN python3 -m pip install --no-cache-dir /tmp/wheel/faiss-*.whl
# Install numpy for runtime usage (tests and examples rely on numpy)
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Create a test script to verify import and basic usage in a robust way
RUN mkdir -p /usr/local/bin
RUN bash -lc 'cat > /usr/local/bin/faiss_test.py << "PY"
import faiss
import numpy as np
xb = np.random.rand(5, 8).astype("float32")
idx = faiss.IndexFlatL2(8)
idx.add(xb)
print("ntotal", idx.ntotal)
PY
' && chmod +x /usr/local/bin/faiss_test.py
# Run a quick smoke test on container start
CMD ["/usr/local/bin/faiss_test.py"]
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2.13kB done
#1 DONE 0.0s
Dockerfile:54
--------------------
52 | RUN mkdir -p /usr/local/bin
53 | RUN bash -lc 'cat > /usr/local/bin/faiss_test.py << "PY"
54 | >>> import faiss
55 | import numpy as np
56 | xb = np.random.rand(5, 8).astype("float32")
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 54: unknown instruction: importFROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget mc \
libgflags-dev \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by Faiss build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local
# Ensure Python packaging tools are up to date
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Build Python wheel for FAISS Python bindings
RUN cd build/faiss/python && python3 setup.py bdist_wheel --dist-dir /tmp/wheel
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python wheel from the builder and install it
COPY --from=builder /tmp/wheel /tmp/wheel
RUN python3 -m pip install --no-cache-dir /tmp/wheel/faiss-*.whl
# Also install numpy for runtime usage in demos/tests (stable version)
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Create a small, robust smoke test script for startup
RUN mkdir -p /usr/local/bin
RUN bash -lc 'cat > /usr/local/bin/faiss_test.py << "PY"\
import faiss\nimport numpy as np\nxb = np.random.rand(5, 8).astype("float32")\nidx = faiss.IndexFlatL2(8)\nidx.add(xb)\nprint("ntotal", idx.ntotal)\nPY' \
&& chmod +x /usr/local/bin/faiss_test.py
# Run smoke test on container start to verify import and basic usage
CMD ["/usr/local/bin/faiss_test.py"]
Concerns: The line that installs a newer CMake uses: wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local. This is likely incorrect because tar usually needs -f - (or a file) to read from stdin; as written, it may fail to extract. Use: wget -qO- "...tar.gz" | tar --strip-components=1 -xzf - -C /usr/local or tar -xzf /path/to/archive -C /usr/local after downloading to a file., Potential inefficiency or risk: building Faiss from source in a multi-stage image can be heavy and slow; ensure this matches intended CI/build time constraints.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by Faiss build
RUN wget -qO- "https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz" -O /tmp/cmake.tar.gz \
&& mkdir -p /tmp/cmake && tar -xzf /tmp/cmake.tar.gz -C /tmp/cmake --strip-components=1 \
&& cp -r /tmp/cmake/* /usr/local/ \
&& rm -rf /tmp/cmake /tmp/cmake.tar.gz
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Build Python wheel for FAISS Python bindings
RUN cd build/faiss/python && python3 setup.py bdist_wheel --dist-dir /tmp/wheel
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python wheel from the builder and install it
COPY --from=builder /tmp/wheel /tmp/wheel
RUN python3 -m pip install --no-cache-dir /tmp/wheel/faiss-*.whl
# Install numpy for runtime usage (demos/tests rely on numpy)
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Simple smoke test at startup
CMD ["python3", "-c", "import faiss; print('faiss OK')"]
Concerns: In the builder stage, the line RUN wget -qO- https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz uses -qO- together with -O, which is invalid and will fail to download CMake. It should be a single -O /tmp/cmake.tar.gz download (e.g., wget -q https://... -O /tmp/cmake.tar.gz)., There is a potential risk that the Faiss Python wheel build may not produce faiss-*.whl as expected; if the wheel is not created, the final image install will fail. Consider adding a check that the wheel exists in /tmp/wheel before attempting pip install.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by Faiss build
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& mkdir -p /tmp/cmake && tar -xzf /tmp/cmake.tar.gz -C /tmp/cmake --strip-components=1 \
&& cp -r /tmp/cmake/* /usr/local/ \
&& rm -rf /tmp/cmake /tmp/cmake.tar.gz
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Build Python wheel for FAISS Python bindings
RUN cd build/faiss/python && python3 setup.py bdist_wheel --dist-dir /tmp/wheel
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python wheel from the builder and install it
COPY --from=builder /tmp/wheel /tmp/wheel
RUN python3 -m pip install --no-cache-dir /tmp/wheel/faiss-*.whl
# Install numpy for runtime usage (demos/tests rely on numpy)
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Simple smoke test at startup
CMD ["python3", "-c", "import faiss; print('faiss OK')"]
- Exact error message and exit code: - cp: cannot overwrite non-directory '/usr/local/man' with directory '/tmp/cmake/man' - Exit code: 1 (the step failed with exit code 1) - Failing command/step: - [builder 3/10] RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz && mkdir -p /tmp/cmake && tar -xzf /tmp/cmake.tar.gz -C /tmp/cmake --strip-components=1 && cp -r /tmp/cmake/* /usr/local/ && rm -rf /tmp/cmake /tmp/cmake.tar.gz - Missing packages or files mentioned: - None reported. The failure is caused by a filesystem conflict: /usr/local/man exists as a non-directory, preventing cp -r from overwriting it with the extracted /tmp/cmake/man directory. - Version mismatch info: - The build intends a newer CMake (3.26.x). The downloaded tarball is cmake-3.26.5-linux-x86_64.tar.gz, consistent with the intended version. No version mismatch is indicated in the log; the failure is due to the /usr/local/man conflict, not a version issue.
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build tools and dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential cmake git swig python3 python3-pip python3-dev libomp-dev libopenblas-dev wget ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (3.26.x) as required by Faiss build
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& mkdir -p /tmp/cmake && tar -xzf /tmp/cmake.tar.gz -C /tmp/cmake --strip-components=1 \
&& cp -r /tmp/cmake/* /usr/local/ \
&& rm -rf /tmp/cmake /tmp/cmake.tar.gz
# Copy sources
WORKDIR /workspace/faiss
COPY . .
# Install Python build requirements
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Build Faiss (CPU only, with Python bindings)
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .
RUN make -C build -j8 faiss
RUN make -C build -j8 swigfaiss
# Build Python wheel for FAISS Python bindings
RUN cd build/faiss/python && python3 setup.py bdist_wheel --dist-dir /tmp/wheel
# Final runtime image
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# Runtime dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
python3 python3-pip libomp-dev libopenblas-base ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the Python wheel from the builder and install it
COPY --from=builder /tmp/wheel /tmp/wheel
RUN python3 -m pip install --no-cache-dir /tmp/wheel/faiss-*.whl
# Install numpy for runtime usage (demos/tests rely on numpy)
RUN python3 -m pip install --no-cache-dir numpy==1.26.4
# Simple smoke test at startup
CMD ["python3", "-c", "import faiss; print('faiss OK')"]
Summary (under 1500 chars): - Exact error message and exit code: - cp: cannot overwrite non-directory '/usr/local/man' with directory '/tmp/cmake/man' - The build failed with exit code: 1 (failed to complete: exit code: 1) - Failing command/step: - RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz && mkdir -p /tmp/cmake && tar -xzf /tmp/cmake.tar.gz -C /tmp/cmake --strip-components=1 && cp -r /tmp/cmake/* /usr/local/ && rm -rf /tmp/cmake /tmp/cmake.tar.gz - Missing packages or files mentioned: - None explicitly missing. The error indicates a filesystem conflict: /usr/local/man is a non-directory, causing cp -r /tmp/cmake/* /usr/local/ to fail when copying /tmp/cmake/man. - Version mismatch info: - Dockerfile intends to use a newer CMake (3.26.x) for Faiss. The failing command tries to download cmake-3.26.5-linux-x86_64.tar.gz, i.e., version 3.26.5. The error is not a version mismatch but a pre-existing path conflict during extraction/copy.
Summary: - Purpose: CMake build script for FAISS with architecture-specific SIMD variants and optional SVS support. - SIMD source registries: - FAISS_SIMD_AVX2_SRC: impl/fast_scan/impl-avx2.cpp; impl/pq_code_distance/pq_code_distance-avx2.cpp; impl/scalar_quantizer/sq-avx2.cpp; impl/approx_topk/avx2.cpp; utils/simd_impl/distances_avx2.cpp - FAISS_SIMD_AVX512_SRC: impl/fast_scan/impl-avx512.cpp; impl/pq_code_distance/pq_code_distance-avx512.cpp; impl/scalar_quantizer/sq-avx512.cpp; utils/simd_impl/distances_avx512.cpp - FAISS_SIMD_NEON_SRC: impl/fast_scan/impl-neon.cpp; impl/scalar_quantizer/sq-neon.cpp; impl/approx_topk/neon.cpp; utils/simd_impl/distances_aarch64.cpp - FAISS_SIMD_SVE_SRC: impl/pq_code_distance/pq_code_distance-sve.cpp; utils/simd_impl/distances_arm_sve.cpp - Architecture dispatch: - x86_64/amd64: FAISS_SIMD_SRC = AVX2 + AVX512 - aarch64/arm64/ARM64: FAISS_SIMD_SRC = NEON + SVE - else: FAISS_SIMD_SRC = empty - Core sources (FAISS_SRC): broad set of core modules (AutoTune.cpp, Clustering.cpp, many impl/ and utils/ files, index/*, invlists/*, etc.). SVS variants appended if FAISS_ENABLE_SVS is on. - Headers (FAISS_HEADERS): extensive header list corresponding to core + impl and utils. SVS headers appended when enabled. - OnDisk inverted lists: included for non-Windows (invlists/OnDiskInvertedLists.cpp and .h). - Export: FAISS_HEADERS exported to parent scope. - Build targets: - faiss (main) - faiss_avx2 (requires -mavx2/-mfma/-mf16c/-mpopcnt on non-Windows; excluded from all unless FAISS_OPT_LEVEL=avx2) - faiss_avx512 (requires -mavx2 -mfma -mf16c -mavx512*; excluded unless FAISS_OPT_LEVEL=avx512) - faiss_avx512_spr (requires Sapphire Rapids flags; excluded unless FAISS_OPT_LEVEL=avx512_spr) - faiss_sve (NEON+SVE; excluded unless FAISS_OPT_LEVEL=sve; NEON/SVE handling varies by platform) - Dynamic Dispatch (dd): - If FAISS_OPT_LEVEL == "dd", main faiss builds with runtime SIMD dispatch (FAISS_ENABLE_DD) and architecture-specific per-file flags (AVX2/AVX512) and baseline per-file options. - ARM (aarch64): per-file SVE/NEON handling when in DD mode. - ARM specifics: - NEON is mandatory on ARM64: COMPILE_SIMD_ARM_NEON defined; NEON sources always compiled into main faiss target. - SVE handling added for ARM where applicable. - SVS (optional): - If FAISS_ENABLE_SVS, add SVS sources to FAISS and link svs_runtime; install libsvs_runtime. - Dependencies: - OpenMP (required) - MKL optional (if FAISS_USE_MKL; otherwise BLAS/LAPACK are required) - If MKL not found, link BLAS and LAPACK for all variants - Packaging/install: - Install targets: faiss; conditionally faiss_avx2, faiss_avx512, faiss_avx512_spr, faiss_sve based on FAISS_OPT_LEVEL - Install headers under faiss/ dir structure - Create and install faiss-config.cmake and faiss-config-version.cmake - Install faiss-targets export - Misc: - FINTEGER=int defined for all faiss targets - Optional LTO (FAISS_USE_LTO) with IPO support check - Windows: export of symbols and /arch flags handling; special handling of bigobj where needed - On Windows, some non-needed options are adjusted (e.g., arch flags) - File references to preserve actionable detail: - SIMD: impl-avx2.cpp, pq_code_distance-avx2.cpp, sq-avx2.cpp, avx2.cpp, distances_avx2.cpp; avx512 equivalents; neon/sve variants - Core/impl/utils lists and numerous FAISS_SRC/FAISS_HEADERS entries (as shown) - svs/ sources and headers when FAISS_ENABLE_SVS is on - OnDiskInvertedLists.cpp/.h for non-WIN32 - Install paths and cmake config files locations (cmake/faiss-config.cmake, faiss-targets) If you want, I can extract a shorter, exact list of updated/modified files per target.
# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: import Faiss and print version
CMD ["bash","-lc","python3 -c '\nimport faiss, sys\nprint("Faiss loaded:", getattr(faiss, "__version__", "unknown"))\n'"]
Failing step - Command: RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release . - Exit code: 1 - Exact error message (preserved): Could NOT find Python (missing: Python_INCLUDE_DIRS Python_NumPy_INCLUDE_DIRS Development.Module NumPy) (found version "3.10.12") Call Stack (most recent call first): /usr/local/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE) /usr/local/share/cmake-3.26/Modules/FindPython.cmake:622 (find_package_handle_standard_args) faiss/python/CMakeLists.txt:295 (find_package) -- Configuring incomplete, errors occurred! Missing packages or files mentioned - Python_INCLUDE_DIRS - Python_NumPy_INCLUDE_DIRS - Development.Module - NumPy - (Note: The error reports these as missing despite Python 3.10.12 being found.) Version/mismatch info - Found version: "3.10.12" - Environment shows a mix of Python versions in the build, e.g. Python 3.10.12 appears as found, while other installed Python components show 3.10.6 (e.g., libpython3-stdlib, python3-dev, etc.), indicating a mismatch between Python runtime and development headers/libs in the image. This could contribute to FindPython failing to locate include/NumPy headers.
# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: import Faiss and print version
CMD ["bash","-lc","python3 - << 'PY'
import faiss, sys
print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))
PY
"]
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2.04kB done
#1 DONE 0.0s
Dockerfile:56
--------------------
54 | # Basic verification: import Faiss and print version
55 | CMD ["bash","-lc","python3 - << 'PY'
56 | >>> import faiss, sys
57 | print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))
58 | PY
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 56: unknown instruction: import# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: import Faiss and print version
CMD ["bash","-lc","python3 -c 'import faiss, sys; print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))'" ]
Concerns: Python wheel compatibility between builder and runtime (different CPython versions could cause wheel install to fail if Python versions diverge)., Consider adding a lightweight runtime test to verify basic Faiss functionality beyond import (optional).
Smoke [FAIL]: python3 -c 'import faiss, sys; print("Faiss version:", getattr(faiss, "__version__", "unknown"))
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python3 -c 'import faiss; idx = faiss.IndexFlatL2(4); print("idx.d=", idx.d, "ntotal=", idx.ntotal)
Output: sh: 1: Syntax error: Unterminated quoted string# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: import Faiss and print version
CMD ["bash","-lc","python3 - <<'PY'
import faiss, sys
print('Faiss loaded:', getattr(faiss, '__version__', 'unknown'))
idx = faiss.IndexFlatL2(4)
print('idx.d=', idx.d, 'ntotal=', idx.ntotal)
PY"]
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2.11kB done
#1 DONE 0.0s
Dockerfile:56
--------------------
54 | # Basic verification: import Faiss and print version
55 | CMD ["bash","-lc","python3 - <<'PY'
56 | >>> import faiss, sys
57 | print('Faiss loaded:', getattr(faiss, '__version__', 'unknown'))
58 | idx = faiss.IndexFlatL2(4)
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 56: unknown instruction: import# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:jammy-20260217 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:jammy-20260217 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: import Faiss and print version
CMD ["bash","-lc","python3 -c 'import faiss, sys; print("Faiss loaded:", getattr(faiss, "__version__", "unknown")); idx = faiss.IndexFlatL2(4); print("idx.d=", idx.d, "ntotal=", idx.ntotal)'" ]
Concerns: Potential numpy version mismatch: runtime installs numpy separately while the wheel from build may bundle its own numpy compatibility. Ensure wheel is compatible with the runtime numpy version., The build can be heavy and time-consuming; consider caching or optimizing the builder steps for faster rebuilds in CI., No explicit tests run during build: the Dockerfile relies on runtime CMD for verification. Consider adding lightweight build-time tests (optional).
Smoke [FAIL]: python3 -c 'import faiss, sys; print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python3 -c 'import faiss; idx = faiss.IndexFlatL2(4); print("idx.d=", idx.d, "ntotal=", idx.ntotal)
Output: sh: 1: Syntax error: Unterminated quoted string# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: ensure Faiss can be imported
CMD ["bash","-lc","python3 - <<'PY'
import faiss, sys
print('Faiss loaded:', getattr(faiss, '__version__', 'unknown'))
PY"]
# Ignore typical build outputs and large folders .git build .tmp *.pyc *.pyo *.o __pycache__ .dockerignore
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.80kB done
#1 DONE 0.0s
Dockerfile:52
--------------------
50 | # Basic verification: ensure Faiss can be imported
51 | CMD ["bash","-lc","python3 - <<'PY'
52 | >>> import faiss, sys
53 | print('Faiss loaded:', getattr(faiss, '__version__', 'unknown'))
54 | PY"]
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 52: unknown instruction: import# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:jammy-20260217 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:jammy-20260217 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: ensure Faiss can be imported
CMD ["bash","-lc","python3 -c 'import faiss, sys; print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))'"]
- Exact error message and exit code - Exit code: 1 - Error: CMake Error at CMakeLists.txt:22 (cmake_minimum_required): CMake 3.24.0 or higher is required. You are running version 3.22.1 - The failing command/step - [builder 7/12] RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release . - Missing packages or files mentioned - No missing packages or files are mentioned in the error output. - Version mismatch info - Required: CMake 3.24.0 or higher - Found: CMake 3.22.1 Root cause (implied): The build requires a newer CMake than what is installed in the image.
# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:jammy-20260217 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:jammy-20260217 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: ensure Faiss can be imported
CMD ["bash","-lc","python3 -c 'import faiss, sys; print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))'"]
Concerns: The CMD line in the runtime stage has quoting issues that would likely break Dockerfile parsing or the image startup (unescaped quotes inside the -c argument). Consider escaping inner quotes or using a small entrypoint script to perform the check.
# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:jammy-20260217 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:jammy-20260217 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Basic verification: ensure Faiss can be imported
CMD ["bash","-lc","python3 -c 'import faiss, sys; print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))'" ]
Concerns: Build may take long and consume substantial CPU/memory resources during image build., Uses a pinned base image tag (ubuntu:jammy-20260217) which may not exist or could be updated; consider using a more stable tag or pinning to a digest., The runtime image installs numpy explicitly; ensure the Python wheel from builder is compatible with the runtime numpy version, otherwise potential ABI issues.
Smoke [FAIL]: python3 -c "import faiss,sys; print('Faiss loaded:', getattr(faiss,'__version__','unknown'))
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python3 -c "import faiss, numpy as np; d=4; x = np.zeros((1,d), dtype='float32'); idx = faiss.IndexFlatL2(d); idx.add(x); D,I = idx.search(x,1); print('index created, I=', I)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python3 -c "import faiss; print('IndexFlatL2 type:', type(faiss.IndexFlatL2(4)))
Output: sh: 1: Syntax error: Unterminated quoted string# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:jammy-20260217 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:jammy-20260217 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Create a small Python verifier script and expose it as entrypoint
RUN printf '%s
' '#!/usr/bin/env python3' 'import faiss' 'print("Faiss loaded; version:", getattr(faiss, "__version__", "unknown"))' > /check_faiss.py \
&& chmod +x /check_faiss.py
# Default command runs the verifier
CMD ["/check_faiss.py"]
# Ignore typical build outputs and large folders .git build .tmp *.pyc *.pyo *.o __pycache__ .dockerignore
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 2.21kB done
#1 DONE 0.0s
Dockerfile:57
--------------------
56 | RUN printf '%s
57 | >>> ' '#!/usr/bin/env python3' 'import faiss' 'print("Faiss loaded; version:", getattr(faiss, "__version__", "unknown"))' > /check_faiss.py \
58 | >>> && chmod +x /check_faiss.py
59 |
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 57: unknown instruction: '# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:22.04 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Create a small Python verifier script and expose it as entrypoint
CMD ["python3", "-c", "import faiss; print('Faiss loaded:', getattr(faiss, '__version__', 'unknown'))"]
Concerns: Build time may be long and resource-intensive for CI., No explicit runtime functional tests beyond loading Faiss; consider adding a small index operation as smoke test.
Smoke [FAIL]: python3 -c 'import faiss; print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python3 -c 'import faiss, numpy as np; d=4; a=np.zeros((1,d), dtype=np.float32); idx=faiss.IndexFlatL2(d); idx.add(a); print("ntotal:", idx.ntotal)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python3 -c 'import faiss; print("IndexFlatL2 exists:", hasattr(faiss, "IndexFlatL2"))
Output: sh: 1: Syntax error: Unterminated quoted string# Build-faiss: CPU-only, from source, with Python bindings
FROM ubuntu:jammy-20260217 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip python3-dev \
build-essential cmake git swig \
sudo libomp-dev libopenblas-dev wget libgflags-dev ca-certificates \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Install a newer CMake (required by Faiss build)
RUN wget -q https://cmake.org/files/v3.26/cmake-3.26.5-linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \
&& tar --strip-components=1 -xz -f /tmp/cmake.tar.gz -C /usr/local \
&& rm /tmp/cmake.tar.gz
# Ensure Python packaging and NumPy headers are available for Python bindings
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install numpy
# Copy source code into the image
COPY . /root/faiss
WORKDIR /root/faiss
# Configure and build Faiss (CPU only, disable tests for speed)
RUN cmake -B build \
-DFAISS_ENABLE_GPU=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release .
RUN cmake --build build -j 8
RUN cmake --build build -j 8 --target swigfaiss
# Build Python bindings into a wheel for easy shipping to runtime
WORKDIR /root/faiss/build/faiss/python
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 setup.py bdist_wheel -d /wheels
# Runtime image: only runtime dependencies and the faiss wheel
FROM ubuntu:jammy-20260217 AS runtime
ENV DEBIAN_FRONTEND=noninteractive
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip libomp5 libopenblas-base \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install numpy+faiss wheel
COPY --from=builder /wheels /wheels
RUN python3 -m pip install numpy
RUN for f in /wheels/*.whl; do python3 -m pip install "$f"; done
# Create a small Python verifier script and expose it as entrypoint
RUN printf '%s\n' '#!/usr/bin/env python3' 'import faiss' 'print("Faiss loaded:", getattr(faiss, "__version__", "unknown"))' > /check_faiss.py \
&& chmod +x /check_faiss.py
# Default command runs the verifier
CMD ["/check_faiss.py"]