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

  1. Install Craft CMS 6 locally
  2. Set up an app at fortrabbit
  3. Deploy code via Git
  4. Database syncing
  5. 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 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
shell

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

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.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