Rails ActiveStorage Failure – Unable to Deploy after trying to add Volumes

I created a volume

fly volumes create bjj_rails_active_storage

But when I deploy I get the following error:

Error: Process group 'app' needs volumes with name 'bjj_rails_active_storage' to fullfill mounts defined in fly.toml; Run `fly volume create bjj_rails_active_storage -r REGION` for the following regions and counts: yul=1

I have tried with two differnt fly.toml configs.

First:

[[mounts]]
  processes = ["app"]
  source = "bjj_rails_active_storage"
  destination = "/storage"

As well as:

[mount]
  source = "bjj_rails_active_storage"
  destination = "/storage"

My fly.toml looks like this:

app = "bjjrails"
primary_region = "yul"
kill_signal = "SIGINT"
kill_timeout = "5s"

[experimental]
  auto_rollback = true

[[services]]
  protocol = "tcp"
  internal_port = 3000
  processes = ["app"]

  [[services.ports]]
    port = 80
    handlers = ["http"]
    force_https = true

  [[services.ports]]
    port = 443
    handlers = ["tls", "http"]
    
  [services.concurrency]
    type = "connections"
    hard_limit = 25
    soft_limit = 20

  [[services.tcp_checks]]
    interval = "15s"
    timeout = "2s"
    grace_period = "1s"
    restart_limit = 0

[[statics]]
  guest_path = "/rails/public"
  url_prefix = "/"

Can anyone point me in the right direction?

Turns out I needed to create two volumes with the same name :man_shrugging:

Kinda weird but okay.

Heya - is your app scaled up to two?

I think so?

Image are now loading but only half the time. It’s as if the image was uploaded to one volume but not the other so half the time it’s a lookup-miss or something.

EDIT:

I have 2 app vms and two volumes

It sounds like it, :slight_smile: worth checking though! You can check with fly scale show

Volumes are mounted disk on the same host as each VM. We can’t mount one volume to multiple VMs.

This means if you’re running two separate VMs, the disks will have what its attached VM puts there.

Put another way; if you uploaded something through an app on one VM and wrote it to the location you mounted the volume on, the data would be on the volume attached to the VM that served that request, and not on the other volume.

Groups
NAME    COUNT   KIND    CPUS    MEMORY  REGIONS 
app     2       shared  1       256 MB  yul(2)

Right, yeah. So…should I not be using volumes for active storage?

I could just setup an S3 bucket but was hoping everything could stay inside Fly

I haven’t tried it, but MinIO should work.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.