Skip to content

Commit 1a74ee5

Browse files
committed
puppet
1 parent 731b8af commit 1a74ee5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.puppeteerrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/** @type {import("puppeteer").Configuration} */
2+
module.exports = {
3+
cacheDirectory: '/opt/puppeteer-cache',
4+
};

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ ENV HOME=/config
1212
# Copy local speedtest-tracker source instead of downloading from GitHub
1313
COPY speedtest-tracker/ /app/www/
1414

15-
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
16-
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
15+
# Puppeteer config: use a cache dir outside /config volume so installed
16+
# Chrome persists across container recreations.
17+
COPY docker-speedtest-tracker/.puppeteerrc.cjs /config/.puppeteerrc.cjs
18+
COPY docker-speedtest-tracker/.puppeteerrc.cjs /app/www/.puppeteerrc.cjs
19+
20+
ENV PUPPETEER_CACHE_DIR=/opt/puppeteer-cache
1721

1822
RUN \
1923
apk add --no-cache \
@@ -38,6 +42,8 @@ RUN \
3842
ssmtp && \
3943
echo "*** install fast-cli ***" && \
4044
npm install -g fast-cli && \
45+
echo "*** install puppeteer chrome into persistent cache ***" && \
46+
npx puppeteer browsers install chrome && \
4147
echo "*** install speedtest-cli ***" && \
4248
if [ -z ${CLI_VERSION+x} ]; then \
4349
CLI_VERSION=$(curl -Ls https://packagecloud.io/ookla/speedtest-cli/debian/dists/bookworm/main/binary-amd64/Packages \
@@ -54,7 +60,7 @@ RUN \
5460
sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php84/php-fpm.d/www.conf && \
5561
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 && \
5662
echo "env[PATH] = /usr/local/bin:/usr/bin:/bin" >> /etc/php84/php-fpm.conf && \
57-
echo "env[PUPPETEER_EXECUTABLE_PATH] = /usr/bin/chromium-browser" >> /etc/php84/php-fpm.conf && \
63+
echo "env[PUPPETEER_CACHE_DIR] = /opt/puppeteer-cache" >> /etc/php84/php-fpm.conf && \
5864
echo "*** install speedtest-tracker ***" && \
5965
cd /app/www && \
6066
composer install \

0 commit comments

Comments
 (0)