f0rest8

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 :blush:

Marked As Solved

tj0

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

LostKobrakai

Make sure you run that code at runtime and not compile time.

f0rest8

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

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.

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement