Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance by caching Filament components and warn if APP_KEY is missing #19

Merged
merged 8 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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=''
}
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ services:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- APP_KEY=
- DB_CONNECTION=sqlite
- APP_KEY= #optional
- 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:
Expand All @@ -99,13 +103,17 @@ 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 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 \
Expand All @@ -122,13 +130,17 @@ 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 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)
Expand Down Expand Up @@ -292,6 +304,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.
Expand Down
2 changes: 1 addition & 1 deletion jenkins-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 7 additions & 6 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@ 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 }}"
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." }
- { 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" }

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)." }
- { 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
Expand All @@ -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." }
Expand Down
42 changes: 20 additions & 22 deletions root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run
Original file line number Diff line number Diff line change
Expand Up @@ -63,37 +63,35 @@ 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
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/"
if ! grep -qE "APP_KEY=[0-9A-Za-z:+\/=]{1,}" /app/www/.env 2> /dev/null; then
echo "An application key is missing, halting init!"
echo "You can generate a key at https://speedtest-tracker.dev/."
sleep infinity
fi
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
Expand Down