Laravel app Images are not visible

Hello, this is my fly.toml file:

# fly.toml app configuration file generated for one-sport on 2023-08-01T17:10:24+03:00
# See for information about how to use this file.

app = "one-sport"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
primary_region = "waw"
console_command = "php /var/www/html/artisan tinker"

    NODE_VERSION = "18"
    PHP_VERSION = "8.2"

  APP_ENV = "production"
  APP_DEBUG = "true"
  APP_URL = ""
  LOG_CHANNEL = "stderr"
  LOG_LEVEL = "debug"
  LOG_STDERR_FORMATTER = "Monolog\\Formatter\\JsonFormatter"
  DB_CONNECTION = "mysql"
  DB_HOST = "mysql-my-new.internal"
  DB_PORT = 3306
  DB_DATABASE= "laravel-db"

  CACHE_DRIVER = "redis"
  FILESYSTEM_DISK = "public"
  SESSION_DRIVER = "database"
  REDIS_URL = "redis://"
  MEMCACHED_HOST = "memcached"
  MAIL_MAILER = "smtp"
  MAIL_HOST = ""
  MAIL_PORT = 2525
  MAIL_FROM_NAME = "LaraApp Team"

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

I manage images in my project with spatie media library.
Here is an example of code in the view:

<img src="{{ $product->getFirstMediaUrl('products/imageOne') }}" class="main_banner float-end" alt="product image">

So when I upload an image, sometimes it can be visible, but very often I see just an alt or empty space for image. And with time is going, all images can disappear. Where should I look for to resolve the problem?


There’s likely 2 (ish) things going on to clarify.

  1. The first (most important) is that VM’s are ephemeral - any file you save to them (like when uploading images) won’t be around if the VM stops/starts.
    • You need to attach a volume and then save user-generated content (like uploaded files) to that volume - docs on that here
  2. Apps stop VM’s automatically when they are idle, fairly quickly. Sending a new request to the restarts the VM(s) automatically. This means your VM may have restarted/lost new data after a file was uploaded.

So, be sure to add a volume to persist data!

Thanks, a lot. For the explanation and for the link.