diff --git a/.puppeteerrc.cjs b/.puppeteerrc.cjs new file mode 100644 index 0000000..3cef53b --- /dev/null +++ b/.puppeteerrc.cjs @@ -0,0 +1,4 @@ +/** @type {import("puppeteer").Configuration} */ +module.exports = { + cacheDirectory: '/opt/puppeteer-cache', +}; diff --git a/Dockerfile b/Dockerfile index c2fa225..8adde97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,16 +4,32 @@ FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.22 ARG BUILD_DATE ARG VERSION -ARG SPEEDTEST_TRACKER_VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="thespad" ENV HOME=/config +# Copy local speedtest-tracker source instead of downloading from GitHub +COPY speedtest-tracker/ /app/www/ + +# Puppeteer config: use a cache dir outside /config volume so installed +# Chrome persists across container recreations. +COPY docker-speedtest-tracker/.puppeteerrc.cjs /config/.puppeteerrc.cjs +COPY docker-speedtest-tracker/.puppeteerrc.cjs /app/www/.puppeteerrc.cjs + +ENV PUPPETEER_CACHE_DIR=/opt/puppeteer-cache + RUN \ apk add --no-cache \ + chromium \ + nss \ + freetype \ + harfbuzz \ + ttf-freefont \ iputils \ grep \ + nodejs \ + npm \ php84-gd \ php84-intl \ php84-pdo_mysql \ @@ -24,8 +40,10 @@ RUN \ php84-xmlreader \ postgresql16-client \ ssmtp && \ - apk add --no-cache --virtual=build-dependencies \ - npm && \ + echo "*** install fast-cli ***" && \ + npm install -g fast-cli && \ + echo "*** install puppeteer chrome into persistent cache ***" && \ + npx puppeteer browsers install chrome && \ echo "*** install speedtest-cli ***" && \ if [ -z ${CLI_VERSION+x} ]; then \ CLI_VERSION=$(curl -Ls https://packagecloud.io/ookla/speedtest-cli/debian/dists/bookworm/main/binary-amd64/Packages \ @@ -42,18 +60,8 @@ RUN \ sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php84/php-fpm.d/www.conf && \ if ! grep -qxF 'clear_env = no' /etc/php84/php-fpm.d/www.conf; then echo 'clear_env = no' >> /etc/php84/php-fpm.d/www.conf; fi && \ echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php84/php-fpm.conf && \ + echo "env[PUPPETEER_CACHE_DIR] = /opt/puppeteer-cache" >> /etc/php84/php-fpm.conf && \ echo "*** install speedtest-tracker ***" && \ - if [ -z ${SPEEDTEST_TRACKER_VERSION+x} ]; then \ - SPEEDTEST_TRACKER_VERSION=$(curl -sX GET "https://api.github.com/repos/alexjustesen/speedtest-tracker/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - curl -o \ - /tmp/speedtest-tracker.tar.gz -L \ - "https://github.com/alexjustesen/speedtest-tracker/archive/${SPEEDTEST_TRACKER_VERSION}.tar.gz" && \ - mkdir -p /app/www && \ - tar xzf \ - /tmp/speedtest-tracker.tar.gz -C \ - /app/www/ --strip-components=1 && \ cd /app/www && \ composer install \ --no-interaction \ @@ -73,13 +81,11 @@ RUN \ } > /etc/php84/conf.d/php-misc.ini && \ printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \ echo "**** cleanup ****" && \ - apk del --purge build-dependencies && \ rm -rf \ - $HOME/.cache \ $HOME/.npm \ /app/www/node_modules \ /tmp/* -COPY root/ / +COPY docker-speedtest-tracker/root/ / VOLUME /config diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 1a55bfc..277e934 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -4,12 +4,14 @@ FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.22 ARG BUILD_DATE ARG VERSION -ARG SPEEDTEST_TRACKER_VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="thespad" ENV HOME=/config +# Copy local speedtest-tracker source instead of downloading from GitHub +COPY speedtest-tracker/ /app/www/ + RUN \ apk add --no-cache \ iputils \ @@ -43,17 +45,6 @@ RUN \ if ! grep -qxF 'clear_env = no' /etc/php84/php-fpm.d/www.conf; then echo 'clear_env = no' >> /etc/php84/php-fpm.d/www.conf; fi && \ echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php84/php-fpm.conf && \ echo "*** install speedtest-tracker ***" && \ - if [ -z ${SPEEDTEST_TRACKER_VERSION+x} ]; then \ - SPEEDTEST_TRACKER_VERSION=$(curl -sX GET "https://api.github.com/repos/alexjustesen/speedtest-tracker/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - curl -o \ - /tmp/speedtest-tracker.tar.gz -L \ - "https://github.com/alexjustesen/speedtest-tracker/archive/${SPEEDTEST_TRACKER_VERSION}.tar.gz" && \ - mkdir -p /app/www && \ - tar xzf \ - /tmp/speedtest-tracker.tar.gz -C \ - /app/www/ --strip-components=1 && \ cd /app/www && \ composer install \ --no-interaction \ @@ -80,6 +71,6 @@ RUN \ /app/www/node_modules \ /tmp/* -COPY root/ / +COPY docker-speedtest-tracker/root/ / VOLUME /config