f0rest8
Probably silly question with file or paths deploying to Fly.io
Where is the server’s priv folder on Fly? I’m having trouble finding a file that I hope is being copied correctly during deployment.
For more context, for Metamorphic’s passphrase generator it uses the eff_large_wordlist.txt and subsequent strategy.
The GenServer for this is started in the Application:
...
# Start the word retrieval GenServer API for password generator.
{Metamorphic.Extensions.PasswordGenerator.WordRepository, %{}},
...
Then, there’s a WordLoader file that calls:
# I've also used Application.app_dir(@otp_app, "/priv/dict/eff_large_wordlist.txt")
# with success locally.
@word_list_contents File.stream!(
Path.join(:code.priv_dir(@otp_app), "/dict/eff_large_wordlist.txt")
)
This worked great in deployment with Render and locally. When deploying to Fly I run into the enoent error and that it was looking for the file at /app/_build/prod/lib/<@otp_app>/priv/dict/eff_large_wordlist.txt.
In the Docker file it runs the command COPY priv priv.
My local file structure root priv directory looks like /home/user/github/name/priv.
I’m not super familiar with Docker, but my understanding is that COPY priv priv is copying all the files in my priv folder over to a priv folder for the server on Fly. Is it copying the folder structure? I’ve used both Application.app_dir/2 and :code.priv_dir/1 and both work except for deployment to Fly (which my thinking is because I’m either not copying the file over and/or not finding it correctly).
Thanks for any help ![]()
Marked As Solved
tj0
So in my production deploy, it is in:
/app/lib/my_app-1.0/priv
The rest of libraries also have a priv directory.
I’m accessing that directory via:
app = Mix.Project.config[:app]
path = :filename.join(:code.priv_dir(unquote(app)), 'the_file')
It seems you’ve already tried these though, so I’m not sure exactly what you’re missing.
I’d suggest logging in via ssh and checking if the file exists on disk.
$ fly ssh console -a your_app
``
Also Liked
LostKobrakai
Make sure you run that code at runtime and not compile time.
f0rest8
Thank you! I should have ssh’d in and checked. That revealed that it was in the same location as yours.
/app/lib/my_app-version/priv/dict/eff_large_wordlist.txt
This works for me:
otp_app = Mix.Project.config()[:app]
version = Mix.Project.config()[:version]
if Mix.env() in [:prod] do
@word_list_contents File.stream!(
"/app/lib/#{otp_app}-#{version}/priv/dict/eff_large_wordlist.txt"
)
else
@word_list_contents File.stream!(
Path.join(:code.priv_dir(otp_app), "/dict/eff_large_wordlist.txt")
)
end
tj0
The docker file is using mix release by default and it works for me, so I don’t think it’s that. Anyway, definitely an odd one.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









