Skip to content
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
25 changes: 23 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

# dependencies
composer-cache
vendor/
node_modules/

# Documentation
README.md
Expand All @@ -21,19 +23,36 @@ docs/
.editorconfig
.php-cs-fixer.php
.php-cs-fixer.cache
.gitattributes
.gitignore
.php-cs-fixer.php
.phpstaorm.meta.php
.prettierrc.json
AGENTS.md
codecov.yml
CONTRIBUTING.md
Dockerfile
eslint.config.js
Makefile
osv-scanner.toml
phpstan-baseline.neon
phpstan.neon
phpunit.ci.xml
phpunit.xml
.phpunit.result.cache
rector.php
sonar-project.properties
phpstan/*
scripts/*
vite/*
# Local testing @ildyria
public/uploads-bck/*

# Node
node_modules/
npm-debug.log

# Lychee
/public/uploads/*
# Mapping for database and config used by docker compose
lychee/*

# Laravel
Expand All @@ -46,6 +65,8 @@ lychee/*
!.env.example

# IDE
.ai/
.claude/
.vscode/
.idea/
*.swp
Expand Down
6 changes: 5 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ indent_size = 4

[docker-compose.yaml]
indent_style = space
indent_size = 2
indent_size = 2

[Dockerfile]
indent_style = space
indent_size = 4
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ DEBUGBAR_ENABLED=false
# enable or disable log viewer. By default it is enabled.
LOG_VIEWER_ENABLED=true

# disable logging 404 errors
# LOG_404_ERRORS=false

# enable or disable clockwork. By default it is disabled (and not provided on non-dev build).
CLOCKWORK_ENABLE=false
CLOCKWORK_DRIVER=laravel
CLOCKWORK_STORAGE_FILES_PATH=storage/clockwork

# enable or disable latency debug: adds a specific amount of time in milliseconds to wait before processing requests.
# Always disabled on production environment.
Expand Down Expand Up @@ -113,6 +118,7 @@ REDIS_PORT=6379
# to disable it for your Log Viewer.
# Should redis crash, you will no longer be able to access your logs.
LOG_VIEWER_CACHE_DRIVER=file
LOG_STDOUT=false

# Session configuration
SESSION_DRIVER=file
Expand Down
46 changes: 24 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@
COPY composer.json composer.lock ./

# Install dependencies (no dev packages for production)
# Remove markdown and test directories to slim down the image
RUN composer install \
--no-dev \
--no-interaction \
--no-progress \
--no-scripts \
--prefer-dist \
--optimize-autoloader \
--ignore-platform-reqs
--ignore-platform-reqs \
&& find vendor \
\( -iname "*.md" -o -iname "test" -o -iname "tests" \) \
-exec rm -rf {} +

# ============================================================================
# Stage 2: Node.js Build for Frontend Assets
Expand Down Expand Up @@ -63,32 +67,30 @@
# hadolint ignore=DL3018
RUN apk add --no-cache \
exiftool \
shadow \
shadow \
ffmpeg \
gd \
grep \
imagemagick \
jpegoptim \
netcat-openbsd \
unzip \
netcat-openbsd \
unzip \
curl \
&& install-php-extensions \
pdo_mysql \
pdo_pgsql \
gd \
zip \
dom \
bcmath \
sodium \
opcache \
pcntl \
exif \
imagick \
intl \
redis \
tokenizer \
&& rm -rf /var/cache/apk/* \
&& apk del shadow
exif \
imagick \
intl \
redis \
tokenizer \
&& rm -rf /var/cache/apk/*

WORKDIR /app

Expand All @@ -102,7 +104,7 @@
COPY --from=node --chown=www-data:www-data /app/public/build ./public/build

# Ensure storage and bootstrap/cache are writable with minimal permissions
RUN mkdir -p storage/framework/cache \

Check failure on line 107 in Dockerfile

View workflow job for this annotation

GitHub Actions / 3️⃣ Dockerfile Lint

SC2086 info: Double quote to prevent globbing and word splitting.
storage/framework/sessions \
storage/framework/views \
storage/logs \
Expand All @@ -111,18 +113,18 @@
&& chown -R www-data:www-data storage bootstrap/cache public/dist \
&& chmod -R 750 storage bootstrap/cache \
&& chmod -R 755 public/dist \
&& touch /app/frankenphp_target \
&& touch /app/public/dist/user.css \
&& touch /app/public/dist/custom.js \
&& chown www-data:www-data /app/public/dist/user.css /app/public/dist/custom.js \
&& chmod 644 /app/public/dist/user.css /app/public/dist/custom.js \
&& cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini \
&& touch /app/frankenphp_target \
&& touch /app/public/dist/user.css \
&& touch /app/public/dist/custom.js \
&& chown www-data:www-data /app/public/dist/user.css /app/public/dist/custom.js \
&& chmod 644 /app/public/dist/user.css /app/public/dist/custom.js \
&& cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini \
&& echo "upload_max_filesize=110M" > $PHP_INI_DIR/conf.d/custom.ini \
&& echo "post_max_size=110M" >> $PHP_INI_DIR/conf.d/custom.ini \
&& echo "max_execution_time=3000" >> $PHP_INI_DIR/conf.d/custom.ini \
&& echo "expose_php=Off" >> $PHP_INI_DIR/conf.d/custom.ini \
&& echo "display_errors=Off" >> $PHP_INI_DIR/conf.d/custom.ini \
&& echo "log_errors=On" >> $PHP_INI_DIR/conf.d/custom.ini
&& echo "max_execution_time=3000" >> $PHP_INI_DIR/conf.d/custom.ini \
&& echo "expose_php=Off" >> $PHP_INI_DIR/conf.d/custom.ini \
&& echo "display_errors=Off" >> $PHP_INI_DIR/conf.d/custom.ini \
&& echo "log_errors=On" >> $PHP_INI_DIR/conf.d/custom.ini

# Copy entrypoint and validation scripts
COPY docker/scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
Expand Down
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,14 @@ gen_typescript_types:
class-leak:
vendor/bin/class-leak check app database/migrations config --skip-type Illuminate\\View\\Component

docker-build-base-image:
docker build -t lychee-base:latest ./docker/base
docker-build:
docker build -t lychee-frankenphp .

docker-build-dev-image:
docker build ./docker/dev -t lychee-dev:latest
docker-build-no-cache:
docker build -t lychee-frankenphp . --no-cache

docker-build-dev: docker-build-base-image docker-build-dev-image
docker-run:
docker compose up

test_pgsql_v2:
docker compose -f docker-compose-pgsql.yaml up -d
Expand Down
2 changes: 1 addition & 1 deletion app/Assets/ArrayToTextTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ protected function setWidth(string $key, ?string $value): void
*/
protected static function valueToLines(?string $value): array
{
return explode("\n", $value);
return explode("\n", $value ?? '');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove deprecation warning from php8.5

}

