diff --git a/.github/test/Dockerfile-alpine b/.github/test/Dockerfile-alpine index 0e63982d9..029cb1dc0 100644 --- a/.github/test/Dockerfile-alpine +++ b/.github/test/Dockerfile-alpine @@ -7,6 +7,8 @@ ENV PYTHONUNBUFFERED=1 COPY requirements.txt /requirements.txt +ARG TARGETPLATFORM + RUN \ apk add --update --no-cache --virtual=build-dependencies \ build-base \ @@ -31,12 +33,18 @@ RUN \ glib \ libsm \ libxext \ - libxrender \ - py3-opencv && \ + libxrender && \ + case "$TARGETPLATFORM" in \ + linux/arm/v7|linux/arm/v8) \ + echo "INFO: Skipping py3-opencv on $TARGETPLATFORM (using pixelmatch fallback)" \ + ;; \ + *) \ + apk add --update --no-cache py3-opencv || echo "WARN: py3-opencv install failed, using pixelmatch fallback" \ + ;; \ + esac && \ echo "**** pip3 install test of changedetection.io ****" && \ python3 -m venv /lsiopy && \ pip install -U pip wheel setuptools && \ - grep -v "opencv-python-headless" /requirements.txt > /requirements-alpine.txt && \ - pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.22/ -r /requirements-alpine.txt && \ + pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.22/ -r /requirements.txt && \ apk del --purge \ build-dependencies diff --git a/Dockerfile b/Dockerfile index 5373fdae1..c0d6a18d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,6 +55,25 @@ RUN --mount=type=cache,id=pip,sharing=locked,target=/tmp/pip-cache \ playwright~=1.56.0 \ || echo "WARN: Failed to install Playwright. The application can still run, but the Playwright option will be disabled." +# OpenCV is optional for fast image comparison (pixelmatch is the fallback) +# Skip on arm/v7 and arm/v8 where builds take weeks - excluded from requirements.txt +ARG TARGETPLATFORM +RUN --mount=type=cache,id=pip,sharing=locked,target=/tmp/pip-cache \ + case "$TARGETPLATFORM" in \ + linux/arm/v7|linux/arm/v8) \ + echo "INFO: Skipping OpenCV on $TARGETPLATFORM (build takes too long), using pixelmatch fallback" \ + ;; \ + *) \ + pip install \ + --prefer-binary \ + --extra-index-url https://www.piwheels.org/simple \ + --cache-dir=/tmp/pip-cache \ + --target=/dependencies \ + opencv-python-headless>=4.8.0.76 \ + || echo "WARN: OpenCV install failed, will use pixelmatch fallback" \ + ;; \ + esac + # Final image stage FROM python:${PYTHON_VERSION}-slim-bookworm diff --git a/requirements.txt b/requirements.txt index c73b20e56..aac51fe65 100644 --- a/requirements.txt +++ b/requirements.txt @@ -73,9 +73,10 @@ lxml >=4.8.0,!=5.2.0,!=5.2.1,<7 elementpath==5.0.4 # For fast image comparison in screenshot change detection -# opencv-python-headless provides cv2 without GUI dependencies (smaller, faster) -# Note: OpenCV uses 4-part versioning (e.g., 4.8.0.76) -opencv-python-headless>=4.8.0.76 +# opencv-python-headless is OPTIONAL (excluded from requirements.txt) +# - Installed conditionally via Dockerfile (skipped on arm/v7 and arm/v8 due to long build times) +# - Pixelmatch is used as fallback when OpenCV is unavailable +# - To install manually: pip install opencv-python-headless>=4.8.0.76 selenium~=4.31.0