From 35a72132d81b423c6fbf2f0e8e41f555bf9bbc56 Mon Sep 17 00:00:00 2001 From: Henry Whitaker Date: Sun, 25 Jun 2023 04:55:47 +0100 Subject: [PATCH] updated to run on php8 --- Taskfile.yaml | 15 ++++++ docker/Dockerfile | 4 +- .../site-confs/default.conf.sample} | 0 docker/conf/etc/cont-init.d/50-speedtest | 48 ++++++++++++------- .../etc/{php7 => php82}/php-fpm.d/www.conf | 0 docker/conf/etc/services.d/speedtest/run | 2 +- 6 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 Taskfile.yaml rename docker/conf/defaults/{default => nginx/site-confs/default.conf.sample} (100%) rename docker/conf/etc/{php7 => php82}/php-fpm.d/www.conf (100%) diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 00000000..6c9f69de --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,15 @@ +version: "3" + +vars: + RTAG: + sh: head -n 25 /dev/random | md5sum | head -c 8 + +tasks: + build: + cmds: + - docker build . -f docker/Dockerfile --tag henrywhitaker3/speedtest-tracker:{{ .RTAG }} + + run: + deps: [build] + cmds: + - docker run --rm -p 8765:80 -e OOKLA_EULA_GDPR=true henrywhitaker3/speedtest-tracker:{{ .RTAG }} diff --git a/docker/Dockerfile b/docker/Dockerfile index b31de422..3c5e4634 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,11 +3,11 @@ LABEL maintainer=henrywhitaker3@outlook.com ENV arch='x86_64' +RUN apk add php82-tokenizer + COPY docker/conf/ / COPY . /site -RUN cd /site composer install - EXPOSE 80 443 VOLUME ["/config"] diff --git a/docker/conf/defaults/default b/docker/conf/defaults/nginx/site-confs/default.conf.sample similarity index 100% rename from docker/conf/defaults/default rename to docker/conf/defaults/nginx/site-confs/default.conf.sample diff --git a/docker/conf/etc/cont-init.d/50-speedtest b/docker/conf/etc/cont-init.d/50-speedtest index ae185219..9d42f252 100644 --- a/docker/conf/etc/cont-init.d/50-speedtest +++ b/docker/conf/etc/cont-init.d/50-speedtest @@ -11,6 +11,18 @@ function eulaError() exit 1 } +function downloadSpeedtestCli() +{ + if [ $(uname -m) == "x86_64" ]; then + wget https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-x86_64.tgz -O speedtest.tgz > /dev/null + else + wget https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-arm.tgz -O speedtest.tgz > /dev/null + fi + + tar zxvf speedtest.tgz > /dev/null + cp speedtest /site/app/Bin/ +} + # Do Ookla stuff if [ -z ${OOKLA_EULA_GDPR+x} ]; then eulaError @@ -23,19 +35,19 @@ else echo "Ookla GDPR and EULA accepted. Downloading Speedtest CLI." cd /tmp - if [ $(uname -m) == "x86_64" ]; then - wget https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-x86_64-linux.tgz -O speedtest.tgz > /dev/null - else - wget https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-arm-linux.tgz -O speedtest.tgz > /dev/null - fi - - tar zxvf speedtest.tgz > /dev/null - cp speedtest /site/app/Bin/ + downloadSpeedtestCli chmod +x /site/artisan HOME=/config && s6-setuidgid abc /site/app/Bin/speedtest --accept-license --accept-gdpr > /dev/null HOME=/root else + /config/www/app/Bin/speedtest --version | grep -E "1\.2\.0" + rc=$? + + if [ $rc -ne 0 ]; then + downloadSpeedtestCli + fi + HOME=/config && s6-setuidgid abc /site/app/Bin/speedtest --accept-license --accept-gdpr > /dev/null HOME=/root fi @@ -69,19 +81,19 @@ fi echo 'Updating packages' apk add composer -cd /config/www && composer install && echo date > /config/www/.composer-time +cd /config/www && php82 /usr/bin/composer.phar install && echo date > /config/www/.composer-time sed "s,DB_DATABASE=.*,DB_DATABASE=/config/speed.db," -i.bak /config/www/.env echo "Running database migrations" -php /config/www/artisan migrate +php82 /config/www/artisan migrate # Check app key exists if grep -E "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /config/www/.env > /dev/null; then echo "App key exists" else echo "Generating app key" - php /config/www/artisan key:generate + php82 /config/www/artisan key:generate fi # Check JWT secret exists @@ -89,7 +101,7 @@ if grep -E "JWT_SECRET=[0-9A-Za-z:+\/=]{1,}" /config/www/.env > /dev/null ; then echo "JWT secret exists" else echo "Generating JWT secret" - php /config/www/artisan jwt:secret + php82 /config/www/artisan jwt:secret fi if [ -z ${SLACK_WEBHOOK+x} ]; then @@ -98,7 +110,7 @@ if [ -z ${SLACK_WEBHOOK+x} ]; then else echo "Slack webhook set, updating db" sed "s,SLACK_WEBHOOK=.*,SLACK_WEBHOOK=$SLACK_WEBHOOK," -i.bak /config/www/.env - php /config/www/artisan speedtest:slack $SLACK_WEBHOOK + php82 /config/www/artisan speedtest:slack $SLACK_WEBHOOK fi if [ -z ${TELEGRAM_BOT_TOKEN+x} ] && [ -z ${TELEGRAM_CHAT_ID+x} ]; then @@ -109,7 +121,7 @@ else echo "Telegram chat id and bot token set, updating .env" sed "s,TELEGRAM_BOT_TOKEN=.*,TELEGRAM_BOT_TOKEN=$TELEGRAM_BOT_TOKEN," -i.bak /config/www/.env sed "s,TELEGRAM_CHAT_ID=.*,TELEGRAM_CHAT_ID=$TELEGRAM_CHAT_ID," -i.bak /config/www/.env - php /config/www/artisan speedtest:telegram --chat=$TELEGRAM_CHAT_ID --bot=$TELEGRAM_BOT_TOKEN + php82 /config/www/artisan speedtest:telegram --chat=$TELEGRAM_CHAT_ID --bot=$TELEGRAM_BOT_TOKEN fi if [ -z ${BASE_PATH+x} ]; then @@ -122,19 +134,19 @@ fi if [ -z ${AUTH+x} ]; then echo "AUTH variable not set. Disabling authentication" - php /config/www/artisan speedtest:auth --disable + php82 /config/www/artisan speedtest:auth --disable else if [ $AUTH == 'true' ]; then echo "AUTH variable set. Enabling authentication" - php /config/www/artisan speedtest:auth --enable + php82 /config/www/artisan speedtest:auth --enable else echo "AUTH variable set, but not to 'true'. Disabling authentication" - php /config/www/artisan speedtest:auth --disable + php82 /config/www/artisan speedtest:auth --disable fi fi echo "Clearing old jobs from queue" -php /config/www/artisan queue:clear +php82 /config/www/artisan queue:clear mkdir -p /config/log/speedtest diff --git a/docker/conf/etc/php7/php-fpm.d/www.conf b/docker/conf/etc/php82/php-fpm.d/www.conf similarity index 100% rename from docker/conf/etc/php7/php-fpm.d/www.conf rename to docker/conf/etc/php82/php-fpm.d/www.conf diff --git a/docker/conf/etc/services.d/speedtest/run b/docker/conf/etc/services.d/speedtest/run index ac1c8c5e..e64c9cc0 100644 --- a/docker/conf/etc/services.d/speedtest/run +++ b/docker/conf/etc/services.d/speedtest/run @@ -1,3 +1,3 @@ #!/usr/bin/with-contenv bash -exec s6-setuidgid abc php /config/www/artisan queue:work --timeout=120 >> /config/log/speedtest/queue.log \ No newline at end of file +exec s6-setuidgid abc php82 /config/www/artisan queue:work --timeout=120 >> /config/log/speedtest/queue.log