Craft CMS 6 assets on fortrabbit
Published
Updated
Craft CMS 6 volumes store files on Laravel disks. Keep uploads in the storage folder, which deployments don't touch.
Install and deploy run down
- Install Craft CMS 6 locally
- Set up an app at fortrabbit
- Deploy code via Git
- Database syncing
- Assets ← you are here
Volumes on Laravel disks
Craft CMS 6 drops its own filesystems. A volume stores its files on a Laravel disk from config/filesystems.php, chosen in the volume settings in the Control Panel.
Use the public disk of the skeleton. It stores files in storage/app/public, and /storage is excluded from deployments, so uploads survive every deployment. Give each volume its own subpath, such as uploads.
The storage link
The public disk serves files under https://…/storage/, through the public/storage symlink. The replace strategy deletes that link on every deployment, so the post-deploy commands create it again:
php artisan storage:link --force
Without it, uploaded images return 404 after a deployment. Add the command to the post-deploy commands of an app created before the template had it.
Sync assets with rsync
Uploads stay out of git. Copy them with rsync:
# UP: local to fortrabbit
rsync -av ./storage/app/public/ {{app-env-id}}@ssh.{{region}}.frbit.app:storage/app/public/
# DOWN: fortrabbit to local
rsync -av {{app-env-id}}@ssh.{{region}}.frbit.app:storage/app/public/ ./storage/app/public/
Add --dry-run to see what would change first.
Store assets in S3
The s3 disk of the skeleton reads AWS_* ENV vars and needs the league/flysystem-aws-s3-v3 package. Uploads then go to the bucket instead of the environment's storage. It adds a service to pay for and set up, so use it for many or large files. See Laravel's filesystem docs.