Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Playwright node components from source #17

Merged
merged 4 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ RUN \
libc-dev \
libffi-dev \
libxslt-dev \
npm \
openssl-dev \
python3-dev \
zip \
zlib-dev && \
apk add --update --no-cache \
libjpeg \
libxslt \
nodejs \
poppler-utils \
python3 && \
echo "**** install changedetection.io ****" && \
Expand All @@ -45,16 +48,35 @@ RUN \
pip \
wheel && \
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.19/ -r /app/changedetection/requirements.txt && \
PLAYWRIGHT_RELEASE=$(curl -sX GET "https://api.github.com/repos/microsoft/playwright-python/releases/latest" \
PLAYWRIGHT_PY_RELEASE=$(curl -sX GET "https://api.github.com/repos/microsoft/playwright-python/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
git clone --depth 1 --branch "${PLAYWRIGHT_RELEASE}" https://github.com/microsoft/playwright-python /tmp/playwright-python && \
git clone --depth 1 --branch "${PLAYWRIGHT_PY_RELEASE}" https://github.com/microsoft/playwright-python /tmp/playwright-python && \
cd /tmp/playwright-python && \
pip install -U --no-cache-dir . && \
git clone --depth 1 --branch "${PLAYWRIGHT_PY_RELEASE}" https://github.com/microsoft/playwright /tmp/playwright && \
cd /tmp/playwright && \
npm ci && \
npm run build && \
# Don't build for other platforms
sed -i '/-darwin-x64/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/-darwin-arm64/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/-linux-arm64/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/-win-x64/d' ./utils/build/build-playwright-driver.sh && \
# Don't download a static node binary, use the OS install
sed -i '/curl ${NODE_URL}/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/elif \[\[ "${ARCHIVE}" == "tar.gz" \]\]; then/,/else/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/cp .\/output\/${NODE_DIR}\/LICENSE .\/output\/playwright-${SUFFIX}\//d' ./utils/build/build-playwright-driver.sh && \
sed -i 's/"..\/..\/${NODE_DIR}\/${NPM_PATH}"/\/usr\/lib\/node_modules\/npm\/bin\/npm-cli.js/' ./utils/build/build-playwright-driver.sh && \
./utils/build/build-playwright-driver.sh && \
rm -rf /lsiopy/lib/python3.11/site-packages/playwright/driver/* && \
cp -R ./utils/build/output/playwright-linux/* /lsiopy/lib/python3.11/site-packages/playwright/driver && \
ln -s /usr/bin/node /lsiopy/lib/python3.11/site-packages/playwright/driver/node && \
apk del --purge \
build-dependencies && \
rm -rf \
/tmp/* \
$HOME/.cache
$HOME/.cache \
$HOME/.npm

COPY root/ /

Expand Down
29 changes: 26 additions & 3 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ RUN \
libc-dev \
libffi-dev \
libxslt-dev \
npm \
openssl-dev \
python3-dev \
zip \
zlib-dev && \
apk add --update --no-cache \
libjpeg \
libxslt \
nodejs \
poppler-utils \
python3 && \
echo "**** install changedetection.io ****" && \
Expand All @@ -45,16 +48,36 @@ RUN \
pip \
wheel && \
pip install -U --no-cache-dir --find-links https://wheel-index.linuxserver.io/alpine-3.19/ -r /app/changedetection/requirements.txt && \
PLAYWRIGHT_RELEASE=$(curl -sX GET "https://api.github.com/repos/microsoft/playwright-python/releases/latest" \
echo "**** install playwright ****" && \
PLAYWRIGHT_PY_RELEASE=$(curl -sX GET "https://api.github.com/repos/microsoft/playwright-python/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
git clone --depth 1 --branch "${PLAYWRIGHT_RELEASE}" https://github.com/microsoft/playwright-python /tmp/playwright-python && \
git clone --depth 1 --branch "${PLAYWRIGHT_PY_RELEASE}" https://github.com/microsoft/playwright-python /tmp/playwright-python && \
cd /tmp/playwright-python && \
pip install -U --no-cache-dir . && \
git clone --depth 1 --branch "${PLAYWRIGHT_PY_RELEASE}" https://github.com/microsoft/playwright /tmp/playwright && \
cd /tmp/playwright && \
npm ci && \
npm run build && \
# Don't build for other platforms
sed -i '/-darwin-x64/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/-darwin-arm64/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/-linux-x64/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/-win-x64/d' ./utils/build/build-playwright-driver.sh && \
# Don't download a static node binary, use the OS install
sed -i '/curl ${NODE_URL}/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/elif \[\[ "${ARCHIVE}" == "tar.gz" \]\]; then/,/else/d' ./utils/build/build-playwright-driver.sh && \
sed -i '/cp .\/output\/${NODE_DIR}\/LICENSE .\/output\/playwright-${SUFFIX}\//d' ./utils/build/build-playwright-driver.sh && \
sed -i 's/"..\/..\/${NODE_DIR}\/${NPM_PATH}"/\/usr\/lib\/node_modules\/npm\/bin\/npm-cli.js/' ./utils/build/build-playwright-driver.sh && \
./utils/build/build-playwright-driver.sh && \
rm -rf /lsiopy/lib/python3.11/site-packages/playwright/driver/* && \
cp -R ./utils/build/output/playwright-linux-arm64/* /lsiopy/lib/python3.11/site-packages/playwright/driver && \
ln -s /usr/bin/node /lsiopy/lib/python3.11/site-packages/playwright/driver/node && \
apk del --purge \
build-dependencies && \
rm -rf \
/tmp/* \
$HOME/.cache
$HOME/.cache \
$HOME/.npm

COPY root/ /

Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The architectures supported by this image are:

Webui is accessible at http://SERVERIP:PORT

Please note that as of version 0.45.15 this image contains the [Playwright content fetcher](https://github.com/dgtlmoon/changedetection.io/wiki/Playwright-content-fetcher#docker-compose-based).
Please note that as of version 0.45.16 this image contains the Playwright content fetcher.

For more info read [the wiki](https://github.com/dgtlmoon/changedetection.io/wiki).

Expand All @@ -73,18 +73,18 @@ To help you get started creating a container from this image you can either use

```yaml
---
version: "2.1"
services:
changedetection:
changedetection.io:
image: lscr.io/linuxserver/changedetection.io:latest
container_name: changedetection
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- TZ=Etc/UTC
- BASE_URL= #optional
- PLAYWRIGHT_DRIVER_URL= #optional
volumes:
- /path/to/appdata/config:/config
- /path/to/changedetection/config:/config
ports:
- 5000:5000
restart: unless-stopped
Expand All @@ -99,6 +99,7 @@ docker run -d \
-e PGID=1000 \
-e TZ=Etc/UTC \
-e BASE_URL= `#optional` \
-e PLAYWRIGHT_DRIVER_URL= `#optional` \
-p 5000:5000 \
-v /path/to/changedetection.io/config:/config \
--restart unless-stopped \
Expand All @@ -116,6 +117,7 @@ Containers are configured using parameters passed at runtime (such as those abov
| `-e PGID=1000` | for GroupID - see below for explanation |
| `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). |
| `-e BASE_URL=` | Specify the full URL (including protocol) when running behind a reverse proxy |
| `-e PLAYWRIGHT_DRIVER_URL=` | Specify the full URL to your chrome driver instance. See the [wiki](https://github.com/dgtlmoon/changedetection.io/wiki/Playwright-content-fetcher) for details. |
| `-v /config` | Persistent config files |

## Environment variables from files (Docker secrets)
Expand Down Expand Up @@ -279,7 +281,8 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64

## Versions

* **08.03.24:** - Build Playwright from source, add libjpeg.
* **09.03.24:** - Build Playwright from source because Microsoft's build and packaging process is awful.
* **08.03.24:** - Build Playwright-python from source, add libjpeg.
* **23.12.23:** - Rebase to Alpine 3.19.
* **10.08.23:** - Add poppler-utils for pdf conversion tools.
* **11.06.23:** - Rebase to Alpine 3.18, deprecate armhf.
Expand Down
15 changes: 9 additions & 6 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,39 @@ param_env_vars:
opt_param_usage_include_env: true
opt_param_env_vars:
- { env_var: "BASE_URL", env_value: "", desc: "Specify the full URL (including protocol) when running behind a reverse proxy" }
- { env_var: "PLAYWRIGHT_DRIVER_URL", env_value: "", desc: "Specify the full URL to your chrome driver instance. See the [wiki](https://github.com/dgtlmoon/changedetection.io/wiki/Playwright-content-fetcher) for details." }

custom_compose: |
---
version: "2.1"
services:
changedetection:
changedetection.io:
thespad marked this conversation as resolved.
Show resolved Hide resolved
image: lscr.io/linuxserver/changedetection.io:latest
container_name: changedetection
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- TZ=Etc/UTC
- BASE_URL= #optional
- PLAYWRIGHT_DRIVER_URL= #optional
volumes:
- /path/to/appdata/config:/config
- /path/to/changedetection/config:/config
ports:
- 5000:5000
restart: unless-stopped

# application setup block
app_setup_block_enabled: true
app_setup_block: |
Webui is accessible at http://SERVERIP:PORT

Please note that as of version 0.45.15 this image contains the [Playwright content fetcher](https://github.com/dgtlmoon/changedetection.io/wiki/Playwright-content-fetcher#docker-compose-based).
Please note that as of version 0.45.16 this image contains the Playwright content fetcher.

For more info read [the wiki](https://github.com/dgtlmoon/changedetection.io/wiki).

# changelog
changelogs:
- { date: "08.03.24:", desc: "Build Playwright from source, add libjpeg."}
- { date: "09.03.24:", desc: "Build Playwright from source because Microsoft's build and packaging process is awful."}
- { date: "08.03.24:", desc: "Build Playwright-python from source, add libjpeg."}
- { date: "23.12.23:", desc: "Rebase to Alpine 3.19."}
- { date: "10.08.23:", desc: "Add poppler-utils for pdf conversion tools." }
- { date: "11.06.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." }
Expand Down