diff --git a/node-playwright-camoufox/Dockerfile b/node-playwright-camoufox/Dockerfile index 6a6b4089..5f22f6ac 100644 --- a/node-playwright-camoufox/Dockerfile +++ b/node-playwright-camoufox/Dockerfile @@ -26,8 +26,8 @@ ENV PLAYWRIGHT_BROWSERS_PATH=/pw-browsers # Tell the crawlee cli that we already have browsers installed, so it skips installing them ENV CRAWLEE_SKIP_BROWSER_INSTALL=1 -# Camoufox stores its browser in ~/.cache/camoufox -ENV APIFY_DEFAULT_BROWSER_PATH=/home/myuser/.cache/camoufox/camoufox-bin +# Stable path through a symlink to the installed Camoufox directory. +ENV APIFY_DEFAULT_BROWSER_PATH=/home/myuser/.cache/camoufox-current/camoufox-bin # Prevent installing of browsers by future `npm install`. ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 @@ -139,9 +139,12 @@ RUN npm --quiet set progress=false \ \ # Install Camoufox browser && PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0 npx camoufox-js fetch \ - # Overrides the dynamic library used by Firefox to determine trusted root certificates with p11-kit-trust.so, which loads the system certificates. - && rm -f /home/myuser/.cache/camoufox/libnssckbi.so \ - && ln -s $(ls -d /usr/lib/*-linux-gnu)/pkcs11/p11-kit-trust.so /home/myuser/.cache/camoufox/libnssckbi.so \ + # Resolve both flat and versioned Camoufox cache layouts. + && CAMOUFOX_BINARY="$(find /home/myuser/.cache/camoufox -type f -name camoufox-bin)" \ + && test -x "$CAMOUFOX_BINARY" \ + && ln -s "$(dirname "$CAMOUFOX_BINARY")" "$(dirname "$APIFY_DEFAULT_BROWSER_PATH")" \ + # Load system certificates from the browser's own library directory. + && ln -sf "$(ls -d /usr/lib/*-linux-gnu)/pkcs11/p11-kit-trust.so" "$(dirname "$CAMOUFOX_BINARY")/libnssckbi.so" \ \ && npm install --omit=dev --omit=optional --no-package-lock --prefer-online \ && npm install --no-package-lock --prefer-online --no-save impit@latest \ diff --git a/python-playwright-camoufox/Dockerfile b/python-playwright-camoufox/Dockerfile index 2222db6e..42ea95c2 100644 --- a/python-playwright-camoufox/Dockerfile +++ b/python-playwright-camoufox/Dockerfile @@ -46,8 +46,8 @@ ENV CRAWLEE_SKIP_BROWSER_INSTALL=1 # Prevent playwright from downloading browsers when users install playwright via pip ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 -# Camoufox stores its browser in ~/.cache/camoufox -ENV APIFY_DEFAULT_BROWSER_PATH=/root/.cache/camoufox/camoufox-bin +# Stable path through a symlink to the installed Camoufox directory. +ENV APIFY_DEFAULT_BROWSER_PATH=/root/.cache/camoufox-current/camoufox-bin # Copy the script for registering intermediate certificates and the pre-downloaded certificates COPY ./register_intermediate_certs.sh ./register_intermediate_certs.sh @@ -111,9 +111,12 @@ RUN python -m pip install --upgrade \ camoufox[geoip]~=${CAMOUFOX_VERSION} \ # Fetch the Camoufox browser && python -m camoufox fetch \ - # Overrides the dynamic library used by Firefox to determine trusted root certificates with p11-kit-trust.so, which loads the system certificates. - && rm -f /root/.cache/camoufox/libnssckbi.so \ - && ln -s /usr/lib/x86_64-linux-gnu/pkcs11/p11-kit-trust.so /root/.cache/camoufox/libnssckbi.so + # Resolve both flat and versioned Camoufox cache layouts. + && CAMOUFOX_BINARY="$(find /root/.cache/camoufox -type f -name camoufox-bin)" \ + && test -x "$CAMOUFOX_BINARY" \ + && ln -s "$(dirname "$CAMOUFOX_BINARY")" "$(dirname "$APIFY_DEFAULT_BROWSER_PATH")" \ + # Load system certificates from the browser's own library directory. + && ln -sf "$(ls -d /usr/lib/*-linux-gnu)/pkcs11/p11-kit-trust.so" "$(dirname "$CAMOUFOX_BINARY")/libnssckbi.so" # Copy the dummy source code to the image COPY --chown=myuser:myuser . .