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

Add Docker info, do not display Update Maintenance on docker #2894

Merged
merged 1 commit into from
Jan 11, 2025
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: 2 additions & 0 deletions app/Actions/Diagnostics/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Actions\Diagnostics;

use App\Actions\Diagnostics\Pipes\Infos\CountForeignKeyInfo;
use App\Actions\Diagnostics\Pipes\Infos\DockerVersionInfo;
use App\Actions\Diagnostics\Pipes\Infos\ExtensionsInfo;
use App\Actions\Diagnostics\Pipes\Infos\InstallTypeInfo;
use App\Actions\Diagnostics\Pipes\Infos\SystemInfo;
Expand All @@ -18,6 +19,7 @@ class Info
*/
private $pipes = [
VersionInfo::class,
DockerVersionInfo::class,
InstallTypeInfo::class,
SystemInfo::class,
ExtensionsInfo::class,
Expand Down
70 changes: 70 additions & 0 deletions app/Actions/Diagnostics/Pipes/Infos/DockerVersionInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/**
* SPDX-License-Identifier: MIT
* Copyright (c) 2017-2018 Tobias Reich
* Copyright (c) 2018-2025 LycheeOrg.
*/

namespace App\Actions\Diagnostics\Pipes\Infos;

use App\Actions\Diagnostics\Diagnostics;
use App\Contracts\DiagnosticStringPipe;

/**
* Which version of Lychee are we using?
*/
class DockerVersionInfo implements DiagnosticStringPipe
{
/**
* {@inheritDoc}
*/
public function handle(array &$data, \Closure $next): array
{
$docker = 'false';
if ($this->isDocker()) {
if ($this->isLinuxServer()) {
$docker = 'linuxserver.io';
}
if ($this->isLycheeOrg()) {
$docker = 'lycheeorg';
}

$docker = 'custom';
}

$data[] = Diagnostics::line('Docker:', $docker);

return $next($data);
}

/**
* Check if we are running in Docker.
*
* @return bool
*/
public function isDocker(): bool
{
return is_file('/.dockerenv');
}

/**
* Check if we are running in Docker.
*
* @return bool
*/
private function isLinuxServer(): bool
{
return is_file('/build_version');
}

/**
* Check if we are running in Docker.
*
* @return bool
*/
private function isLycheeOrg(): bool
{
return is_file(base_path('/docker_target'));
}
}
14 changes: 8 additions & 6 deletions app/Http/Controllers/Admin/UpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Admin;

use App\Actions\Diagnostics\Pipes\Checks\UpdatableCheck;
use App\Actions\Diagnostics\Pipes\Infos\DockerVersionInfo;
use App\Actions\Diagnostics\Pipes\Infos\VersionInfo;
use App\Actions\InstallUpdate\ApplyUpdate;
use App\Contracts\Exceptions\LycheeException;
Expand Down Expand Up @@ -32,12 +33,13 @@ public function __construct(ApplyUpdate $applyUpdate)
/**
* Retrieve Update data from the server.
*
* @param UpdateRequest $request
* @param VersionInfo $versionInfo
* @param UpdateRequest $request
* @param VersionInfo $versionInfo
* @param DockerVersionInfo $dockerVersionInfo
*
* @return UpdateInfo
*/
public function get(UpdateRequest $request, VersionInfo $versionInfo): UpdateInfo
public function get(UpdateRequest $request, VersionInfo $versionInfo, DockerVersionInfo $dockerVersionInfo): UpdateInfo
{
/** @var VersionChannelType $channelName */
$channelName = $versionInfo->getChannelName();
Expand All @@ -57,17 +59,17 @@ public function get(UpdateRequest $request, VersionInfo $versionInfo): UpdateInf
}
}

return new UpdateInfo($info, $extra, $channelName);
return new UpdateInfo($info, $extra, $channelName, $dockerVersionInfo->isDocker());
}

/**
* Checking if any updates are available.
*
* @return UpdateCheckInfo
*/
public function check(UpdateRequest $request, GitHubVersion $gitHubFunctions, VersionInfo $versionInfo): UpdateCheckInfo
public function check(UpdateRequest $request, GitHubVersion $gitHubFunctions, VersionInfo $versionInfo, DockerVersionInfo $dockerVersionInfo): UpdateCheckInfo
{
return new UpdateCheckInfo($gitHubFunctions->getBehindTest(), !$gitHubFunctions->isUpToDate() || !$versionInfo->fileVersion->isUpToDate());
return new UpdateCheckInfo($gitHubFunctions->getBehindTest(), !$dockerVersionInfo->isDocker() && (!$gitHubFunctions->isUpToDate() || !$versionInfo->fileVersion->isUpToDate()));
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/Http/Resources/Diagnostics/UpdateInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function __construct(
public string $info,
public string $extra,
public VersionChannelType $channelName,
public bool $isDocker,
) {
}
}
3 changes: 2 additions & 1 deletion app/Metadata/Versions/GitHubVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ private function hydrateLocalHead(): void
private function hydrateRemote(bool $useCache): void
{
// We do not fetch when local branch is not master.
if ($this->remote === null || !$this->isMasterBranch()) {
// We do not fetch when the localHead is not set.
if ($this->remote === null || $this->localHead === null || !$this->isMasterBranch()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<Card
v-if="data"
v-if="data && data.isDocker !== true"
class="min-h-40 dark:bg-surface-800 shadow shadow-surface-950/30 rounded-lg relative"
pt:body:class="min-h-40 h-full"
pt:content:class="h-full flex justify-between flex-col"
Expand Down
1 change: 1 addition & 0 deletions resources/js/lychee.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ declare namespace App.Http.Resources.Diagnostics {
info: string;
extra: string;
channelName: App.Enum.VersionChannelType;
isDocker: boolean;
};
}
declare namespace App.Http.Resources.Editable {
Expand Down
Loading