Skip to content

Commit 75cb2a8

Browse files
authored
Version 7.0.0 + Avoid race condition + install check (#3910)
1 parent bf38642 commit 75cb2a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1064
-611
lines changed

.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ APP_FORCE_HTTPS=false
1717
# Do note that this disable CSP!!
1818
DEBUGBAR_ENABLED=false
1919

20-
# enable or disable log viewer. By default it is enabled.
21-
LOG_VIEWER_ENABLED=true
20+
# enable or disable log viewer. By default it is disabled
21+
# Unfortunately, it is not possible to enable Log Viewer in production.
22+
# If you wish to enable it, also switch your APP_ENV to 'local'
23+
LOG_VIEWER_ENABLED=false
2224

2325
# disable logging 404 errors
2426
# LOG_404_ERRORS=false

.github/workflows/CICD.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ on:
1111
- '**/*.md'
1212
- 'public/dist/*.js'
1313
- 'public/dist/**/*.js'
14-
- 'public/Lychee-front'
1514
pull_request:
1615
paths-ignore:
1716
- '**/*.md'
1817
- 'public/dist/*.js'
1918
- 'public/dist/**/*.js'
20-
- 'public/Lychee-front'
2119
# Allow manually triggering the workflow.
2220
workflow_dispatch:
2321

@@ -207,6 +205,9 @@ jobs:
207205
- name: Checkout code
208206
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
209207

208+
- name: Set up QEMU
209+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
210+
210211
- name: Set up Docker Buildx
211212
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f #v3.12.0
212213

@@ -217,13 +218,22 @@ jobs:
217218
username: ${{ github.actor }}
218219
password: ${{ secrets.GITHUB_TOKEN }}
219220

221+
-
222+
name: Login to DockerHub
223+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
224+
with:
225+
username: ${{ secrets.DOCKERHUB_USERNAME }}
226+
password: ${{ secrets.DOCKERHUB_TOKEN }}
227+
220228
- name: Extract metadata (tags, labels)
221229
id: meta
222230
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
223231
with:
224-
images: ghcr.io/${{ github.repository }}
232+
images: |
233+
${{ github.repository }}
234+
ghcr.io/${{ github.repository }}
225235
flavor: |
226-
latest=${{ startsWith(github.ref, 'refs/tags/') }}
236+
latest=${{ startsWith(github.ref, 'refs/tags/') }}
227237
tags: |
228238
# define default branch
229239
type=edge,branch=master
@@ -236,6 +246,7 @@ jobs:
236246
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
237247
with:
238248
push: true
249+
platforms: linux/amd64,linux/arm64
239250
tags: ${{ steps.meta.outputs.tags }}
240251
labels: ${{ steps.meta.outputs.labels }}
241252
cache-from: type=gha

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ FROM dunglas/frankenphp:php8.4-alpine@sha256:49654aea8f2b9bc225bde6d89c901105450
6161
ARG USER=appuser
6262

6363
LABEL maintainer="lycheeorg"
64+
LABEL org.opencontainers.image.title="Lychee"
65+
LABEL org.opencontainers.image.description="Self-hosted photo management system done right."
66+
LABEL org.opencontainers.image.authors="LycheeOrg"
67+
LABEL org.opencontainers.image.vendor="LycheeOrg"
6468
LABEL org.opencontainers.image.source="https://github.com/LycheeOrg/Lychee"
69+
LABEL org.opencontainers.image.url="https://lycheeorg.github.io"
70+
LABEL org.opencontainers.image.documentation="https://lycheeorg.dev/docs"
71+
LABEL org.opencontainers.image.licenses="MIT"
72+
LABEL org.opencontainers.image.base.name="dunglas/frankenphp:php8.4-alpine"
6573

6674
# Install system utilities and PHP extensions
6775
# hadolint ignore=DL3018

README.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
[![Website][website-shield]](https://lycheeorg.dev)
1414
[![Documentation][docs-shield]](https://lycheeorg.dev/docs/)
1515
[![Changelog][changelog-shield]](https://lycheeorg.dev/docs/releases.html)
16-
[![Docker repository][docker-shield]](https://github.com/LycheeOrg/Lychee-Docker)
1716
[![Gitter][gitter-shield]](https://gitter.im/LycheeOrg/Lobby)
1817
[![Discord][discord-shield]][discord]
1918

@@ -23,6 +22,10 @@ Lychee is a free, open-source photo-management tool that runs on your server or
2322

2423
For even more advanced features, consider the Supporter Edition (SE). The SE version offers additional functionality to enhance your experience. Learn more about the Supporter Edition and its benefits [here](https://lycheeorg.dev/get-supporter-edition).
2524

25+
## ⚠️ Upgrade Notice to Version 7.0
26+
27+
**Version 7.0 introduces significant changes on the docker image.** Please refer to our [Upgrade Guide](https://lycheeorg.dev/docs/upgrade.html#upgrading-lychee-docker-installations-from-v6-to-v7) for detailed instructions on how to upgrade from previous versions.
28+
2629
## Support the Team
2730

2831
We aim to maintain a free open-source photography library with high quality of code.<br>
@@ -46,13 +49,13 @@ There are three deployment options available. The simplest is **Docker deploymen
4649

4750
### Docker deployment
4851

49-
An official Docker image can be found at [LycheeOrg/Lychee-Docker](https://github.com/LycheeOrg/Lychee-Docker) or on Docker Hub as [lycheeorg/lychee](https://hub.docker.com/r/lycheeorg/lychee).
52+
An official Docker image can be found at [LycheeOrg/Lychee](https://github.com/LycheeOrg/Lychee/pkgs/container/lychee) or on Docker Hub as [lycheeorg/lychee](https://hub.docker.com/r/lycheeorg/lychee).
5053

5154
### File-based deployment
5255

5356
Copy the extracted Zip file from https://github.com/LycheeOrg/Lychee/releases to your webserver.
5457

55-
If you feel like checking the authenticity of our releases, we advise you to read our [Verifying Releases documentation](docs/specs/5-operations/verifying-releases.md).
58+
If you feel like checking the authenticity of our releases, we advise you to read our [Verifying Releases documentation &#187;](docs/specs/5-operations/verifying-releases.md).
5659

5760
### Build from Source deployment
5861

@@ -66,7 +69,7 @@ To run Lychee, everything you need is a web-server with PHP 8.4 or later and a d
6669
6. Generate your secret key with `php artisan key:generate`
6770
7. Migrate your database with `php artisan migrate` to create a new database or migrate an existing Lychee installation to the latest framework.
6871

69-
See detailed instructions on the [Installation](https://lycheeorg.dev/docs/installation.html) page of our documentation.
72+
See detailed instructions on the [Installation &#187;](https://lycheeorg.dev/docs/installation.html) page of our documentation.
7073

7174
### Update
7275

@@ -108,19 +111,8 @@ In order to use the new photos email notification you will need to have configur
108111

109112
Take a look at the [Documentation](https://lycheeorg.dev/docs/), particularly the [FAQ](https://lycheeorg.dev/docs/faq_troubleshooting.html) if you have problems. Discovered a bug? Please create an issue [here](https://github.com/LycheeOrg/Lychee/issues) on GitHub! You can also contact us directly on [gitter (login with your github account)](https://gitter.im/LycheeOrg/Lobby) or on [discord &#187;][discord].
110113

111-
## Notice: `master` & `alpha` branches
112-
113-
As LycheeOrg is a very small team, we do not have many maintainers. Most of us have an active work/family life, and as a result, it is no longer possible for us to apply proper 4-eyes principle in the coding reviews.
114-
115-
In order to keep our high code quality, the following changes have been applied.
116-
117-
- `master` stays as a stable branch and contains 4-eyes peer-reviewed pull-requests.
118-
- `alpha` contains the latest changes (i.e. the above mentionned PR) merged with minimal review.
119-
120-
With this change, we hope to strike a balance between decently paced development (on `alpha`) and maintaining a robust core (on `master`).
121-
122-
On Docker, `nightly`/`dev` continues to refer to the latest `master` commit.
123-
The `alpha` tag is updated daily with the content of the associated branch.
114+
On Docker, `edge` is used to refer to the latest `master` commit.
115+
And `latest` is used to refer to the latest stable release.
124116

125117
That being said, if you like the gallery and would like to contribute, do not hesitate to open pull request. If you would like to see more functionalities added and help us push Lychee, [Join the team!](https://lycheeorg.dev/docs/contributions.html#joining-the-team)
126118

@@ -141,7 +133,6 @@ We would like to thank Jetbrains for supporting us with their [Open Source Devel
141133
[website-shield]: https://img.shields.io/badge/-Website-informational.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAASCAYAAACuLnWgAAABfWlDQ1BpY2MAACiRfZE9SMNAHMVfU6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AwQLbZQsF8o26OZSrNo1hfFqGUYIaLu4KFeXvw03Jt9Bl37aPnkkAACaJWagHy68V28/GKPKRp67qPaHWfmKqNJHvmcCAdMRGDQFbN48DWuFh/OP7uCPsIGRMRdOEiJrL0AuLiKceTjSuXn96J/3vjo30zp76uLvn40BALUG6CNOimdLhSq4JVEd8rD2yUrYTQMVC4huAtFLIdspaM9g8+QUXtv5KrZuWItRzwOnFqTS8IMYfitANBNAzKduI7j6bpDc/7zZ6HgcAHauP3wy5bW99ezCHscMgzxmSJUEIRTQgEk0aIHAEhQcNqZWjCMOulAA0iQGEgL/SQqSMWQOkIkMQZwg5Xq5MWmOA0BAZx1SaC1XPY4oU4gtCaEzQFIQRmEBIJYCcQkyxyCJJQQkuM7BhBpZoqA1AWEGwgX8vB2Mu/vvVQa3f1quVFocAMKoua/ndypEOQDyeOx0USmOggcEqVIAKLjRSOwMERN4GC4i60SYcIrghkFJQOUZYgawdVN4fdPhk8WV48c3VHb1gKNPPz4I/HO7Jz9sdKIn28K4X4o2qg/mag8GqorCQw4wEjLUoIKg2ewgLo7BuBR/zc1jwGLQFpBwjfya1ZjeuhvV4aktXOY0IUT/8yfPVMj84/eDXvfUrUuXcvVLN5Cv+3AZAy9Q9EyCeMjGxkOHML5uHbqNBhLfB2EEec+DNzKKvOtqyugtxvj+yqqJ2nOR2uzsAQJywmj9StTzqd9oIu33YbQCt20MVstwly3zmWU1CHBFa1MDQdFo7WutBeV8kXH+fc6254bKo+q5SP3hHDPKrCKEHKGUvQOjR562vQEhhAK4bYAvLdu+VigOtPOOI+Mg5ACUUxzQ/1orz0uv3WFKiHKWprbRT2cJYyCUdkdXLO/if+Rvf2QoDtYrAMIAAAAASUVORK5CYII=
142134
[docs-shield]: https://img.shields.io/badge/-Documentation-informational.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAASCAYAAACuLnWgAAABfWlDQ1BpY2MAACiRfZE9SMNAHMVfU6VaKg52EHEIWJ0siIqIk1ahCB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GUYIaLu4KFeXvw03Jt9Bl37aPnkkAACaJWagHy68V28/GKPKRp67qPaHWfmKqNJHvmcCAdMRGDQFbN48DWuFh/OP7uCPsIGRMRdOEiJrL0AuLiKceTjSuXn96J/3vjo30zp76uLvn40BALUG6CNOimdLhSq4JVEd8rD2yUrYTQMVC4huAtFLIdspaM9g8+QUXtv5KrZuWItRzwOnFqTS8IMYfitANBNAzKduI7j6bpDc/7zZ6HgcAHauP3wy5bW99ezCHscMgzxmSJUEIRTQgEk0aIHAEhQcNqZWjCMOulAA0iQGEgL/SQqSMWQOkIkMQZwg5Xq5MWmOA0BAZx1SaC1XPY4oU4gtCaEzQFIQRmEBIJYCcQkyxyCJJQQkuM7BhBpZoqA1AWEGwgX8vB2Mu/vvVQa3f1quVFocAMKoua/ndypEOQDyeOx0USmOggcEqVIAKLjRSOwMERN4GC4i60SYcIrghkFJQOUZYgawdVN4fdPhk8WV48c3VHb1gKNPPz4I/HO7Jz9sdKIn28K4X4o2qg/mag8GqorCQw4wEjLUoIKg2ewgLo7BuBR/zc1jwGLQFpBwjfya1ZjeuhvV4aktXOY0IUT/8yfPVMj84/eDXvfUrUuXcvVLN5Cv+3AZAy9Q9EyCeMjGxkOHML5uHbqNBhLfB2EEec+DNzKKvOtqyugtxvj+yqqJ2nOR2uzsAQJywmj9StTzqd9oIu33YbQCt20MVstwly3zmWU1CHBFa1MDQdFo7WutBeV8kXH+fc6254bKo+q5SP3hHDPKrCKEHKGUvQOjR562vQEhhAK4bYAvLdu+VigOtPOOI+Mg5ACUUxzQ/1orz0uv3WFKiHKWprbRT2cJYyCUdkdXLO/if+Rvf2QoDtYrAMIAAAAASUVORK5CYII=
143135
[changelog-shield]: https://img.shields.io/badge/-Changelog-informational.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAASCAYAAACuLnWgAAABfWlDQ1BpY2MAACiRfZE9SMNAHMVfU6VaKg52EHEIWJ0siIqIk1ahCBVCrdCqg8mlX9CkIWlxcRRc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37aPnkkAACaJWagHy68V28/GKPKRp67qPaHWfmKqNJHvmcCAdMRGDQFbN48DWuFh/OP7uCPsIGRMRdOEiJrL0AuLiKceTjSuXn96J/3vjo30zp76uLvn40BALUG6CNOimdLhSq4JVEd8rD2yUrYTQMVC4huAtFLIdspaM9g8+QUXtv5KrZuWItRzwOnFqTS8IMYfitANBNAzKduI7j6bpDc/7zZ6HgcAHauP3wy5bW99ezCHscMgzxmSJUEIRTQgEk0aIHAEhQcNqZWjCMOulAA0iQGEgL/SQqSMWQOkIkMQZwg5Xq5MWmOA0BAZx1SaC1XPY4oU4gtCaEzQFIQRmEBIJYCcQkyxyCJJQQkuM7BhBpZoqA1AWEGwgX8vB2Mu/vvVQa3f1quVFocAMKoua/ndypEOQDyeOx0USmOggcEqVIAKLjRSOwMERN4GC4i60SYcIrghkFJQOUZYgawdVN4fdPhk8WV48c3VHb1gKNPPz4I/HO7Jz9sdKIn28K4X4o2qg/mag8GqorCQw4wEjLUoIKg2ewgLo7BuBR/zc1jwGLQFpBwjfya1ZjeuhvV4aktXOY0IUT/8yfPVMj84/eDXvfUrUuXcvVLN5Cv+3AZAy9Q9EyCeMjGxkOHML5uHbqNBhLfB2EEec+DNzKKvOtqyugtxvj+yqqJ2nOR2uzsAQJywmj9StTzqd9oIu33YbQCt20MVstwly3zmWU1CHBFa1MDQdFo7WutBeV8kXH+fc6254bKo+q5SP3hHDPKrCKEHKGUvQOjR562vQEhhAK4bYAvLdu+VigOtPOOI+Mg5ACUUxzQ/1orz0uv3WFKiHKWprbRT2cJYyCUdkdXLO/if+Rvf2QoDtYrAMIAAAAASUVORK5CYII=
144-
[docker-shield]: https://img.shields.io/badge/-Lychee--Docker-informational.svg?logo=github
145136
[gitter-shield]: https://img.shields.io/gitter/room/LycheeOrg/Lobby.svg?logo=gitter
146137
[jetbrains-opensource]: https://www.jetbrains.com/community/opensource/
147138
[download-shield]: https://img.shields.io/github/downloads/LycheeOrg/Lychee/total
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
3+
/**
4+
* SPDX-License-Identifier: MIT
5+
* Copyright (c) 2017-2018 Tobias Reich
6+
* Copyright (c) 2018-2025 LycheeOrg.
7+
*/
8+
9+
namespace App\Http\Controllers\Admin\Maintenance;
10+
11+
use App\Http\Requests\Maintenance\MaintenanceRequest;
12+
use Illuminate\Routing\Controller;
13+
use Illuminate\Support\Facades\Config;
14+
use Illuminate\Support\Facades\DB;
15+
use Illuminate\Support\Facades\Queue;
16+
17+
/**
18+
* FlushQueue - Maintenance controller for managing the job queue.
19+
*
20+
* This controller provides functionality to:
21+
* - Check the number of pending jobs in the queue
22+
* - Clear all pending jobs from the queue
23+
*
24+
* Behavior Based on Queue Configuration:
25+
* - If queue is 'sync': Returns 0 (no persistent queue)
26+
* - If queue is 'database': Counts/clears jobs from the jobs table
27+
* - Other queue drivers (redis, sqs, etc.): May not be fully supported
28+
*
29+
* CAUTION: Clearing the queue will delete all pending jobs permanently.
30+
* This cannot be undone. Only use when you need to reset the queue state.
31+
*/
32+
class FlushQueue extends Controller
33+
{
34+
/**
35+
* Clear all pending jobs from the queue.
36+
*
37+
* CAUTION: This permanently deletes all pending jobs.
38+
*
39+
* @param MaintenanceRequest $request Authenticated maintenance request (admin only)
40+
*
41+
* @return void
42+
*/
43+
public function do(MaintenanceRequest $request): void
44+
{
45+
$queue_connection = Config::get('queue.default', 'sync');
46+
47+
// Sync queue has no persistent storage, nothing to clear
48+
if ($queue_connection === 'sync') {
49+
return;
50+
}
51+
52+
// For database queue, use Laravel's clear method if available
53+
if ($queue_connection === 'database') {
54+
// Truncate the jobs table to clear all pending jobs
55+
DB::table('jobs')->truncate();
56+
} else {
57+
// For other queue drivers (redis, sqs, etc.), attempt to use the clear method
58+
// This requires the queue to implement ClearableQueue interface
59+
$queue = Queue::connection($queue_connection);
60+
61+
if (method_exists($queue, 'clear')) {
62+
$queue->clear(Config::get("queue.connections.{$queue_connection}.queue", 'default'));
63+
}
64+
}
65+
}
66+
67+
/**
68+
* Count the number of pending jobs in the queue.
69+
*
70+
* Returns the count of jobs currently waiting to be processed.
71+
*
72+
* @param MaintenanceRequest $request Authenticated maintenance request (admin only)
73+
*
74+
* @return int Total number of pending jobs in the queue
75+
*/
76+
public function check(MaintenanceRequest $request): int
77+
{
78+
$queue_connection = Config::get('queue.default', 'sync');
79+
80+
// Sync queue has no persistent storage, always 0
81+
if ($queue_connection === 'sync') {
82+
return 0;
83+
}
84+
85+
// For database queue, count jobs in the jobs table
86+
if ($queue_connection === 'database') {
87+
return DB::table('jobs')->count();
88+
}
89+
90+
// For other queue drivers, attempt to get queue size
91+
$queue = Queue::connection($queue_connection);
92+
93+
if (method_exists($queue, 'size')) {
94+
return $queue->size(Config::get("queue.connections.{$queue_connection}.queue", 'default'));
95+
}
96+
97+
// If we can't determine the size, return 0
98+
return 0;
99+
}
100+
}

app/Http/Controllers/Admin/Maintenance/FulfillPreCompute.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,26 @@ public function do(MaintenanceRequest $request): void
5353
$queue_connection = Config::get('queue.default', 'sync');
5454
$is_sync = $queue_connection === 'sync';
5555

56-
$query = $this->getAlbumsNeedingComputation();
56+
$query = $this->getAlbumsNeedingComputation()
57+
->whereRaw('_lft = _rgt - 1') // Only leaf albums
58+
->orderBy('_lft', 'desc');
5759

5860
if ($is_sync) {
5961
// For sync queue, process in chunks by _lft DESC (leaf to root)
6062
// This reduces re-computation as parents are processed before children
61-
$albums = $query->orderBy('_lft', 'desc')->limit(50)->toBase()->get(['id']);
63+
$albums = $query->limit(50)->toBase()->get(['id']);
6264
$albums->each(function ($album): void {
6365
RecomputeAlbumStatsJob::dispatch($album->id);
6466
});
6567
} else {
6668
// For async queue, dispatch all jobs at once
6769
// The queue worker will handle them
68-
$albums = $query->get(['id']);
69-
/** @phpstan-ignore method.notFound */
70-
$albums->each(function ($album): void {
71-
RecomputeAlbumStatsJob::dispatch($album->id);
72-
});
70+
$query->toBase()
71+
->select(['id'])
72+
->lazy(500)
73+
->each(function ($album): void {
74+
RecomputeAlbumStatsJob::dispatch($album->id);
75+
});
7376
}
7477
}
7578

app/Jobs/RecomputeAlbumStatsJob.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,15 @@ private function getPhotoIdForUser(Album $album, ?User $user, bool $is_nsfw_cont
259259
$sorting = $album->getEffectivePhotoSorting();
260260
$result = $photo_query_policy
261261
->applySearchabilityFilter(
262-
query: Photo::query(),
262+
query: Photo::query()->select('photos.id'),
263263
user: $user,
264264
unlocked_album_ids: [],
265265
origin: $album,
266266
include_nsfw: $is_nsfw_context)
267267
->orderBy('photos.is_starred', 'desc')
268268
->orderBy($sorting->column->value, $sorting->order->value)
269269
->select('photos.id')
270-
->get();
271-
272-
$result = $result->first();
270+
->first();
273271

274272
return $result?->id;
275273
}

app/Metadata/Cache/RouteCacheManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function __construct()
8686
'api/v2/Maintenance::oldOrders' => false,
8787
'api/v2/Maintenance::fulfillOrders' => false,
8888
'api/v2/Maintenance::fulfillPrecompute' => false,
89+
'api/v2/Maintenance::flushQueue' => false,
8990

9091
'api/v2/Map' => new RouteCacheConfig(tag: CacheTag::GALLERY, user_dependant: true, extra: [RequestAttribute::ALBUM_ID_ATTRIBUTE]),
9192
'api/v2/Map::provider' => new RouteCacheConfig(tag: CacheTag::SETTINGS),

0 commit comments

Comments
 (0)