diff --git a/.github/test/Dockerfile-alpine b/.github/test/Dockerfile-alpine new file mode 100644 index 00000000..b255195d --- /dev/null +++ b/.github/test/Dockerfile-alpine @@ -0,0 +1,31 @@ +# Taken from https://github.com/linuxserver/docker-changedetection.io/blob/main/Dockerfile +# Test that we can still build on Alpine (musl modified libc https://musl.libc.org/) +# Some packages wont install via pypi because they dont have a wheel available under this architecture. + +FROM ghcr.io/linuxserver/baseimage-alpine:3.16 +ENV PYTHONUNBUFFERED=1 + +COPY requirements.txt /requirements.txt + +RUN \ + apk add --update --no-cache --virtual=build-dependencies \ + cargo \ + g++ \ + gcc \ + libc-dev \ + libffi-dev \ + libxslt-dev \ + make \ + openssl-dev \ + py3-wheel \ + python3-dev \ + zlib-dev && \ + apk add --update --no-cache \ + libxslt \ + python3 \ + py3-pip && \ + echo "**** pip3 install test of changedetection.io ****" && \ + pip3 install -U pip wheel setuptools && \ + pip3 install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.16/ -r /requirements.txt && \ + apk del --purge \ + build-dependencies diff --git a/.github/workflows/test-container-build.yml b/.github/workflows/test-container-build.yml index 7d59ad0b..735b7205 100644 --- a/.github/workflows/test-container-build.yml +++ b/.github/workflows/test-container-build.yml @@ -43,6 +43,16 @@ jobs: version: latest driver-opts: image=moby/buildkit:master + # https://github.com/dgtlmoon/changedetection.io/pull/1067 + # Check we can still build under alpine/musl + - name: Test that the docker containers can build (musl via alpine check) + id: docker_build_musl + uses: docker/build-push-action@v2 + with: + context: ./ + file: ./.github/test/Dockerfile-alpine + platforms: linux/amd64,linux/arm64 + - name: Test that the docker containers can build id: docker_build uses: docker/build-push-action@v2 @@ -53,3 +63,4 @@ jobs: platforms: linux/arm/v7,linux/arm/v6,linux/amd64,linux/arm64, cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + diff --git a/Dockerfile b/Dockerfile index d16736fa..a88ab5a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,11 @@ COPY requirements.txt /requirements.txt RUN pip install --target=/dependencies -r /requirements.txt +# Playwright is an alternative to Selenium +# Excluded this package from requirements.txt to prevent arm/v6 and arm/v7 builds from failing +# https://github.com/dgtlmoon/changedetection.io/pull/1067 also musl/alpine (not supported) +RUN pip install --target=/dependencies playwright~=1.26 \ + || echo "WARN: Failed to install Playwright. The application can still run, but the Playwright option will be disabled." # Final image stage FROM python:3.8-slim diff --git a/changedetectionio/run_all_tests.sh b/changedetectionio/run_all_tests.sh index 2783c9b8..459513e8 100755 --- a/changedetectionio/run_all_tests.sh +++ b/changedetectionio/run_all_tests.sh @@ -38,6 +38,10 @@ unset WEBDRIVER_URL docker kill $$-test_selenium echo "TESTING WEBDRIVER FETCH > PLAYWRIGHT/BROWSERLESS..." +# Not all platforms support playwright (not ARM/rPI), so it's not packaged in requirements.txt +PLAYWRIGHT_VERSION=$(grep -i -E "RUN pip install.+" "$SCRIPT_DIR/../Dockerfile" | grep --only-matching -i -E "playwright[=><~+]+[0-9\.]+") +echo "using $PLAYWRIGHT_VERSION" +pip3 install "$PLAYWRIGHT_VERSION" docker run -d --name $$-test_browserless -e "DEFAULT_LAUNCH_ARGS=[\"--window-size=1920,1080\"]" --rm -p 3000:3000 --shm-size="2g" browserless/chrome:1.53-chrome-stable # takes a while to spin up sleep 5 diff --git a/requirements.txt b/requirements.txt index 48398276..fd5b23bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -52,7 +52,7 @@ jinja2-time # https://peps.python.org/pep-0508/#environment-markers # https://github.com/dgtlmoon/changedetection.io/pull/1009 -jq ~= 1.3 ;python_version >= "3.8" and sys_platform == "linux" -playwright~=1.26; python_version >= "3.8" and "arm" not in platform_machine and "aarch" not in platform_machine +jq~=1.3 ;python_version >= "3.8" and sys_platform == "linux" +# playwright is installed at Dockerfile build time because it's not available on all platforms