protected static function mb_str_pad(
Expand Down
5 changes: 5 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
* Lychee's custom exception handler.
Expand Down Expand Up @@ -135,6 +136,10 @@ public function __construct(Container $container)
// Cache the application path to avoid multiple function calls
// and potential exceptions in `report()`
$this->appPath = app_path();

if (config('features.log_404_errors') === false) {
$this->dontReport[] = NotFoundHttpException::class;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Models/AlbumResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(Album $album)
$this->track_url = $album->track_url;
$this->license = $album->license->localization();
// TODO: Investigate later why this string is 24 characters long.
$this->header_id = trim($album->header_id);
$this->header_id = $album->header_id !== null ? trim($album->header_id) : null;

// children
$this->parent_id = $album->parent_id;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Models/ThumbAlbumResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function __construct(AbstractAlbum $data)
$this->created_at_carbon = $data->created_at;
$this->created_at = $this->created_at_carbon->format($date_format);
$policy = AlbumProtectionPolicy::ofBaseAlbum($data);
$this->description = Str::limit($data->description, 100);
$this->description = $data->description === null ? null : Str::limit($data->description, 100);
$this->owner = $data->owner->username;
}

Expand Down
2 changes: 1 addition & 1 deletion app/Models/Album.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ protected function setAlbumThumbAspectRatioAttribute(?AspectRatioType $aspect_ra
*/
protected function getAlbumTimelineAttribute(): ?TimelineAlbumGranularity
{
return TimelineAlbumGranularity::tryFrom($this->attributes['album_timeline']);
return TimelineAlbumGranularity::tryFrom($this->attributes['album_timeline'] ?? '');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove deprecation warning from php8.5

}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/Models/BaseAlbumImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ protected function setPhotoSortingAttribute(?PhotoSortingCriterion $sorting): vo
*/
protected function getPhotoLayoutAttribute(): ?PhotoLayoutType
{
return PhotoLayoutType::tryFrom($this->attributes['photo_layout']);
return PhotoLayoutType::tryFrom($this->attributes['photo_layout'] ?? '');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove deprecation warning from php8.5

}

/**
Expand All @@ -324,7 +324,7 @@ protected function setPhotoLayoutAttribute(?PhotoLayoutType $aspect_ratio): void
*/
protected function getPhotoTimelineAttribute(): ?TimelinePhotoGranularity
{
return TimelinePhotoGranularity::tryFrom($this->attributes['photo_timeline']);
return TimelinePhotoGranularity::tryFrom($this->attributes['photo_timeline'] ?? '');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove deprecation warning from php8.5

}

/**
Expand Down
Loading