How to combine mounts and statics

I’m trying to store user uploaded content in mounted volume and expose it using statics. However it doesn’t seem to be working and I don’t know how to debug it. What should I try or look into? Thank you!



  guest_path = "/workspace/media"
  url_prefix = "/media"

request resulting in 404

➜  ~ curl -i
HTTP/2 404
content-length: 179
content-type: text/html
cross-origin-opener-policy: same-origin
date: Mon, 14 Feb 2022 10:27:03 GMT
referrer-policy: same-origin
server: Fly/36a8cd76 (2022-02-11)
x-content-type-options: nosniff
x-frame-options: DENY
fly-cache-status: MISS
via: 2
fly-request-id: 01FVVWB0R6ZE4FTBFE0MKN9A3H

ls showing the file present

➜  screenhelp git:(main) ✗ flyctl ssh console
Update available 0.0.295 -> v0.0.297.
Run "flyctl version update" to upgrade.
Connecting to top1.nearest.of.screenchat.internal... complete
# ls /media
# ls /workspace/media
lost+found  recordings
# ^[[A      : not found
# in/sh: 3:
# ls /workspace/media/recordings

I believe this is not working because statics must exist in the Docker image. This feature was really designed to deliver things like application CSS/JS assets - not uploaded files, etc.

Aha, thanks for the explanation. Do you have any tips on how to host files stored in the volume?

What framework are you using? Most modern runtimes (meaning, not Ruby + Rails) do a great job delivering static files at scale. Your framework might have a statics middleware that just does this for you. Even Rails is fine for this at normal application volumes.

You can run nginx in your VMs if you’re on something like Rails and need thousands of static file requests per second.

I’m using Django. Because I’m not expecting huge traffic overnight I decided to just serve files in python and put CloudFlare CDN in front of it. Should be fine for now.