Add LibreSpeed cli to dev image (#2455)

Co-authored-by: Alex Justesen <1144087+alexjustesen@users.noreply.github.com>
This commit is contained in:
Alex Justesen
2025-11-27 19:18:14 -06:00
committed by GitHub
parent ed62109e12
commit 28418c3761
3 changed files with 54 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Actions\Librespeed;
use App\Enums\ResultService;
use App\Enums\ResultStatus;
use App\Events\SpeedtestWaiting;
use App\Models\Result;
use Lorisleiva\Actions\Concerns\AsAction;
use Throwable;
class RunSpeedtest
{
use AsAction;
public function handle(bool $isScheduled = false, ?string $server = null, ?int $dispatchedBy = null): mixed
{
$result = Result::create([
'data->server->url' => $server,
'service' => ResultService::Librespeed,
'status' => ResultStatus::Waiting,
'scheduled' => $isScheduled,
'dispatched_by' => $dispatchedBy,
]);
SpeedtestWaiting::dispatch($result);
// TODO: Implement Librespeed speedtest job batching
// Bus::batch([
// [
// new StartSpeedtestJob($result),
// new CheckForInternetConnectionJob($result),
// new SkipSpeedtestJob($result),
// new SelectSpeedtestServerJob($result),
// new RunSpeedtestJob($result),
// new BenchmarkSpeedtestJob($result),
// new CompleteSpeedtestJob($result),
// ],
// ])->catch(function (Batch $batch, ?Throwable $e) {
// Log::error(sprintf('Speedtest batch "%s" failed for an unknown reason.', $batch->id));
// })->name('Ookla Speedtest')->dispatch();
return $result;
}
}
+2
View File
@@ -7,12 +7,14 @@ use Filament\Support\Contracts\HasLabel;
enum ResultService: string implements HasLabel
{
case Faker = 'faker';
case Librespeed = 'librespeed';
case Ookla = 'ookla';
public function getLabel(): ?string
{
return match ($this) {
self::Faker => __('enums.service.faker'),
self::Librespeed => __('enums.service.librespeed'),
self::Ookla => __('enums.service.ookla'),
};
}
+6
View File
@@ -7,6 +7,7 @@ ARG NODE_VERSION=22
ARG MYSQL_CLIENT="mysql-client"
ARG POSTGRES_VERSION=17
ARG SPEEDTEST_VERSION=1.2.0
ARG LIBRESPEED_VERSION=1.0.12
WORKDIR /var/www/html
@@ -49,14 +50,19 @@ RUN apt-get update && apt-get upgrade -y \
&& ARCH=$(uname -m) \
&& if [ "$ARCH" = "x86_64" ]; then \
PLATFORM="x86_64"; \
LIBRESPEED_PLATFORM="amd64"; \
elif [ "$ARCH" = "aarch64" ]; then \
PLATFORM="aarch64"; \
LIBRESPEED_PLATFORM="arm64"; \
else \
echo "Unsupported architecture: $ARCH"; exit 1; \
fi \
&& curl -o /tmp/speedtest-cli.tgz -L \
"https://install.speedtest.net/app/cli/ookla-speedtest-$SPEEDTEST_VERSION-linux-$PLATFORM.tgz" \
&& tar -xzf /tmp/speedtest-cli.tgz -C /usr/bin \
&& curl -o /tmp/librespeed-cli.tar.gz -L \
"https://github.com/librespeed/speedtest-cli/releases/download/v$LIBRESPEED_VERSION/librespeed-cli_${LIBRESPEED_VERSION}_linux_${LIBRESPEED_PLATFORM}.tar.gz" \
&& tar -xzf /tmp/librespeed-cli.tar.gz -C /usr/bin \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*