Problems with laravel-medialibrary

Hello.

I use the spatie/media-library package to handle media in my Laravel project. The uploaded media gets stored in the storage/app/public directory. I have already followed the fly.io documentation to persist the storage folder but there seems to be something wrong because I have to constantly run fly ssh console -C "php /var/www/html/artisan storage:link" to make my files available again.

The only thread related to this issue is this one, which doesn’t seem to fix my problem.

Here is my fly.toml file:

app = 'the-wordsmiths-collection'
primary_region = 'mad'
console_command = 'php /var/www/html/artisan tinker'

[build]
  [build.args]
    NODE_VERSION = '18'
    PHP_VERSION = '8.3'

[env]
  APP_ENV = 'production'
	APP_URL='https://the-wordsmiths-collection.fly.dev'
	DB_CONNECTION="pgsql"
  LOG_CHANNEL = 'stderr'
  LOG_LEVEL = 'info'
  LOG_STDERR_FORMATTER = 'Monolog\Formatter\JsonFormatter'
  SESSION_DRIVER = 'cookie'
  SESSION_SECURE_COOKIE = 'true'

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

[mounts]
  source="storage_vol"
  destination="/var/www/html/storage"

[[vm]]
  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1

Here is my GitHub repository for the project, if it helps.

I fixed this by adding the line /usr/bin/php /var/www/html/artisan storage:link to the end of the caches.sh file.

#!/usr/bin/env bash

/usr/bin/php /var/www/html/artisan config:cache --no-ansi -q
/usr/bin/php /var/www/html/artisan route:cache --no-ansi -q
/usr/bin/php /var/www/html/artisan view:cache --no-ansi -q

/usr/bin/php /var/www/html/artisan storage:link
1 Like