Skip to content

Add Laravel Automation for Storage Initialization - #711

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

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
Contributor

This update adds a 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.

Summary

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/.

Laravel won't boot unless certain directories exist and are writable. When that happens, the Docker 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
Contributor Author

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

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

@ryanjbonnell

ryanjbonnell commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is similar to #401 (that's been open for over 2+ years!) — but takes a more robust and comprehensive approach.

Both pull requests aim to solve an extremely common problem when containerizing Laravel applications.

It'd be great to see this get added to the 5.x release!

@jaydrogers
jaydrogers deleted the branch serversideup:release/webserver-improvements-and-fixes October 8, 2026 17:28
@jaydrogers jaydrogers closed this Oct 8, 2026
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.

2 participants