yes the image could uploaded and opened, but I still lose it somehow after each deploy
my config/storage.yml
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= ENV.fetch('RAILS_STORAGE', Rails.root.join("storage")) %>
my fly.toml
# fly.toml app configuration file generated for norma on 2023-05-07T19:39:43+07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = "myapp"
primary_region = "sin"
[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = true
auto_start_machines = true
[[statics]]
guest_path = "/rails/public"
url_prefix = "/"
[env]
RAILS_STORAGE = "/mnt/volume/storage"
[mounts]
source = "storage_volume"
destination = "/mnt/volume"
$ fly scale show
VM Resources for app: myapp
Groups
NAME COUNT KIND CPUS MEMORY REGIONS
app 1 shared 1 512 MB sin
$ fly volumes list
ID STATE NAME SIZE REGION ZONE ENCRYPTED ATTACHED VM CREATED AT
vol_podq4qymdpnvg8w1 created storage_volume 1GB sin e968 true 3287454ea05438 23 hours ago
If I ssh and browse the directory (/mnt/volume/storage) I could see activestorage folders and files there
is it because I only run one machine and one drive? I feel overwhelmed with the doc that said it must be run on 2 machine and 2 storage,
I don’t care if my app have downtime though I just want it to works like I want to
is it because something like shared dirs or something like that?
I’ll update the guides to provide more guidance on active storage.
Each VM will have its own separate disk, so it is not a good idea to have active storage write to a local disk if you have multiple machines. There is a postgres adapter which you can use if you are already using postgres. If you want your storage to be in fly.io, you can use MinIO. You can also use Amazon S3, Microsoft Azure, or Google Cloud Services.
so you mean, that it is bad to use volume disk to store data? and better to go for storage service like s3?
I think so too, from fly.io doc they recommend me to run 2 machine and 2 storage, to avoid downtime and they ask me to setup the sync between those storage by my own which is not really practical even though I’m fine with the downtime and running it only by 1 machine, it still has problem in my app thus why I make the thread
It is very difficult to give “one size fits all” recommendations in a very concise and clear way. A slightly longer version:
Don’t use volumes unless you are prepared to setup the sync between the volumes.
People who aren’t prepared to set up sync (which, truth be told is most people) use a database, either hosted on fly like Postgres, or hosted elsewhere to address their storage needs.
For those people (which, again, is most people), having only one machine will involve downtime.
I don’t know what time frame you are looking at, but currently in beta is something called litefs, which will store data in sqlite3. I’m working with Kent Dodds on The Epic Stack which supports storing images in litefs on fly.io. If that is of interest to you, I can look into providing an activestorage adapter for sqlite3.
Just be aware that what I described in the paragraph above is either in beta or future work. If this is of interest, I’d be glad to work through this with you.