From 09f24855944ed9c05d0fea2a30df173d1bf9f880 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Thu, 14 Oct 2021 16:03:46 -0500 Subject: [PATCH 1/3] Use standard nginx.conf from lsio alpine nginx base image --- Dockerfile | 53 +++++++------ Dockerfile.aarch64 | 53 +++++++------ Dockerfile.armhf | 53 +++++++------ README.md | 1 + readme-vars.yml | 1 + root/defaults/default | 31 -------- root/defaults/{ => www}/index.html | 0 root/etc/cont-init.d/50-config | 80 ++++++++++---------- root/usr/share/webapps/librespeed/index.html | 40 ++++++++++ 9 files changed, 161 insertions(+), 151 deletions(-) delete mode 100644 root/defaults/default rename root/defaults/{ => www}/index.html (100%) create mode 100644 root/usr/share/webapps/librespeed/index.html diff --git a/Dockerfile b/Dockerfile index 000f1da..f72d5f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.13 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.15 # set version label ARG BUILD_DATE @@ -8,34 +8,33 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="aptalca" RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ - curl \ - php7-ctype \ - php7-gd \ - php7-mysqli \ - php7-pdo_pgsql \ - php7-pdo_sqlite && \ - echo "**** install librespeed ****" && \ - if [ -z ${LIBRESPEED_RELEASE+x} ]; then \ - LIBRESPEED_RELEASE=$(curl -sX GET "https://api.github.com/repos/librespeed/speedtest/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - mkdir -p \ - /usr/share/webapps/librespeed && \ - curl -o \ - /tmp/librespeed.tar.gz -L \ - "https://github.com/librespeed/speedtest/archive/${LIBRESPEED_RELEASE}.tar.gz" && \ - tar xf \ - /tmp/librespeed.tar.gz -C \ - /usr/share/webapps/librespeed --strip-components=1 && \ - echo "**** cleanup ****" && \ - rm -rf \ - /tmp/* + echo "**** install packages ****" && \ + apk add --no-cache \ + curl \ + php8-ctype \ + php8-gd \ + php8-mysqli \ + php8-pdo_pgsql \ + php8-pdo_sqlite && \ + echo "**** install librespeed ****" && \ + if [ -z ${LIBRESPEED_RELEASE+x} ]; then \ + LIBRESPEED_RELEASE=$(curl -sX GET "https://api.github.com/repos/librespeed/speedtest/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + fi && \ + mkdir -p \ + /app/www/public && \ + curl -o \ + /tmp/librespeed.tar.gz -L \ + "https://github.com/librespeed/speedtest/archive/${LIBRESPEED_RELEASE}.tar.gz" && \ + tar xf \ + /tmp/librespeed.tar.gz -C \ + /app/www/public --strip-components=1 && \ + echo "**** cleanup ****" && \ + rm -rf \ + /tmp/* # add local files COPY root/ / # ports and volumes -EXPOSE 80 -VOLUME /config +EXPOSE 80 443 diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 2137cec..86b817c 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.13 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.15 # set version label ARG BUILD_DATE @@ -8,34 +8,33 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="aptalca" RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ - curl \ - php7-ctype \ - php7-gd \ - php7-mysqli \ - php7-pdo_pgsql \ - php7-pdo_sqlite && \ - echo "**** install librespeed ****" && \ - if [ -z ${LIBRESPEED_RELEASE+x} ]; then \ - LIBRESPEED_RELEASE=$(curl -sX GET "https://api.github.com/repos/librespeed/speedtest/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - mkdir -p \ - /usr/share/webapps/librespeed && \ - curl -o \ - /tmp/librespeed.tar.gz -L \ - "https://github.com/librespeed/speedtest/archive/${LIBRESPEED_RELEASE}.tar.gz" && \ - tar xf \ - /tmp/librespeed.tar.gz -C \ - /usr/share/webapps/librespeed --strip-components=1 && \ - echo "**** cleanup ****" && \ - rm -rf \ - /tmp/* + echo "**** install packages ****" && \ + apk add --no-cache \ + curl \ + php8-ctype \ + php8-gd \ + php8-mysqli \ + php8-pdo_pgsql \ + php8-pdo_sqlite && \ + echo "**** install librespeed ****" && \ + if [ -z ${LIBRESPEED_RELEASE+x} ]; then \ + LIBRESPEED_RELEASE=$(curl -sX GET "https://api.github.com/repos/librespeed/speedtest/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + fi && \ + mkdir -p \ + /app/www/public && \ + curl -o \ + /tmp/librespeed.tar.gz -L \ + "https://github.com/librespeed/speedtest/archive/${LIBRESPEED_RELEASE}.tar.gz" && \ + tar xf \ + /tmp/librespeed.tar.gz -C \ + /app/www/public --strip-components=1 && \ + echo "**** cleanup ****" && \ + rm -rf \ + /tmp/* # add local files COPY root/ / # ports and volumes -EXPOSE 80 -VOLUME /config +EXPOSE 80 443 diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 8d4b99e..e956912 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -1,4 +1,4 @@ -FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.13 +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.15 # set version label ARG BUILD_DATE @@ -8,34 +8,33 @@ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DA LABEL maintainer="aptalca" RUN \ - echo "**** install packages ****" && \ - apk add --no-cache \ - curl \ - php7-ctype \ - php7-gd \ - php7-mysqli \ - php7-pdo_pgsql \ - php7-pdo_sqlite && \ - echo "**** install librespeed ****" && \ - if [ -z ${LIBRESPEED_RELEASE+x} ]; then \ - LIBRESPEED_RELEASE=$(curl -sX GET "https://api.github.com/repos/librespeed/speedtest/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - mkdir -p \ - /usr/share/webapps/librespeed && \ - curl -o \ - /tmp/librespeed.tar.gz -L \ - "https://github.com/librespeed/speedtest/archive/${LIBRESPEED_RELEASE}.tar.gz" && \ - tar xf \ - /tmp/librespeed.tar.gz -C \ - /usr/share/webapps/librespeed --strip-components=1 && \ - echo "**** cleanup ****" && \ - rm -rf \ - /tmp/* + echo "**** install packages ****" && \ + apk add --no-cache \ + curl \ + php8-ctype \ + php8-gd \ + php8-mysqli \ + php8-pdo_pgsql \ + php8-pdo_sqlite && \ + echo "**** install librespeed ****" && \ + if [ -z ${LIBRESPEED_RELEASE+x} ]; then \ + LIBRESPEED_RELEASE=$(curl -sX GET "https://api.github.com/repos/librespeed/speedtest/releases/latest" \ + | awk '/tag_name/{print $4;exit}' FS='[""]'); \ + fi && \ + mkdir -p \ + /app/www/public && \ + curl -o \ + /tmp/librespeed.tar.gz -L \ + "https://github.com/librespeed/speedtest/archive/${LIBRESPEED_RELEASE}.tar.gz" && \ + tar xf \ + /tmp/librespeed.tar.gz -C \ + /app/www/public --strip-components=1 && \ + echo "**** cleanup ****" && \ + rm -rf \ + /tmp/* # add local files COPY root/ / # ports and volumes -EXPOSE 80 -VOLUME /config +EXPOSE 80 443 diff --git a/README.md b/README.md index eb02ba8..09a53c3 100644 --- a/README.md +++ b/README.md @@ -254,6 +254,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **20.08.22:** - Rebasing to alpine 3.15 with php8. Restructure nginx configs ([see changes announcement](https://info.linuxserver.io/issues/2022-08-20-nginx-base)). * **01.03.21:** - Fix up database settings. Make sure `index.html` is recreated. * **28.02.21:** - Added php7-ctype. * **23.01.21:** - Rebasing to alpine 3.13. diff --git a/readme-vars.yml b/readme-vars.yml index 910cbc9..d25e504 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -63,6 +63,7 @@ app_setup_block: | # changelog changelogs: + - { date: "20.08.22:", desc: "Rebasing to alpine 3.15 with php8. Restructure nginx configs ([see changes announcement](https://info.linuxserver.io/issues/2022-08-20-nginx-base))." } - { date: "01.03.21:", desc: "Fix up database settings. Make sure `index.html` is recreated." } - { date: "28.02.21:", desc: "Added php7-ctype." } - { date: "23.01.21:", desc: "Rebasing to alpine 3.13." } diff --git a/root/defaults/default b/root/defaults/default deleted file mode 100644 index cba78df..0000000 --- a/root/defaults/default +++ /dev/null @@ -1,31 +0,0 @@ -## Version 2020/01/06 - Changelog: https://github.com/linuxserver/docker-librespeed/commits/master/root/defaults/default - -server { - listen 80 default_server; - - listen 443 ssl; - - root /usr/share/webapps/librespeed; - index index.php index.html index.htm; - - real_ip_header X-Forwarded-For; - set_real_ip_from 172.17.0.0/16; - - server_name _; - - ssl_certificate /config/keys/cert.crt; - ssl_certificate_key /config/keys/cert.key; - - client_max_body_size 0; - - location / { - try_files $uri $uri/ /index.html; - } - - location ~ \.php$ { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass 127.0.0.1:9000; - fastcgi_index index.php; - include /etc/nginx/fastcgi_params; - } -} diff --git a/root/defaults/index.html b/root/defaults/www/index.html similarity index 100% rename from root/defaults/index.html rename to root/defaults/www/index.html diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 5191605..615d10d 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -2,63 +2,65 @@ # make our folders mkdir -p \ - /config/www \ - /config/www/img + /config/www \ + /config/www/img # create symlink to index.html -[[ ! -L /usr/share/webapps/librespeed/index.html ]] && \ - ln -s /config/www/index.html /usr/share/webapps/librespeed/index.html -[[ ! -f /config/www/index.html ]] && \ - cp /defaults/index.html /config/www/index.html +if [[ ! -L /app/www/public/index.html ]]; then + ln -s /config/www/index.html /app/www/public/index.html +fi # update templates -cp /usr/share/webapps/librespeed/example*.html /config/www/ +cp /app/www/public/example*.html /config/www/ # use custom js files if exist -[[ -f /config/www/speedtest.js ]] && \ - cp /config/www/speedtest.js /usr/share/webapps/librespeed/speedtest.js -[[ -f /config/www/speedtest_worker.js ]] && \ - cp /config/www/speedtest_worker.js /usr/share/webapps/librespeed/speedtest_worker.js +if [[ -f /config/www/speedtest.js ]]; then + cp /config/www/speedtest.js /app/www/public/speedtest.js +fi +if [[ -f /config/www/speedtest_worker.js ]]; then + cp /config/www/speedtest_worker.js /app/www/public/speedtest_worker.js +fi # enables custom results page if [ "$CUSTOM_RESULTS" == "true" ]; then - echo "custom results" - [[ ! -e "/config/www/results/index.php" ]] && \ - mkdir -p /config/www/results/ && \ - mv /usr/share/webapps/librespeed/results/index.php /config/www/results/index.php - ln -sf /config/www/results/index.php /usr/share/webapps/librespeed/results/index.php + echo "custom results" + if [[ ! -e "/config/www/results/index.php" ]]; then + mkdir -p /config/www/results/ + mv /app/www/public/results/index.php /config/www/results/index.php + fi + ln -sf /config/www/results/index.php /app/www/public/results/index.php fi # configure app settings sed -i "\ - s|\$Sqlite_db_file.*|\$Sqlite_db_file = \'/config/speedtest_telemetry.sql\';|g; \ - s|\$enable_id_obfuscation.*|\$enable_id_obfuscation = true;|g; - s|\$stats_password.*|\$stats_password = \'${PASSWORD}\';|g" \ - /usr/share/webapps/librespeed/results/telemetry_settings.php + s|\$Sqlite_db_file.*|\$Sqlite_db_file = \'/config/speedtest_telemetry.sql\';|g; \ + s|\$enable_id_obfuscation.*|\$enable_id_obfuscation = true;|g; + s|\$stats_password.*|\$stats_password = \'${PASSWORD}\';|g" \ + /app/www/public/results/telemetry_settings.php if [ "$DB_TYPE" = "postgresql" ]; then - sed -i "\ - s|\$db_type.*|\$db_type = \'${DB_TYPE}\';|g; \ - s|\$PostgreSql_username.*|\$PostgreSql_username = \'${DB_USERNAME}\';|g; \ - s|\$PostgreSql_password.*|\$PostgreSql_password = \'${DB_PASSWORD}\';|g; \ - s|\$PostgreSql_hostname.*|\$PostgreSql_hostname = \'${DB_HOSTNAME}\';|g; \ - s|\$PostgreSql_databasename.*|\$PostgreSql_databasename = \'${DB_NAME}\';|g" \ - /usr/share/webapps/librespeed/results/telemetry_settings.php + sed -i "\ + s|\$db_type.*|\$db_type = \'${DB_TYPE}\';|g; \ + s|\$PostgreSql_username.*|\$PostgreSql_username = \'${DB_USERNAME}\';|g; \ + s|\$PostgreSql_password.*|\$PostgreSql_password = \'${DB_PASSWORD}\';|g; \ + s|\$PostgreSql_hostname.*|\$PostgreSql_hostname = \'${DB_HOSTNAME}\';|g; \ + s|\$PostgreSql_databasename.*|\$PostgreSql_databasename = \'${DB_NAME}\';|g" \ + /app/www/public/results/telemetry_settings.php elif [ "$DB_TYPE" = "mysql" ]; then - sed -i "\ - s|\$MySql_username.*|\$MySql_username = \'${DB_USERNAME}\';|g; \ - s|\$MySql_password.*|\$MySql_password = \'${DB_PASSWORD}\';|g; \ - s|\$MySql_hostname.*|\$MySql_hostname = \'${DB_HOSTNAME}\';|g; \ - s|\$MySql_databasename.*|\$MySql_databasename = \'${DB_NAME}\';|g; \ - s|\$MySql_port.*|\$MySql_port = \'${DB_PORT:-3306}\';|g" \ - /usr/share/webapps/librespeed/results/telemetry_settings.php + sed -i "\ + s|\$MySql_username.*|\$MySql_username = \'${DB_USERNAME}\';|g; \ + s|\$MySql_password.*|\$MySql_password = \'${DB_PASSWORD}\';|g; \ + s|\$MySql_hostname.*|\$MySql_hostname = \'${DB_HOSTNAME}\';|g; \ + s|\$MySql_databasename.*|\$MySql_databasename = \'${DB_NAME}\';|g; \ + s|\$MySql_port.*|\$MySql_port = \'${DB_PORT:-3306}\';|g" \ + /app/www/public/results/telemetry_settings.php else - sed -i \ - "s|\$db_type.*|\$db_type = \'sqlite\';|g" \ - /usr/share/webapps/librespeed/results/telemetry_settings.php + sed -i \ + "s|\$db_type.*|\$db_type = \'sqlite\';|g" \ + /app/www/public/results/telemetry_settings.php fi # permissions echo "Setting permissions" chown -R abc:abc \ - /usr/share/webapps/librespeed \ - /config + /app/www/public \ + /config diff --git a/root/usr/share/webapps/librespeed/index.html b/root/usr/share/webapps/librespeed/index.html new file mode 100644 index 0000000..2ac31be --- /dev/null +++ b/root/usr/share/webapps/librespeed/index.html @@ -0,0 +1,40 @@ + + + Upgrade Required! + + + +
+

