I’m deploying a Phoenix app with Mix releases. I’d like to access a static file, stored in the priv/
directory, during runtime.
When I enter the running app, I can see the following directory structure:
iex(backend@5714fba14b09)10> File.ls()
{:ok, ["lib", "tmp", "bin", "erts-10.4.4", "releases", "Procfile"]}
If I want to access anything in priv
, I have to use the full path lib/backend-2.2.0/priv/.../myfile.json
(for example). I could write code to generate this path based on the version and app name but that seems fragile – is there a better way? I tried looking into how Ecto does this for migrations, but with no luck!