From 255cecef4736459041ddac1880e74ee8087b01d5 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Thu, 6 Jun 2024 20:06:13 -0400 Subject: [PATCH 1/8] cache filament components --- root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run index 98be876..7d6f7a0 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run @@ -92,8 +92,8 @@ if [[ -z ${APP_KEY} ]]; then fi # Build cache -s6-setuidgid abc php /app/www/artisan view:clear --no-ansi -q s6-setuidgid abc php /app/www/artisan optimize --no-ansi -q +s6-setuidgid abc php /app/www/artisan filament:cache-components --no-ansi -q # Migrate database s6-setuidgid abc php /app/www/artisan migrate --force --no-ansi -q From 2fb2a4dd0cc890d2ebc2d11b49786b7da5969e22 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Thu, 6 Jun 2024 20:07:44 -0400 Subject: [PATCH 2/8] warn and no longer generate an app key --- .../etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run index 7d6f7a0..92b3651 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run @@ -85,9 +85,8 @@ done # Check for app key if [[ -z ${APP_KEY} ]]; then if ! grep -E "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env > /dev/null; then - export APP_KEY=$(s6-setuidgid abc php /app/www/artisan key:generate --show) - echo "An application key was generated at start up, as no environment variable was set." - echo "To set an application key that persists, read the docs: https://docs.speedtest-tracker.dev/" + echo "An application key is missing!" + echo "Go to https://speedtest-tracker.dev/ generate an application key." fi fi From 4f3e90ef116a3dcae798cb5ff1378dad734028ca Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Fri, 7 Jun 2024 08:45:47 -0400 Subject: [PATCH 3/8] added app key to a required param and updated change log --- readme-vars.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme-vars.yml b/readme-vars.yml index 3db9c70..eca967b 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -20,6 +20,7 @@ common_param_env_vars_enabled: true param_container_name: "{{ project_name }}" param_usage_include_env: true param_env_vars: + - { env_var: "APP_KEY", env_value: "", desc: "App key used for encrypting stored data. Get a key at https://speedtest-tracker.dev" } - { env_var: "DB_CONNECTION", env_value: "sqlite", desc: "Set the database type to use. `sqlite`, `pgsql`, or `mysql`" } param_usage_include_vols: true param_volumes: @@ -30,7 +31,6 @@ param_ports: opt_param_usage_include_env: true opt_param_env_vars: - - { env_var: "APP_KEY", env_value: "", desc: "App key used for encrypting stored data. Generate with `docker exec speedtest-tracker php /app/www/artisan key:generate --show`" } - { env_var: "DB_HOST", env_value: "", desc: "Database hostname (postgres/mysql)." } - { env_var: "DB_PORT", env_value: "", desc: "Database port (postgres/mysql)." } - { env_var: "DB_DATABASE", env_value: "", desc: "Database name (postgres/mysql)." } @@ -44,6 +44,7 @@ app_setup_block: | # changelog changelogs: + - { date: "07.06.24:", desc: "Cache Filament components and added APP_KEY as a required param." } - { date: "27.05.24:", desc: "Existing users should update their nginx confs to avoid http2 deprecation warnings." } - { date: "24.05.24:", desc: "Rebase to Alpine 3.20." } - { date: "16.04.24:", desc: "Rebase to Alpine 3.19, upgrade to php 8.3." } From 052deae341556703bd06ab71d4263ec8973c5297 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Fri, 7 Jun 2024 09:02:13 -0400 Subject: [PATCH 4/8] better key wording --- readme-vars.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme-vars.yml b/readme-vars.yml index eca967b..25a743a 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -20,7 +20,7 @@ common_param_env_vars_enabled: true param_container_name: "{{ project_name }}" param_usage_include_env: true param_env_vars: - - { env_var: "APP_KEY", env_value: "", desc: "App key used for encrypting stored data. Get a key at https://speedtest-tracker.dev" } + - { env_var: "APP_KEY", env_value: "", desc: "App key used for encrypting stored data. You can generate a key at https://speedtest-tracker.dev" } - { env_var: "DB_CONNECTION", env_value: "sqlite", desc: "Set the database type to use. `sqlite`, `pgsql`, or `mysql`" } param_usage_include_vols: true param_volumes: From 9df787bf5aeb2f5af8e7011f6ef9454904609a70 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Fri, 7 Jun 2024 09:51:31 -0400 Subject: [PATCH 5/8] dont copy production env file, no longer exists --- .../s6-rc.d/init-speedtest-tracker-config/run | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run index 92b3651..18b7b1c 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run @@ -63,30 +63,28 @@ lsiown -R abc:abc \ /app/www/storage # Check for env file -if [[ ! -f /config/.env ]]; then - cp /app/www/.env.production /config/.env -fi - -# create symlinks -symlinks=( \ -/app/www/.env \ -) +if [[ -f /config/.env ]]; then + # create symlinks + symlinks=( \ + /app/www/.env \ + ) -for i in "${symlinks[@]}" -do - if [[ -e "$i" && ! -L "$i" ]]; then - rm -rf "$i" - fi - if [[ ! -L "$i" ]]; then - ln -s /config/"$(basename "$i")" "$i" - fi -done + for i in "${symlinks[@]}" + do + if [[ -e "$i" && ! -L "$i" ]]; then + rm -rf "$i" + fi + if [[ ! -L "$i" ]]; then + ln -s /config/"$(basename "$i")" "$i" + fi + done +fi # Check for app key if [[ -z ${APP_KEY} ]]; then - if ! grep -E "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env > /dev/null; then + if ! grep -qE "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env 2> /dev/null; then echo "An application key is missing!" - echo "Go to https://speedtest-tracker.dev/ generate an application key." + echo "You can generate a key at https://speedtest-tracker.dev/." fi fi From e22556d0ef160ddba21c7aa6deff4c146f25aa78 Mon Sep 17 00:00:00 2001 From: thespad Date: Fri, 7 Jun 2024 15:13:06 +0100 Subject: [PATCH 6/8] Sleep if no app_key set. Add dummy app_key to CI --- Jenkinsfile | 2 +- README.md | 7 ++++--- jenkins-vars.yml | 2 +- readme-vars.yml | 2 +- .../s6-overlay/s6-rc.d/init-speedtest-tracker-config/run | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 158fa04..2e59ca9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,7 +34,7 @@ pipeline { CI_PORT='80' CI_SSL='false' CI_DELAY='60' - CI_DOCKERENV='' + CI_DOCKERENV='APP_KEY=base64:w4fvYUSRozulci8bYVk9wCaRVge3PMF7ixo9fDz9T7o=' CI_AUTH='' CI_WEBPATH='' } diff --git a/README.md b/README.md index f8a78c3..01ab7e3 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,8 @@ services: - PUID=1000 - PGID=1000 - TZ=Etc/UTC + - APP_KEY= - DB_CONNECTION=sqlite - - APP_KEY= #optional - DB_HOST= #optional - DB_PORT= #optional - DB_DATABASE= #optional @@ -99,8 +99,8 @@ docker run -d \ -e PUID=1000 \ -e PGID=1000 \ -e TZ=Etc/UTC \ + -e APP_KEY= \ -e DB_CONNECTION=sqlite \ - -e APP_KEY= `#optional` \ -e DB_HOST= `#optional` \ -e DB_PORT= `#optional` \ -e DB_DATABASE= `#optional` \ @@ -122,8 +122,8 @@ Containers are configured using parameters passed at runtime (such as those abov | `-e PUID=1000` | for UserID - see below for explanation | | `-e PGID=1000` | for GroupID - see below for explanation | | `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). | +| `-e APP_KEY=` | App key used for encrypting stored data. You can generate a key at [https://speedtest-tracker.dev](https://speedtest-tracker.dev) | | `-e DB_CONNECTION=sqlite` | Set the database type to use. `sqlite`, `pgsql`, or `mysql` | -| `-e APP_KEY=` | App key used for encrypting stored data. Generate with `docker exec speedtest-tracker php /app/www/artisan key:generate --show` | | `-e DB_HOST=` | Database hostname (postgres/mysql). | | `-e DB_PORT=` | Database port (postgres/mysql). | | `-e DB_DATABASE=` | Database name (postgres/mysql). | @@ -292,6 +292,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **07.06.24:** - Cache Filament components and added APP_KEY as a required param. * **27.05.24:** - Existing users should update their nginx confs to avoid http2 deprecation warnings. * **24.05.24:** - Rebase to Alpine 3.20. * **16.04.24:** - Rebase to Alpine 3.19, upgrade to php 8.3. diff --git a/jenkins-vars.yml b/jenkins-vars.yml index cf27360..1f8801a 100644 --- a/jenkins-vars.yml +++ b/jenkins-vars.yml @@ -24,7 +24,7 @@ repo_vars: - CI_PORT='80' - CI_SSL='false' - CI_DELAY='60' - - CI_DOCKERENV='' + - CI_DOCKERENV='APP_KEY=base64:w4fvYUSRozulci8bYVk9wCaRVge3PMF7ixo9fDz9T7o=' - CI_AUTH='' - CI_WEBPATH='' sponsor_links: diff --git a/readme-vars.yml b/readme-vars.yml index 25a743a..b132f0e 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -20,7 +20,7 @@ common_param_env_vars_enabled: true param_container_name: "{{ project_name }}" param_usage_include_env: true param_env_vars: - - { env_var: "APP_KEY", env_value: "", desc: "App key used for encrypting stored data. You can generate a key at https://speedtest-tracker.dev" } + - { env_var: "APP_KEY", env_value: "", desc: "App key used for encrypting stored data. You can generate a key at [https://speedtest-tracker.dev](https://speedtest-tracker.dev)" } - { env_var: "DB_CONNECTION", env_value: "sqlite", desc: "Set the database type to use. `sqlite`, `pgsql`, or `mysql`" } param_usage_include_vols: true param_volumes: diff --git a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run index 18b7b1c..cccf9ea 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run @@ -83,8 +83,9 @@ fi # Check for app key if [[ -z ${APP_KEY} ]]; then if ! grep -qE "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env 2> /dev/null; then - echo "An application key is missing!" + echo "An application key is missing, halting init!" echo "You can generate a key at https://speedtest-tracker.dev/." + sleep infinity fi fi From 769db0ad8fab2391aac84c47ce488231fcaf9af7 Mon Sep 17 00:00:00 2001 From: thespad Date: Fri, 7 Jun 2024 15:58:47 +0100 Subject: [PATCH 7/8] Add new vars to readme --- README.md | 12 ++++++++++++ readme-vars.yml | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 01ab7e3..6d4789a 100644 --- a/README.md +++ b/README.md @@ -79,11 +79,15 @@ services: - TZ=Etc/UTC - APP_KEY= - DB_CONNECTION=sqlite + - SPEEDTEST_SCHEDULE= + - SPEEDTEST_SERVERS= - DB_HOST= #optional - DB_PORT= #optional - DB_DATABASE= #optional - DB_USERNAME= #optional - DB_PASSWORD= #optional + - DISPLAY_TIMEZONE=Etc/UTC #optional + - PRUNE_RESULTS_OLDER_THAN=0 #optional volumes: - /path/to/data:/config ports: @@ -101,11 +105,15 @@ docker run -d \ -e TZ=Etc/UTC \ -e APP_KEY= \ -e DB_CONNECTION=sqlite \ + -e SPEEDTEST_SCHEDULE= \ + -e SPEEDTEST_SERVERS= \ -e DB_HOST= `#optional` \ -e DB_PORT= `#optional` \ -e DB_DATABASE= `#optional` \ -e DB_USERNAME= `#optional` \ -e DB_PASSWORD= `#optional` \ + -e DISPLAY_TIMEZONE=Etc/UTC `#optional` \ + -e PRUNE_RESULTS_OLDER_THAN=0 `#optional` \ -p 80:80 \ -v /path/to/data:/config \ --restart unless-stopped \ @@ -124,11 +132,15 @@ Containers are configured using parameters passed at runtime (such as those abov | `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). | | `-e APP_KEY=` | App key used for encrypting stored data. You can generate a key at [https://speedtest-tracker.dev](https://speedtest-tracker.dev) | | `-e DB_CONNECTION=sqlite` | Set the database type to use. `sqlite`, `pgsql`, or `mysql` | +| `-e SPEEDTEST_SCHEDULE=` | Set the test schedule in cron format. e.g. `0 */6 * * *` | +| `-e SPEEDTEST_SERVERS=` | A comma-separated list of server IDs to test against. Run `docker exec speedtest-tracker php /app/www/artisan app:ookla-list-servers` to get a list of nearby servers. | | `-e DB_HOST=` | Database hostname (postgres/mysql). | | `-e DB_PORT=` | Database port (postgres/mysql). | | `-e DB_DATABASE=` | Database name (postgres/mysql). | | `-e DB_USERNAME=` | Database username (postgres/mysql). | | `-e DB_PASSWORD=` | Database password (postgres/mysql). | +| `-e DISPLAY_TIMEZONE=Etc/UTC` | Timezone for the UI. | +| `-e PRUNE_RESULTS_OLDER_THAN=0` | Days to keep test results. | | `-v /config` | Contains speedtest-tracker config and database, if using sqlite. | ## Environment variables from files (Docker secrets) diff --git a/readme-vars.yml b/readme-vars.yml index b132f0e..9771e69 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -22,6 +22,8 @@ param_usage_include_env: true param_env_vars: - { env_var: "APP_KEY", env_value: "", desc: "App key used for encrypting stored data. You can generate a key at [https://speedtest-tracker.dev](https://speedtest-tracker.dev)" } - { env_var: "DB_CONNECTION", env_value: "sqlite", desc: "Set the database type to use. `sqlite`, `pgsql`, or `mysql`" } + - { env_var: "SPEEDTEST_SCHEDULE", env_value: "", desc: "Set the test schedule in cron format. e.g. `0 */6 * * *`" } + - { env_var: "SPEEDTEST_SERVERS", env_value: "", desc: "A comma-separated list of server IDs to test against. Run `docker exec speedtest-tracker php /app/www/artisan app:ookla-list-servers` to get a list of nearby servers." } param_usage_include_vols: true param_volumes: - { vol_path: "/config", vol_host_path: "/path/to/data", desc: "Contains speedtest-tracker config and database, if using sqlite." } @@ -36,6 +38,8 @@ opt_param_env_vars: - { env_var: "DB_DATABASE", env_value: "", desc: "Database name (postgres/mysql)." } - { env_var: "DB_USERNAME", env_value: "", desc: "Database username (postgres/mysql)." } - { env_var: "DB_PASSWORD", env_value: "", desc: "Database password (postgres/mysql)." } + - { env_var: "DISPLAY_TIMEZONE", env_value: "Etc/UTC", desc: "Timezone for the UI." } + - { env_var: "PRUNE_RESULTS_OLDER_THAN", env_value: "0", desc: "Days to keep test results." } # application setup block app_setup_block_enabled: true From b5cd77634f723aa4b57cad0616bd2c6aa2f41167 Mon Sep 17 00:00:00 2001 From: thespad Date: Fri, 7 Jun 2024 16:00:29 +0100 Subject: [PATCH 8/8] Consistency tweaks --- readme-vars.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/readme-vars.yml b/readme-vars.yml index 9771e69..75a9089 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -5,16 +5,12 @@ project_url: "https://github.com/alexjustesen/speedtest-tracker" project_logo: "https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/speedtest-tracker-logo.png" project_blurb: "[{{ project_name|capitalize }}]({{ project_url }}) is a self-hosted internet performance tracking application that runs speedtest checks against Ookla's Speedtest service." project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}" -project_blurb_optional_extras_enabled: false # supported architectures available_architectures: - { arch: "{{ arch_x86_64 }}", tag: "amd64-latest"} - { arch: "{{ arch_arm64 }}", tag: "arm64v8-latest"} -# development version -development_versions: false - # container parameters common_param_env_vars_enabled: true param_container_name: "{{ project_name }}" @@ -26,7 +22,7 @@ param_env_vars: - { env_var: "SPEEDTEST_SERVERS", env_value: "", desc: "A comma-separated list of server IDs to test against. Run `docker exec speedtest-tracker php /app/www/artisan app:ookla-list-servers` to get a list of nearby servers." } param_usage_include_vols: true param_volumes: - - { vol_path: "/config", vol_host_path: "/path/to/data", desc: "Contains speedtest-tracker config and database, if using sqlite." } + - { vol_path: "/config", vol_host_path: "/path/to/{{ project_name }}/data", desc: "Contains speedtest-tracker config and database, if using sqlite." } param_usage_include_ports: true param_ports: - { external_port: "80", internal_port: "80", port_desc: "Web UI" }