From da19b6a8a2dd2ba960de56bf43d870762756bad7 Mon Sep 17 00:00:00 2001 From: Meghdad Date: Tue, 19 May 2026 19:26:57 +0330 Subject: [PATCH] fix storage link error on docker deploy --- dockerized/SKILL.md | 1 + dockerized/docker/app/Dockerfile | 1 + dockerized/docker/app/entrypoint.sh | 12 +++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dockerized/SKILL.md b/dockerized/SKILL.md index a794344..9384828 100644 --- a/dockerized/SKILL.md +++ b/dockerized/SKILL.md @@ -41,6 +41,7 @@ Only publish HTTP and RTMP by default. Keep MediaMTX HLS behind Apache and keep - When changing Laravel runtime behavior, update the shared `x-app-environment` block unless the value belongs to one role only. - When changing queue behavior, prefer env-driven options on the `queue` service and `docker/app/entrypoint.sh`. - Keep `npm run build` after PHP setup and Composer install in `docker/app/Dockerfile`; the Wayfinder Vite plugin invokes `php artisan wayfinder:generate` during the build. The asset stage must also provide safe build-time Laravel env values, create Laravel writable directories such as `storage/framework/views`, and run `php artisan wayfinder:generate --with-form --no-interaction` before `npm run build` so failures are visible in Docker logs. +- Do not call `php artisan storage:link --force` as `www-data` during container startup; `public/storage` lives in the root-owned image filesystem. Create the symlink as root in the entrypoint if it is missing. - Keep deploy script behavior idempotent: repeat runs should update the Git checkout, rebuild, migrate, and restart services without deleting volumes. - Keep generated secrets in `.env`; do not bake secrets into images or templates. diff --git a/dockerized/docker/app/Dockerfile b/dockerized/docker/app/Dockerfile index b9d6cbf..c2ee589 100644 --- a/dockerized/docker/app/Dockerfile +++ b/dockerized/docker/app/Dockerfile @@ -113,6 +113,7 @@ RUN composer dump-autoload --optimize --no-dev \ storage/framework/views \ storage/logs \ bootstrap/cache \ + && if [ ! -e public/storage ]; then ln -s ../storage/app/public public/storage; fi \ && chown -R www-data:www-data storage bootstrap/cache \ && chmod +x /usr/local/bin/nyone-entrypoint diff --git a/dockerized/docker/app/entrypoint.sh b/dockerized/docker/app/entrypoint.sh index 1a5a364..686da03 100644 --- a/dockerized/docker/app/entrypoint.sh +++ b/dockerized/docker/app/entrypoint.sh @@ -61,6 +61,16 @@ prepare_laravel_paths() { chown -R www-data:www-data storage bootstrap/cache } +ensure_public_storage_link() { + mkdir -p public storage/app/public + + if [[ -L public/storage || -e public/storage ]]; then + return 0 + fi + + ln -s ../storage/app/public public/storage +} + cache_laravel_bootstrap() { if [[ "${APP_OPTIMIZE_ON_BOOT:-true}" != "true" ]]; then return 0 @@ -93,7 +103,7 @@ if [[ "${WAIT_FOR_SERVICES:-true}" == "true" ]]; then fi prepare_laravel_paths -artisan storage:link --force >/dev/null || true +ensure_public_storage_link cache_laravel_bootstrap case "$role" in