NobbZ

NobbZ

When I build your container, this is what I see:

Step 8/10 : RUN mix deps.get
 ---> Running in 38022be2ebe1
** (Mix.Config.LoadError) could not load config config/config.exs
    ** (SyntaxError) config/config.exs:24: syntax error before: config
    (elixir) lib/code.ex:192: Code.eval_string/3
    (mix) lib/mix/config.ex:188: Mix.Config.read!/2
    (mix) lib/mix/tasks/loadconfig.ex:37: Mix.Tasks.Loadconfig.load/1
    (mix) lib/mix/tasks/loadconfig.ex:27: Mix.Tasks.Loadconfig.run/1
    (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2

So my assumption is, that you happily changed around in your Dockerfile, but never rebuilt the container.

0
Post #12
sc4224

sc4224 OP

If I hardcode the secret key for Guardian in config.exs, this is not an error, so no, this has nothing to do with the dockerfile. I don’t know what is it I changed, nothing has changed in my dockerfile at all

0
Post #13
NobbZ

NobbZ

The trailing , is an error. If the compiler tells you that there is an error, then you can’t argue!

I removed that trailing comma, rebuilt the container, docker run -it genesis iex -S mix into it, ignored a bunch of error messages related to unavailable dependencies, got into iex and did this:

iex(1)> Comeonin.Bcrypt.hashpwsalt("Foo")
"$2b$12$ZvbuL.cQ.8RklUhAjBO2../NXRJ4heFp2lPafeX2Ue1DrkEbUfwAG"

So: Works on my machine

0
Post #14
sc4224

sc4224 OP

So after I removed that comma, everything builds, and I was able to do docker-compose up. Now the problem still remains:

phoenix_1  |     ** (UndefinedFunctionError) function Bcrypt.Base.gensalt_nif/3 is undefined (module Bcrypt.Base is not available)
phoenix_1  |         (bcrypt_elixir) Bcrypt.Base.gensalt_nif([218, 167, 96, 212, 228, 19, 3, 128, 160, 226, 183, 148, 194, 74, 214, 34], 12, 98)
phoenix_1  |         (bcrypt_elixir) lib/bcrypt.ex:52: Bcrypt.gen_salt/2
phoenix_1  |         (bcrypt_elixir) lib/bcrypt.ex:88: Bcrypt.hash_pwd_salt/2
phoenix_1  |         (my_app) lib/my_app/accounts/user.ex:63: MyApp.Accounts.User.put_pass_hash/1
phoenix_1  |         (my_app) lib/my_app/accounts/accounts.ex:74: MyApp.Accounts.update_user/2

This happens here in this function:

  defp put_pass_hash(changeset) do
    case changeset do
      %Ecto.Changeset{valid?: true, changes: %{password: password}} ->
        IO.puts(password)

        put_change(changeset, :password_hash, Comeonin.Bcrypt.hashpwsalt(password))

      _ ->
        changeset
    end
  end

I don’t know why this keeps happening, where is gensalt getting called?

I did as instructed, deleted deps, deleted _build, in my .dockerignore file I specified to ignore ./my_app/deps and ./my_app/_build

0
Post #15
NobbZ

NobbZ

Please do docker system prune to delete all containers that are not currently running or referenced by running containers (before that, make sure using docker ps and docker stop that no containers related to your application are running).

Then start from scratch using docker-compose build, after that has finished, try again to start your containers as you are used to it.

As it works for me after a pristine clone of your application, I have to assume, that there is something weird in the caches failing your builds.

0
Post #16
NobbZ

NobbZ

I took a closer look again, this time into the docker compose file. You are using a volume, pulling all your local stuff into the container shadowing the stuff in the container. This won’t work. Please remove the volume.

1
Post #18
sc4224

sc4224 OP

So I tried docker run -it genesys_phoenix iex -S mix and i see the errors but I ignored them and ran Comeonin.Bcrypt.hashpwsalt("Foo") in the shell. It works. But I have no idea why it doesn’t work in the application when I call the function in the user context

0
Post #19
sc4224

sc4224 OP

Just remove the volume and run docker-compose up again?

0
Post #20
sc4224

sc4224 OP

Ok this works, now my question is probably a fundamental one, but I also never understood. What am I actually doing with volumes in this case. Was this a bind mount or a named volume. From what I understand, it is a bind mount. But I don’t understand when I should and shouldn’t use it

0
Post #21
NobbZ

NobbZ

Yeah, that should do it.

0
Post #22