Upgrade Required!

+

The application inside this image has been moved to a new folder.

+

You will need to update your /config/nginx/nginx.conf and /config/nginx/site-confs/default.conf in order for the application to work.

+

New config samples are located at /config/nginx/nginx.conf.sample and /config/nginx/site-confs/default.conf.sample

+

Please review our announcement: Significant changes to nginx based images

+
+ + From 4692da69257802bffabca4622e6b49c6122fe266 Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sat, 20 Aug 2022 18:54:37 -0500 Subject: [PATCH 2/3] Add default location migration --- root/migrations/02-default-location | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 root/migrations/02-default-location diff --git a/root/migrations/02-default-location b/root/migrations/02-default-location new file mode 100644 index 0000000..82a026d --- /dev/null +++ b/root/migrations/02-default-location @@ -0,0 +1,10 @@ +#!/usr/bin/with-contenv bash + +DEFAULT_CONF="/config/nginx/site-confs/default.conf" +OLD_ROOT="root /usr/share/webapps/librespeed;" +NEW_ROOT="root /app/www/public;" + +if grep -q "${OLD_ROOT}" "${DEFAULT_CONF}";then + echo "updating root in ${DEFAULT_CONF}" + sed -i "s|${OLD_ROOT}|${NEW_ROOT}|" "${DEFAULT_CONF}" +fi From bb570b004c7f9d26ed27170da380c36c47e60dcd Mon Sep 17 00:00:00 2001 From: Eric Nemchik Date: Sun, 21 Aug 2022 16:54:10 -0500 Subject: [PATCH 3/3] Keep /config volume consistently --- Dockerfile | 1 + Dockerfile.aarch64 | 1 + Dockerfile.armhf | 1 + 3 files changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index f72d5f4..5a18762 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,3 +38,4 @@ COPY root/ / # ports and volumes EXPOSE 80 443 +VOLUME /config diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 86b817c..ec8bd01 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -38,3 +38,4 @@ COPY root/ / # ports and volumes EXPOSE 80 443 +VOLUME /config diff --git a/Dockerfile.armhf b/Dockerfile.armhf index e956912..0ab8bab 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -38,3 +38,4 @@ COPY root/ / # ports and volumes EXPOSE 80 443 +VOLUME /config