Skip to content

Add Laravel Automation for Storage Initialization - #711

Open
ryanjbonnell wants to merge 5 commits into
serversideup:release/webserver-improvements-and-fixesfrom
ryanjbonnell:storage-initialization
Open

ryanjbonnell wants to merge 5 commits into
serversideup:release/webserver-improvements-and-fixesfrom
ryanjbonnell:storage-initialization

Conversation

@ryanjbonnell

@ryanjbonnell ryanjbonnell commented Oct 2, 2026 •

Copy link
Copy Markdown

This update adds an new opt-in Laravel automation that creates Laravel's storage/ and bootstrap/cache directories at container start if they're missing and makes them writable.

Laravel won't boot unless certain directories exist and are writable.

While the Laravel framework includes these storage directories, in containers they often don't exist due to misconfigured .dockerignore excludes or an empty volume mounted over storage/.

When that happens, the container fails with errors like:

The /var/www/html/bootstrap/cache directory must be present and writable.
View path not found.

Developers typically address this situation with their own entrypoint script(s) or by baking .gitkeep files into the image.

This addition improves the DevOps experience by adding the "fix" as an automation, reducing the rigmarole of building and maintaining containers at scale.

Highlights:

  • New AUTORUN_LARAVEL_STORAGE_INIT variable (default false, so no behavior change for existing users).
  • New laravel_storage_init function, which:
    • Creates any missing storage directories expected by Laravel. Existing directories are left alone, so it's safe on every start.
    • Runs chmod ug+rwx on each of those directories only. Files inside them (such as user uploads) are never touched.
    • Skips a directory with an info message when the chmod fails because the directory is owned by another user (e.g. root), instead of failing startup.
    • Stops container startup when a directory can't be created, with the mkdir error shown in debug mode.
  • Runs before every other automation, because Artisan can't boot without bootstrap/cache.

This feature introduces no breaking changes and is available like the other Laravel Automations.

@ryanjbonnell

Copy link
Copy Markdown
Author

A preview of the rendered Markdown documentation, describing the feature and its usage:

CleanShot 2026-10-02 at 00 14 26@2x

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant