processone / ejabberd-contrib

Growing and curated ejabberd contributions repository - PR or ask to join !

Home Page:http://ejabberd.im

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The dependency library doesn't exist in the docker image (cuesport library for ejabberd_auth_http module)

kacperjurak opened this issue · comments

Hi, I use ejabberd in docker-compose.yml (at M1 Mac but I think this doesn't matter):

 ejabberd:
    image: ghcr.io/processone/ejabberd
    ...

When I install ejabberd_auth_http module and change ejabberd.yml config file to:

auth_method: http
auth_opts:
  host: "http://localhost:12000"

ejabberd stops working. For example, when I try to refresh admin page at web GUI I'm getting an error (full error at the end):

2023-11-04 18:10:42.636646+00:00 [info] (<0.997.0>) Accepted connection [::ffff:192.168.65.1]:45126 -> [::ffff:172.21.0.3]:5280
2023-11-04 18:10:44.712044+00:00 [error] HTTP handler crashed: exception error: undefined function cuesport:get_worker/1
   in function  ejabberd_auth_http:make_req/5 (/opt/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl, line 213)

It looks like the library cuesport, which is a dependency for an ejabberd_auth_http module is not present in the docker build. I think ejabberdctl module_install must be broken in this docker image because there's no way to compile a dependency library while running Alpine Linux (without any compile tools).

Full error below:

2023-11-04 18:10:42.636646+00:00 [info] (<0.997.0>) Accepted connection [::ffff:192.168.65.1]:45126 -> [::ffff:172.21.0.3]:5280
2023-11-04 18:10:44.712044+00:00 [error] HTTP handler crashed: exception error:
 undefined function cuesport:get_worker/1
   in function  ejabberd_auth_http:make_req/5 (/opt/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl, line 213)
   in call from ejabberd_auth_http:check_password/4 (/opt/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl, line 64)
   in call from ejabberd_auth:'-db_check_password/7-fun-0-'/5 (src/ejabberd_auth.erl, line 692)
   in call from ets_cache:update/5 (/home/runner/work/ejabberd/ejabberd/deps/cache_tab/src/ets_cache.erl, line 226)
   in call from ejabberd_auth:db_check_password/7 (src/ejabberd_auth.erl, line 689)
   in call from ejabberd_auth:'-check_password_with_authmodule/6-fun-0-'/8 (src/ejabberd_auth.erl, line 250)
   in call from lists:foldl/3 (lists.erl, line 1594)
...

Hello,

How did you install this extra module? It indeed require couple extra modules that aren't distributed with ejabberd.

Right, problem confirmed.

ejabberdctl module_install ejabberd_auth_http fails in the ejabberd container image: to install the module dependencies, git and make are required, and they aren't available in the container image (neither in ejabberd/ecs nor the ghcr.io/processone/ejabberd container images).


The manual solution is to install the development requirements:

sudo docker exec --user root eja apk add git make

And now in the container:

$ rm -rf .ejabberd-modules
$ ejabberdctl modules_update_specs
$ ejabberdctl module_install ejabberd_auth_http
/opt/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/deps/fusco/src/fusco_lib.erl:273:22: Warning: http_uri:decode/1 is deprecated and will be removed in OTP 27; use uri_string:unquote function instead
%  273|                     {http_uri:decode(User), "", HostPortPath};
%     |                      ^

/opt/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/deps/fusco/src/fusco_lib.erl:275:22: Warning: http_uri:decode/1 is deprecated and will be removed in OTP 27; use uri_string:unquote function instead
%  275|                     {http_uri:decode(User), http_uri:decode(Passwd),
%     |                      ^

/opt/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/deps/fusco/src/fusco_lib.erl:275:45: Warning: http_uri:decode/1 is deprecated and will be removed in OTP 27; use uri_string:unquote function instead
%  275|                     {http_uri:decode(User), http_uri:decode(Passwd),
%     |                                             ^

Module ejabberd_auth_http has been installed.
Now you can configure it in your ejabberd.yml

A definitive solution could be to include those packages in the container image (increasing the image size from 45 to 54 MB):

diff --git a/.github/container/Dockerfile b/.github/container/Dockerfile
index 94a9422f2..fa65931d4 100644
--- a/.github/container/Dockerfile
+++ b/.github/container/Dockerfile
@@ -158,6 +158,8 @@ RUN apk -U upgrade --available --no-cache \
         $(cat /tmp/runDeps) \
         so:libcap.so.2 \
         so:libtdsodbc.so.0 \
+        git \
+        make \
         tini \
     && ln -fs /usr/lib/libtdsodbc.so.0 /usr/lib/libtdsodbc.so

After regenerating the image, running a new container and setting this in ejabberd.yml, it starts correctly:

install_contrib_modules:
  - ejabberd_auth_http

auth_method: http
auth_opts:
  host: "http://localhost:12000"

Hello, I am not intending to compete with the official image, however, for https://github.com/sando38/helm-ejabberd I use a custom image which includes the ejabberd_auth_http module:

version: '3'

services:
  ejabberd:
    image: ghcr.io/sando38/ejabberd:23.10-k8s3
    command: >
      sh -c "ejabberdctl foreground"
    environment:
      - ERLANG_NODE_ARG=ejabberd@localhost

Note: command and environment are required to simulate the behavior of the official image.

Update: I just saw you use a M1 (ARM64). The referenced image above is only built for (x86-64).