Argon2 module not loading in docker build
Description
When trying to register, when calculating the hash with the argon2_elixir module, this fails (when building with docker-compose.yml).
Steps to Reproduce
- docker-compose up
- Navigate to register page
- Submit Register form and check error in the phoenix logs
Expected behaviour:
Query OK and register.
Actual behaviour:
Does not send activation link and error displayed in logs:
api_1 | [info] POST /api
api_1 | [debug] Processing with Absinthe.Plug
api_1 | Parameters: %{"operationName" => "CreateUser", "query" => "mutation CreateUser($email: String!, $password: String!) {\n createUser(email: $email, password: $password) {\n email\n confirmationSentAt\n __typename\n }\n}\n", "variables" => %{"email" => "lucas@pomme.com", "password" => "[FILTERED]"}}
api_1 | Pipelines: [:graphql]
api_1 | [debug] ABSINTHE schema=MobilizonWeb.Schema variables=%{"email" => "lucas@pomme.com", "password" => "[FILTERED]"}
api_1 | ---
api_1 | mutation CreateUser($email: String!, $password: String!) {
api_1 | createUser(email: $email, password: $password) {
api_1 | email
api_1 | confirmationSentAt
api_1 | __typename
api_1 | }
api_1 | }
api_1 | ---
api_1 | [error] Process #PID<0.2202.0> raised an exception
api_1 | ** (RuntimeError) An error occurred when loading Argon2.
api_1 | Make sure you have a C compiler and Erlang 20 installed.
api_1 | If you are not using Erlang 20, either upgrade to Erlang 20 or
api_1 | use bcrypt_elixir (version 0.12) or pbkdf2_elixir.
api_1 | See the Comeonin wiki for more information.
api_1 |
api_1 | (argon2_elixir) lib/argon2/base.ex:19: Argon2.Base.init/0
api_1 | (kernel) code_server.erl:1340: anonymous fn/1 in :code_server.handle_on_load/5
api_1 | [warn] The on_load function for module Elixir.Argon2.Base returned:
api_1 | {%RuntimeError{message: "An error occurred when loading Argon2.\nMake sure you have a C compiler and Erlang 20 installed.\nIf you are not using Erlang 20, either upgrade to Erlang 20 or\nuse bcrypt_elixir (version 0.12) or pbkdf2_elixir.\nSee the Comeonin wiki for more information.\n"}, [{Argon2.Base, :init, 0, [file: 'lib/argon2/base.ex', line: 19]}, {:code_server, :"-handle_on_load/5-fun-0-", 1, [file: 'code_server.erl', line: 1340]}]}
api_1 |
api_1 | [error] Process #PID<0.2204.0> raised an exception
api_1 | ** (RuntimeError) An error occurred when loading Argon2.
api_1 | Make sure you have a C compiler and Erlang 20 installed.
api_1 | If you are not using Erlang 20, either upgrade to Erlang 20 or
api_1 | use bcrypt_elixir (version 0.12) or pbkdf2_elixir.
api_1 | See the Comeonin wiki for more information.
api_1 |
api_1 | (argon2_elixir) lib/argon2/base.ex:19: Argon2.Base.init/0
api_1 | (kernel) code_server.erl:1340: anonymous fn/1 in :code_server.handle_on_load/5
api_1 | [warn] The on_load function for module Elixir.Argon2.Base returned:
api_1 | {%RuntimeError{message: "An error occurred when loading Argon2.\nMake sure you have a C compiler and Erlang 20 installed.\nIf you are not using Erlang 20, either upgrade to Erlang 20 or\nuse bcrypt_elixir (version 0.12) or pbkdf2_elixir.\nSee the Comeonin wiki for more information.\n"}, [{Argon2.Base, :init, 0, [file: 'lib/argon2/base.ex', line: 19]}, {:code_server, :"-handle_on_load/5-fun-0-", 1, [file: 'code_server.erl', line: 1340]}]}
api_1 |
api_1 | [info] Sent 500 in 3274ms
api_1 | [error] #PID<0.2200.0> running MobilizonWeb.Endpoint (connection #PID<0.2199.0>, stream id 1) terminated
api_1 | Server: 0.0.0.0:4000 (http)
api_1 | Request: POST /api
api_1 | ** (exit) an exception was raised:
api_1 | ** (UndefinedFunctionError) function Argon2.Base.hash_password/3 is undefined (module Argon2.Base is not available)
api_1 | (argon2_elixir) Argon2.Base.hash_password("pommepomme", <<170, 147, 46, 18, 233, 214, 229, 203, 159, 80, 178, 186, 22, 236, 241, 212>>, [])
api_1 | (mobilizon) lib/mobilizon/users/user.ex:192: Mobilizon.Users.User.hash_password/1
api_1 | (mobilizon) lib/mobilizon/users/user.ex:98: Mobilizon.Users.User.registration_changeset/2
api_1 | (mobilizon) lib/mobilizon/users/users.ex:30: Mobilizon.Users.register/1
api_1 | (mobilizon) lib/mobilizon_web/resolvers/user.ex:118: MobilizonWeb.Resolvers.User.create_user/3
api_1 | (mobilizon) lib/mobilizon_web/schema/utils.ex:8: anonymous fn/4 in MobilizonWeb.Schema.Utils.handle_errors/1
api_1 | (absinthe) lib/absinthe/resolution.ex:209: Absinthe.Resolution.call/2
api_1 | (absinthe) lib/absinthe/phase/document/execution/resolution.ex:209: Absinthe.Phase.Document.Execution.Resolution.reduce_resolution/1
api_1 | (absinthe) lib/absinthe/phase/document/execution/resolution.ex:168: Absinthe.Phase.Document.Execution.Resolution.do_resolve_field/4
api_1 | (absinthe) lib/absinthe/phase/document/execution/resolution.ex:153: Absinthe.Phase.Document.Execution.Resolution.do_resolve_fields/6
api_1 | (absinthe) lib/absinthe/phase/document/execution/resolution.ex:72: Absinthe.Phase.Document.Execution.Resolution.walk_result/5
api_1 | (absinthe) lib/absinthe/phase/document/execution/resolution.ex:53: Absinthe.Phase.Document.Execution.Resolution.perform_resolution/3
api_1 | (absinthe) lib/absinthe/phase/document/execution/resolution.ex:24: Absinthe.Phase.Document.Execution.Resolution.resolve_current/3
api_1 | (absinthe) lib/absinthe/pipeline.ex:274: Absinthe.Pipeline.run_phase/3
api_1 | (absinthe_plug) lib/absinthe/plug.ex:421: Absinthe.Plug.run_query/4
api_1 | (absinthe_plug) lib/absinthe/plug.ex:247: Absinthe.Plug.call/2
api_1 | (phoenix) lib/phoenix/router/route.ex:40: Phoenix.Router.Route.call/2
api_1 | (phoenix) lib/phoenix/router.ex:288: Phoenix.Router.__call__/2
api_1 | (mobilizon) lib/mobilizon_web/endpoint.ex:1: MobilizonWeb.Endpoint.plug_builder_call/2
api_1 | (mobilizon) lib/plug/debugger.ex:122: MobilizonWeb.Endpoint."call (overridable 3)"/2
Reproduces how often:
100%
Versions
Last branch (3a133b94) on macOS with Docker
Additional Information
I tried a fork w/ the bcrypt_elixir library and it works: https://framagit.org/lucaskev/mobilizon/commit/11e5ac0ce02ecc3783fc741c53d7662bb87cf896 It vaguely looks more standard/stable and I could not find pertinent stuff on this weird bug: https://elixirforum.com/t/understanding-my-current-docker-setup-trying-to-use-argon2/19622 It may be due to building stuff in C in Docker on Alpine Linux... or not.
Edited by Thomas