Skip to content

Commit 28418c3

Browse files
authored
Add LibreSpeed cli to dev image (alexjustesen#2455)
Co-authored-by: Alex Justesen <[email protected]>
1 parent ed62109 commit 28418c3

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
namespace App\Actions\Librespeed;
4+
5+
use App\Enums\ResultService;
6+
use App\Enums\ResultStatus;
7+
use App\Events\SpeedtestWaiting;
8+
use App\Models\Result;
9+
use Lorisleiva\Actions\Concerns\AsAction;
10+
use Throwable;
11+
12+
class RunSpeedtest
13+
{
14+
use AsAction;
15+
16+
public function handle(bool $isScheduled = false, ?string $server = null, ?int $dispatchedBy = null): mixed
17+
{
18+
$result = Result::create([
19+
'data->server->url' => $server,
20+
'service' => ResultService::Librespeed,
21+
'status' => ResultStatus::Waiting,
22+
'scheduled' => $isScheduled,
23+
'dispatched_by' => $dispatchedBy,
24+
]);
25+
26+
SpeedtestWaiting::dispatch($result);
27+
28+
// TODO: Implement Librespeed speedtest job batching
29+
30+
// Bus::batch([
31+
// [
32+
// new StartSpeedtestJob($result),
33+
// new CheckForInternetConnectionJob($result),
34+
// new SkipSpeedtestJob($result),
35+
// new SelectSpeedtestServerJob($result),
36+
// new RunSpeedtestJob($result),
37+
// new BenchmarkSpeedtestJob($result),
38+
// new CompleteSpeedtestJob($result),
39+
// ],
40+
// ])->catch(function (Batch $batch, ?Throwable $e) {
41+
// Log::error(sprintf('Speedtest batch "%s" failed for an unknown reason.', $batch->id));
42+
// })->name('Ookla Speedtest')->dispatch();
43+
44+
return $result;
45+
}
46+
}

app/Enums/ResultService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
enum ResultService: string implements HasLabel
88
{
99
case Faker = 'faker';
10+
case Librespeed = 'librespeed';
1011
case Ookla = 'ookla';
1112

1213
public function getLabel(): ?string
1314
{
1415
return match ($this) {
1516
self::Faker => __('enums.service.faker'),
17+
self::Librespeed => __('enums.service.librespeed'),
1618
self::Ookla => __('enums.service.ookla'),
1719
};
1820
}

docker/8.4/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ARG NODE_VERSION=22
77
ARG MYSQL_CLIENT="mysql-client"
88
ARG POSTGRES_VERSION=17
99
ARG SPEEDTEST_VERSION=1.2.0
10+
ARG LIBRESPEED_VERSION=1.0.12
1011

1112
WORKDIR /var/www/html
1213

@@ -49,14 +50,19 @@ RUN apt-get update && apt-get upgrade -y \
4950
&& ARCH=$(uname -m) \
5051
&& if [ "$ARCH" = "x86_64" ]; then \
5152
PLATFORM="x86_64"; \
53+
LIBRESPEED_PLATFORM="amd64"; \
5254
elif [ "$ARCH" = "aarch64" ]; then \
5355
PLATFORM="aarch64"; \
56+
LIBRESPEED_PLATFORM="arm64"; \
5457
else \
5558
echo "Unsupported architecture: $ARCH"; exit 1; \
5659
fi \
5760
&& curl -o /tmp/speedtest-cli.tgz -L \
5861
"https://install.speedtest.net/app/cli/ookla-speedtest-$SPEEDTEST_VERSION-linux-$PLATFORM.tgz" \
5962
&& tar -xzf /tmp/speedtest-cli.tgz -C /usr/bin \
63+
&& curl -o /tmp/librespeed-cli.tar.gz -L \
64+
"https://github.com/librespeed/speedtest-cli/releases/download/v$LIBRESPEED_VERSION/librespeed-cli_${LIBRESPEED_VERSION}_linux_${LIBRESPEED_PLATFORM}.tar.gz" \
65+
&& tar -xzf /tmp/librespeed-cli.tar.gz -C /usr/bin \
6066
&& apt-get -y autoremove \
6167
&& apt-get clean \
6268
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

0 commit comments

Comments
 (0)