Skip to content

Commit 7b98df7

Browse files
authored
Merge pull request #19 from alexjustesen/main
Improve performance by caching Filament components and warn if APP_KEY is missing
2 parents 9fad838 + b5cd776 commit 7b98df7

File tree

5 files changed

+45
-33
lines changed

5 files changed

+45
-33
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pipeline {
3434
CI_PORT='80'
3535
CI_SSL='false'
3636
CI_DELAY='60'
37-
CI_DOCKERENV=''
37+
CI_DOCKERENV='APP_KEY=base64:w4fvYUSRozulci8bYVk9wCaRVge3PMF7ixo9fDz9T7o='
3838
CI_AUTH=''
3939
CI_WEBPATH=''
4040
}

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@ services:
7777
- PUID=1000
7878
- PGID=1000
7979
- TZ=Etc/UTC
80+
- APP_KEY=
8081
- DB_CONNECTION=sqlite
81-
- APP_KEY= #optional
82+
- SPEEDTEST_SCHEDULE=
83+
- SPEEDTEST_SERVERS=
8284
- DB_HOST= #optional
8385
- DB_PORT= #optional
8486
- DB_DATABASE= #optional
8587
- DB_USERNAME= #optional
8688
- DB_PASSWORD= #optional
89+
- DISPLAY_TIMEZONE=Etc/UTC #optional
90+
- PRUNE_RESULTS_OLDER_THAN=0 #optional
8791
volumes:
8892
- /path/to/data:/config
8993
ports:
@@ -99,13 +103,17 @@ docker run -d \
99103
-e PUID=1000 \
100104
-e PGID=1000 \
101105
-e TZ=Etc/UTC \
106+
-e APP_KEY= \
102107
-e DB_CONNECTION=sqlite \
103-
-e APP_KEY= `#optional` \
108+
-e SPEEDTEST_SCHEDULE= \
109+
-e SPEEDTEST_SERVERS= \
104110
-e DB_HOST= `#optional` \
105111
-e DB_PORT= `#optional` \
106112
-e DB_DATABASE= `#optional` \
107113
-e DB_USERNAME= `#optional` \
108114
-e DB_PASSWORD= `#optional` \
115+
-e DISPLAY_TIMEZONE=Etc/UTC `#optional` \
116+
-e PRUNE_RESULTS_OLDER_THAN=0 `#optional` \
109117
-p 80:80 \
110118
-v /path/to/data:/config \
111119
--restart unless-stopped \
@@ -122,13 +130,17 @@ Containers are configured using parameters passed at runtime (such as those abov
122130
| `-e PUID=1000` | for UserID - see below for explanation |
123131
| `-e PGID=1000` | for GroupID - see below for explanation |
124132
| `-e TZ=Etc/UTC` | specify a timezone to use, see this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List). |
133+
| `-e APP_KEY=` | App key used for encrypting stored data. You can generate a key at [https://speedtest-tracker.dev](https://speedtest-tracker.dev) |
125134
| `-e DB_CONNECTION=sqlite` | Set the database type to use. `sqlite`, `pgsql`, or `mysql` |
126-
| `-e APP_KEY=` | App key used for encrypting stored data. Generate with `docker exec speedtest-tracker php /app/www/artisan key:generate --show` |
135+
| `-e SPEEDTEST_SCHEDULE=` | Set the test schedule in cron format. e.g. `0 */6 * * *` |
136+
| `-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. |
127137
| `-e DB_HOST=` | Database hostname (postgres/mysql). |
128138
| `-e DB_PORT=` | Database port (postgres/mysql). |
129139
| `-e DB_DATABASE=` | Database name (postgres/mysql). |
130140
| `-e DB_USERNAME=` | Database username (postgres/mysql). |
131141
| `-e DB_PASSWORD=` | Database password (postgres/mysql). |
142+
| `-e DISPLAY_TIMEZONE=Etc/UTC` | Timezone for the UI. |
143+
| `-e PRUNE_RESULTS_OLDER_THAN=0` | Days to keep test results. |
132144
| `-v /config` | Contains speedtest-tracker config and database, if using sqlite. |
133145

134146
## Environment variables from files (Docker secrets)
@@ -292,6 +304,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
292304

293305
## Versions
294306

307+
* **07.06.24:** - Cache Filament components and added APP_KEY as a required param.
295308
* **27.05.24:** - Existing users should update their nginx confs to avoid http2 deprecation warnings.
296309
* **24.05.24:** - Rebase to Alpine 3.20.
297310
* **16.04.24:** - Rebase to Alpine 3.19, upgrade to php 8.3.

jenkins-vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repo_vars:
2424
- CI_PORT='80'
2525
- CI_SSL='false'
2626
- CI_DELAY='60'
27-
- CI_DOCKERENV=''
27+
- CI_DOCKERENV='APP_KEY=base64:w4fvYUSRozulci8bYVk9wCaRVge3PMF7ixo9fDz9T7o='
2828
- CI_AUTH=''
2929
- CI_WEBPATH=''
3030
sponsor_links:

readme-vars.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,37 @@ project_url: "https://github.com/alexjustesen/speedtest-tracker"
55
project_logo: "https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/speedtest-tracker-logo.png"
66
project_blurb: "[{{ project_name|capitalize }}]({{ project_url }}) is a self-hosted internet performance tracking application that runs speedtest checks against Ookla's Speedtest service."
77
project_lsio_github_repo_url: "https://github.com/linuxserver/docker-{{ project_name }}"
8-
project_blurb_optional_extras_enabled: false
98

109
# supported architectures
1110
available_architectures:
1211
- { arch: "{{ arch_x86_64 }}", tag: "amd64-latest"}
1312
- { arch: "{{ arch_arm64 }}", tag: "arm64v8-latest"}
1413

15-
# development version
16-
development_versions: false
17-
1814
# container parameters
1915
common_param_env_vars_enabled: true
2016
param_container_name: "{{ project_name }}"
2117
param_usage_include_env: true
2218
param_env_vars:
19+
- { 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)" }
2320
- { env_var: "DB_CONNECTION", env_value: "sqlite", desc: "Set the database type to use. `sqlite`, `pgsql`, or `mysql`" }
21+
- { env_var: "SPEEDTEST_SCHEDULE", env_value: "", desc: "Set the test schedule in cron format. e.g. `0 */6 * * *`" }
22+
- { 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." }
2423
param_usage_include_vols: true
2524
param_volumes:
26-
- { vol_path: "/config", vol_host_path: "/path/to/data", desc: "Contains speedtest-tracker config and database, if using sqlite." }
25+
- { vol_path: "/config", vol_host_path: "/path/to/{{ project_name }}/data", desc: "Contains speedtest-tracker config and database, if using sqlite." }
2726
param_usage_include_ports: true
2827
param_ports:
2928
- { external_port: "80", internal_port: "80", port_desc: "Web UI" }
3029

3130
opt_param_usage_include_env: true
3231
opt_param_env_vars:
33-
- { 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`" }
3432
- { env_var: "DB_HOST", env_value: "", desc: "Database hostname (postgres/mysql)." }
3533
- { env_var: "DB_PORT", env_value: "", desc: "Database port (postgres/mysql)." }
3634
- { env_var: "DB_DATABASE", env_value: "", desc: "Database name (postgres/mysql)." }
3735
- { env_var: "DB_USERNAME", env_value: "", desc: "Database username (postgres/mysql)." }
3836
- { env_var: "DB_PASSWORD", env_value: "", desc: "Database password (postgres/mysql)." }
37+
- { env_var: "DISPLAY_TIMEZONE", env_value: "Etc/UTC", desc: "Timezone for the UI." }
38+
- { env_var: "PRUNE_RESULTS_OLDER_THAN", env_value: "0", desc: "Days to keep test results." }
3939

4040
# application setup block
4141
app_setup_block_enabled: true
@@ -44,6 +44,7 @@ app_setup_block: |
4444
4545
# changelog
4646
changelogs:
47+
- { date: "07.06.24:", desc: "Cache Filament components and added APP_KEY as a required param." }
4748
- { date: "27.05.24:", desc: "Existing users should update their nginx confs to avoid http2 deprecation warnings." }
4849
- { date: "24.05.24:", desc: "Rebase to Alpine 3.20." }
4950
- { date: "16.04.24:", desc: "Rebase to Alpine 3.19, upgrade to php 8.3." }

root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,37 +63,35 @@ lsiown -R abc:abc \
6363
/app/www/storage
6464

6565
# Check for env file
66-
if [[ ! -f /config/.env ]]; then
67-
cp /app/www/.env.production /config/.env
68-
fi
69-
70-
# create symlinks
71-
symlinks=( \
72-
/app/www/.env \
73-
)
66+
if [[ -f /config/.env ]]; then
67+
# create symlinks
68+
symlinks=( \
69+
/app/www/.env \
70+
)
7471

75-
for i in "${symlinks[@]}"
76-
do
77-
if [[ -e "$i" && ! -L "$i" ]]; then
78-
rm -rf "$i"
79-
fi
80-
if [[ ! -L "$i" ]]; then
81-
ln -s /config/"$(basename "$i")" "$i"
82-
fi
83-
done
72+
for i in "${symlinks[@]}"
73+
do
74+
if [[ -e "$i" && ! -L "$i" ]]; then
75+
rm -rf "$i"
76+
fi
77+
if [[ ! -L "$i" ]]; then
78+
ln -s /config/"$(basename "$i")" "$i"
79+
fi
80+
done
81+
fi
8482

8583
# Check for app key
8684
if [[ -z ${APP_KEY} ]]; then
87-
if ! grep -E "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env > /dev/null; then
88-
export APP_KEY=$(s6-setuidgid abc php /app/www/artisan key:generate --show)
89-
echo "An application key was generated at start up, as no environment variable was set."
90-
echo "To set an application key that persists, read the docs: https://docs.speedtest-tracker.dev/"
85+
if ! grep -qE "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env 2> /dev/null; then
86+
echo "An application key is missing, halting init!"
87+
echo "You can generate a key at https://speedtest-tracker.dev/."
88+
sleep infinity
9189
fi
9290
fi
9391

9492
# Build cache
95-
s6-setuidgid abc php /app/www/artisan view:clear --no-ansi -q
9693
s6-setuidgid abc php /app/www/artisan optimize --no-ansi -q
94+
s6-setuidgid abc php /app/www/artisan filament:cache-components --no-ansi -q
9795

9896
# Migrate database
9997
s6-setuidgid abc php /app/www/artisan migrate --force --no-ansi -q

0 commit comments

Comments
 (0)