Skip to content

is not posible to build docker ejabberd ecs on MacOS ? #124

Open

Description

@hvar90

hi

i tried to build ecs on my Mac

i wrote

sudo ./build.sh 25.03

this is my build.sh

#!/bin/sh

current=$(date +%y.%m)
version=${1:-$current}

docker build \
    --build-arg VERSION=$version \
    --build-arg VCS_REF=`git rev-parse --short HEAD` \
    --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
    -t ejabberd/ecs:$version --platform linux/amd64  .

[ "$version" = "latest" ] || docker tag ejabberd/ecs:$version ejabberd/ecs:latest

i got this error message

11:50:23.723 [notice] Application hex exited: exited in: Hex.Application.start(:normal, [])
10.95     ** (EXIT) an exception was raised:
10.95         ** (MatchError) no match of right hand side value: 105
10.95             (elixir 1.15.7) src/elixir_def.erl:134: :elixir_def.store_definition/3
10.95             (mix 1.15.7) Mix.RemoteConverger.behaviour_info/1
10.95             (kernel 9.2) application_master.erl:293: :application_master.start_it_old/4
10.97 
10.97 11:50:23.939 [notice] Application inets exited: :stopped
10.98 
10.98 11:50:23.949 [notice] Application ssl exited: :stopped
10.98 
10.98 11:50:23.949 [notice] Application public_key exited: :stopped
10.98 
10.98 11:50:23.949 [notice] Application asn1 exited: :stopped
10.99 
10.99 11:50:23.950 [notice] Application crypto exited: :stopped
11.00 Could not start Hex. Try fetching a new version with "mix local.hex" or uninstalling it with "mix archive.uninstall hex.ez"
11.01 ** (MatchError) no match of right hand side value: {:error, {:hex, {:bad_return, {{Hex.Application, :start, [:normal, []]}, {:EXIT, {{:badmatch, 105}, [{:elixir_def, :store_definition, 3, [file: ~c"src/elixir_def.erl", line: 134]}, {Mix.RemoteConverger, :behaviour_info, 1, []}, {:application_master, :start_it_old, 4, [file: ~c"application_master.erl", line: 293]}]}}}}}}
11.01     (hex 2.1.1) lib/hex.ex:5: Hex.start/0
11.01     (mix 1.15.7) lib/mix/hex.ex:60: Mix.Hex.start/0
11.01     (mix 1.15.7) lib/mix/dep/loader.ex:189: Mix.Dep.Loader.with_scm_and_app/5
11.01     (mix 1.15.7) lib/mix/dep/loader.ex:141: Mix.Dep.Loader.to_dep/4
11.01     (elixir 1.15.7) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
11.01     (mix 1.15.7) lib/mix/dep/loader.ex:364: Mix.Dep.Loader.mix_children/3
11.01     (mix 1.15.7) lib/mix/dep/loader.ex:18: Mix.Dep.Loader.children/1
11.01     (mix 1.15.7) lib/mix/dep/converger.ex:97: Mix.Dep.Converger.all/4
------

 4 warnings found (use docker --debug to expand):
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 125)
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 126)
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 127)
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 128)
Dockerfile:19
--------------------
  18 |     COPY rel/*exs rel/
  19 | >>> RUN git checkout ${VERSION/latest/HEAD} \
  20 | >>>     \
  21 | >>>     && if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then \
  22 | >>>         echo '{vsn, "'"$VERSION.0"'"}.' >> vars.config; \
  23 | >>>     else \
  24 | >>>         echo '{vsn, "0.0.0"}.' >> vars.config; \
  25 | >>>     fi \
  26 | >>>     \
  27 | >>>     && mix deps.get \
  28 | >>>     && (cd deps/eimp; ./configure)
  29 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c git checkout ${VERSION/latest/HEAD}         && if [[ \"$VERSION\" =~ ^[0-9]+\\.[0-9]+$ ]]; then         echo '{vsn, \"'\"$VERSION.0\"'\"}.' >> vars.config;     else         echo '{vsn, \"0.0.0\"}.' >> vars.config;     fi         && mix deps.get     && (cd deps/eimp; ./configure)" did not complete successfully: exit code: 1
Error response from daemon: No such image: ejabberd/ecs:25.03

but when i do the same on linux ubuntu i can build ecs successfully

so my question is if building ecs on Mac is not possible?

this is my Dockerfile

FROM docker.io/golang:1.22-alpine AS api
RUN go install -v \
    github.com/processone/ejabberd-api/cmd/ejabberd@latest \
    && mv bin/ejabberd bin/ejabberdapi

FROM docker.io/ejabberd/mix AS builder
ARG VERSION
ENV VERSION=${VERSION:-latest} \
    MIX_ENV=prod
LABEL maintainer="ProcessOne <contact@process-one.net>" \
    product="Ejabberd Community Server builder"

# Get ejabberd sources, dependencies, configuration
RUN git clone https://github.com/processone/ejabberd.git
WORKDIR /ejabberd
COPY vars.config .
COPY config.exs config/
COPY rel/*exs rel/
RUN git checkout ${VERSION/latest/HEAD} \
    \
    && if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then \
        echo '{vsn, "'"$VERSION.0"'"}.' >> vars.config; \
    else \
        echo '{vsn, "0.0.0"}.' >> vars.config; \
    fi \
    \
    && mix deps.get \
    && (cd deps/eimp; ./configure)

# Compile
RUN MIX_ENV=prod mix release

# Prepare runtime environment
RUN mkdir runtime \
    && tar -C runtime -zxf _build/prod/ejabberd-*.tar.gz \
    && cd runtime \
    && cp releases/*/start.boot bin \
    && cp releases/*/start_clean.boot bin \
    && echo 'beam_lib:strip_files(filelib:wildcard("lib/*/ebin/*beam")), init:stop().' | erl >/dev/null \
    && mv erts*/bin/* bin \
    && EJABBERD_VERSION=`(cd releases; ls -1 -d *.*.*)` \
    && rm -rf releases erts* bin/*src bin/dialyzer bin/typer etc \
    && rm bin/ejabberd \
    && mkdir lib/ejabberd-$EJABBERD_VERSION/priv/bin \
    && cp /usr/lib/elixir/bin/* bin/ \
    && sed -i 's|ERL_EXEC="erl"|ERL_EXEC="/home/ejabberd/bin/erl"|' bin/elixir \
    && cp /ejabberd/tools/captcha*sh bin/ \
    && cp -r /ejabberd/sql lib/ejabberd-*/priv

# Runtime container
FROM docker.io/alpine:3.19
ARG VERSION
ARG VCS_REF
ARG BUILD_DATE
ENV TERM=xterm \
    LC_ALL=C.UTF-8 \
    LANG=en_US.UTF-8 \
    LANGUAGE=en_US.UTF-8 \
    REPLACE_OS_VARS=true \
    HOME=/home/ejabberd \
    PATH="$PATH:/home/ejabberd/bin" \
    VERSION=${VERSION:-latest}
LABEL maintainer="ProcessOne <contact@process-one.net>" \
    product="Ejabberd Community Server Official Docker Image" \
    version=$VERSION \
    org.label-schema.vcs-ref=$VCS_REF \
    org.label-schema.vcs-url="https://github.com/processone/docker-ejabberd" \
    org.label-schema.build-date=$BUILD_DATE \
    org.label-schema.name="Ejabberd Community Server Official Docker Image" \
    org.label-schema.description="Robust, Scalable and Extensible Realtime Server using XMPP, MQTT and SIP" \
    org.label-schema.url="https://www.ejabberd.im/" \
    org.label-schema.vendor="ProcessOne" \
    org.label-schema.version=$VERSION \
    org.label-schema.schema-version="1.0"

# Create directory structure and user for ejabberd
RUN addgroup ejabberd -g 9000 \
    && adduser -s /bin/sh -D -G ejabberd ejabberd -u 9000 \
    && mkdir -p /home/ejabberd/conf /home/ejabberd/database /home/ejabberd/logs /home/ejabberd/upload \
    && chown -R ejabberd:ejabberd /home/ejabberd \
    && ln -fs /home/ejabberd /opt/ejabberd \
    && ln -fs /home/ejabberd /opt/ejabberd-$VERSION

# Install required dependencies
RUN apk upgrade --update-cache --no-progress \
    && apk add \
    expat \
    freetds \
    gd \
    jpeg \
    libgd \
    libpng \
    libstdc++ \
    libwebp \
    ncurses-libs \
    openssl \
    sqlite \
    sqlite-libs \
    tini \
    unixodbc \
    yaml \
    zlib \
    && ln -fs /usr/lib/libtdsodbc.so.0 /usr/lib/libtdsodbc.so \
    && rm -rf /var/cache/apk/*

# Install ejabberd

WORKDIR $HOME
COPY --from=builder /ejabberd/runtime .
COPY bin/* bin/
COPY --from=api /go/bin/ejabberdapi bin/ejabberdapi
RUN chmod 755 bin/ejabberdctl bin/ejabberdapi bin/erl bin/captcha*.sh \
    && mkdir -p /home/ejabberd/sql \
    && cp /home/ejabberd/lib/ejabberd-*/priv/sql/* /home/ejabberd/database/ \
    && cp /home/ejabberd/lib/ejabberd-*/priv/sql/* /home/ejabberd/sql/
COPY --chown=ejabberd:ejabberd conf conf/
ADD --chown=ejabberd:ejabberd https://download.process-one.net/cacert.pem conf/cacert.pem

# Setup runtime environment
.............more configurations .......................

Activity

  1. badlop commented on Apr 23, 2025

    @badlop
    Member

    Quite strange that you can build in linux and the exact same files fail in Mac.

    11:50:23.723 [notice] Application hex exited: exited in: Hex.Application.start(:normal, [])
    10.95     ** (EXIT) an exception was raised:
    10.95         ** (MatchError) no match of right hand side value: 105
    10.95             (elixir 1.15.7) src/elixir_def.erl:134: :elixir_def.store_definition/3
    10.95             (mix 1.15.7) Mix.RemoteConverger.behaviour_info/1
    10.95             (kernel 9.2) application_master.erl:293: :application_master.start_it_old/4
    

    That is the first error message, the one that triggers all the other errors. Maybe there's some problem in elixir 1.15.7 specific to Mac?

    I guess if you use an alpine image newer than 3.19, it will use an elixir newer than 1.15.7, just to see if the problem disappears.

    Alternatively, you can try building the ejabberd container image instead of the ecs image. The usage of both images is almost identical, but their build methods are different, and the included versions are different.

  2. hvar90 commented on Apr 23, 2025

    @hvar90
    Author

    i changed to docker.io/golang:1.24.2-alpine AS api
    and docker.io/alpine:3.21.3
    i am using the latest version of alpine
    https://hub.docker.com/_/alpine

    but it is using elixir 1.15.7 still and i get the same error message

    15:30:37.370 [notice] Application hex exited: exited in: Hex.Application.start(:normal, [])
    7.109     ** (EXIT) an exception was raised:
    7.109         ** (MatchError) no match of right hand side value: 105
    7.109             (elixir 1.15.7) src/elixir_def.erl:134: :elixir_def.store_definition/3
    7.109             (mix 1.15.7) Mix.RemoteConverger.behaviour_info/1
    7.109             (kernel 9.2) application_master.erl:293: :application_master.start_it_old/4
    7.119 
    7.119 15:30:37.530 [notice] Application inets exited: :stopped
    7.130 
    7.130 15:30:37.541 [notice] Application ssl exited: :stopped
    7.139 
    7.139 15:30:37.542 [notice] Application public_key exited: :stopped
    7.144 
    7.144 15:30:37.542 [notice] Application asn1 exited: :stopped
    7.144 
    7.144 15:30:37.543 [notice] Application crypto exited: :stopped
    7.162 Could not start Hex. Try fetching a new version with "mix local.hex" or uninstalling it with "mix archive.uninstall hex.ez"
    7.182 ** (MatchError) no match of right hand side value: {:error, {:hex, {:bad_return, {{Hex.Application, :start, [:normal, []]}, {:EXIT, {{:badmatch, 105}, [{:elixir_def, :store_definition, 3, [file: ~c"src/elixir_def.erl", line: 134]}, {Mix.RemoteConverger, :behaviour_info, 1, []}, {:application_master, :start_it_old, 4, [file: ~c"application_master.erl", line: 293]}]}}}}}}
    7.182     (hex 2.1.1) lib/hex.ex:5: Hex.start/0
    7.182     (mix 1.15.7) lib/mix/hex.ex:60: Mix.Hex.start/0
    7.182     (mix 1.15.7) lib/mix/dep/loader.ex:189: Mix.Dep.Loader.with_scm_and_app/5
    7.182     (mix 1.15.7) lib/mix/dep/loader.ex:141: Mix.Dep.Loader.to_dep/4
    7.182     (elixir 1.15.7) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
    7.182     (mix 1.15.7) lib/mix/dep/loader.ex:364: Mix.Dep.Loader.mix_children/3
    7.182     (mix 1.15.7) lib/mix/dep/loader.ex:18: Mix.Dep.Loader.children/1
    7.182     (mix 1.15.7) lib/mix/dep/converger.ex:97: Mix.Dep.Converger.all/4
    

    i found some people had similar errors on mac
    do you think there is a relation with my problem?
    https://stackoverflow.com/questions/45764045/trouble-installing-elixir-1-5-on-osx
    http://github.com/elixir-lang/elixir/issues/9932

    i tried this method

    sudo docker buildx build \
        -t personal/ejabberd \
        -f Dockerfile \ 
        --platform linux/amd64  .
    

    as ejabberd container image said

    but i got the same error

    15:30:37.370 [notice] Application hex exited: exited in: Hex.Application.start(:normal, [])
    7.109     ** (EXIT) an exception was raised:
    7.109         ** (MatchError) no match of right hand side value: 105
    7.109             (elixir 1.15.7) src/elixir_def.erl:134: :elixir_def.store_definition/3
    7.109             (mix 1.15.7) Mix.RemoteConverger.behaviour_info/1
    7.109             (kernel 9.2) application_master.erl:293: :application_master.start_it_old/4
    7.119 
    7.119 15:30:37.530 [notice] Application inets exited: :stopped
    7.130 
    7.130 15:30:37.541 [notice] Application ssl exited: :stopped
    7.139 
    7.139 15:30:37.542 [notice] Application public_key exited: :stopped
    7.144 
    7.144 15:30:37.542 [notice] Application asn1 exited: :stopped
    7.144 
    7.144 15:30:37.543 [notice] Application crypto exited: :stopped
    7.162 Could not start Hex. Try fetching a new version with "mix local.hex" or uninstalling it with "mix archive.uninstall hex.ez"
    7.182 ** (MatchError) no match of right hand side value: {:error, {:hex, {:bad_return, {{Hex.Application, :start, [:normal, []]}, {:EXIT, {{:badmatch, 105}, [{:elixir_def, :store_definition, 3, [file: ~c"src/elixir_def.erl", line: 134]}, {Mix.RemoteConverger, :behaviour_info, 1, []}, {:application_master, :start_it_old, 4, [file: ~c"application_master.erl", line: 293]}]}}}}}}
    7.182     (hex 2.1.1) lib/hex.ex:5: Hex.start/0
    7.182     (mix 1.15.7) lib/mix/hex.ex:60: Mix.Hex.start/0
    7.182     (mix 1.15.7) lib/mix/dep/loader.ex:189: Mix.Dep.Loader.with_scm_and_app/5
    7.182     (mix 1.15.7) lib/mix/dep/loader.ex:141: Mix.Dep.Loader.to_dep/4
    7.182     (elixir 1.15.7) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
    7.182     (mix 1.15.7) lib/mix/dep/loader.ex:364: Mix.Dep.Loader.mix_children/3
    7.182     (mix 1.15.7) lib/mix/dep/loader.ex:18: Mix.Dep.Loader.children/1
    7.182     (mix 1.15.7) lib/mix/dep/converger.ex:97: Mix.Dep.Converger.all/4
    
  3. hvar90 commented on Mar 7, 2026

    @hvar90
    Author

    Hi again, i downloaded the last version of this github and the previous error I had is now fixed, maybe it got fixed thanks to this fix #125, but now another error occurs later in the building

     => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                   0.0s
     => => transferring dockerfile: 4.96kB                                                                                                                                                                                                                                                                                 0.0s
     => [internal] load metadata for docker.io/library/alpine:3.22                                                                                                                                                                                                                                                         0.9s
     => [internal] load metadata for docker.io/ejabberd/mix:latest                                                                                                                                                                                                                                                         0.8s
     => [internal] load metadata for docker.io/library/golang:1.25-alpine                                                                                                                                                                                                                                                  0.8s
     => [internal] load .dockerignore                                                                                                                                                                                                                                                                                      0.0s
     => => transferring context: 2B                                                                                                                                                                                                                                                                                        0.0s
     => [builder 1/9] FROM docker.io/ejabberd/mix:latest@sha256:84356e4ff41d735babc8e5be1f4d70aa8471485f4e744b86fa369638776cd809                                                                                                                                                                                           0.0s
     => => resolve docker.io/ejabberd/mix:latest@sha256:84356e4ff41d735babc8e5be1f4d70aa8471485f4e744b86fa369638776cd809                                                                                                                                                                                                   0.0s
     => [stage-2  1/10] FROM docker.io/library/alpine:3.22@sha256:55ae5d250caebc548793f321534bc6a8ef1d116f334f18f4ada1b2daad3251b2                                                                                                                                                                                         0.0s
     => => resolve docker.io/library/alpine:3.22@sha256:55ae5d250caebc548793f321534bc6a8ef1d116f334f18f4ada1b2daad3251b2                                                                                                                                                                                                   0.0s
     => [internal] load build context                                                                                                                                                                                                                                                                                      0.0s
     => => transferring context: 2.29kB                                                                                                                                                                                                                                                                                    0.0s
     => CACHED [stage-2 10/10] ADD --chown=ejabberd:ejabberd https://download.process-one.net/cacert.pem conf/cacert.pem                                                                                                                                                                                                   0.6s
     => [api 1/2] FROM docker.io/library/golang:1.25-alpine@sha256:8e02eb337d9e0ea459e041f1ee5eece41cbb61f1d83e7d883a3e2fb4862063fa                                                                                                                                                                                        0.0s
     => => resolve docker.io/library/golang:1.25-alpine@sha256:8e02eb337d9e0ea459e041f1ee5eece41cbb61f1d83e7d883a3e2fb4862063fa                                                                                                                                                                                            0.0s
     => CACHED [api 2/2] RUN go install -v     github.com/processone/ejabberd-api/cmd/ejabberd@latest     && mv bin/ejabberd bin/ejabberdapi                                                                                                                                                                               0.0s
     => CACHED [stage-2  2/10] RUN addgroup ejabberd -g 9000     && adduser -s /bin/sh -D -G ejabberd ejabberd -u 9000     && mkdir -p /home/ejabberd/conf /home/ejabberd/database /home/ejabberd/logs /home/ejabberd/upload     && chown -R ejabberd:ejabberd /home/ejabberd     && ln -fs /home/ejabberd /opt/ejabberd   0.0s
     => CACHED [stage-2  3/10] RUN apk upgrade --update-cache --no-progress     && apk add     expat     freetds     gd     jpeg     libgd     libpng     libstdc++     libwebp     ncurses-libs     openssl     sqlite     sqlite-libs     tini     unixodbc     yaml     zlib     && ln -fs /usr/lib/libtdsodbc.so.0 /u  0.0s
     => CACHED [stage-2  4/10] WORKDIR /home/ejabberd                                                                                                                                                                                                                                                                      0.0s
     => CACHED [builder 2/9] RUN git clone https://github.com/processone/ejabberd.git                                                                                                                                                                                                                                      0.0s
     => CACHED [builder 3/9] WORKDIR /ejabberd                                                                                                                                                                                                                                                                             0.0s
     => CACHED [builder 4/9] COPY vars.config .                                                                                                                                                                                                                                                                            0.0s
     => CACHED [builder 5/9] COPY config.exs config/                                                                                                                                                                                                                                                                       0.0s
     => CACHED [builder 6/9] COPY rel/*exs rel/                                                                                                                                                                                                                                                                            0.0s
     => CACHED [builder 7/9] RUN git checkout HEAD         && if [[ "latest" =~ ^[0-9]+.[0-9]+$ ]]; then         echo '{vsn, "'"latest.0"'"}.' >> vars.config;     else         echo '{vsn, "0.0.0"}.' >> vars.config;     fi         && mix deps.get --verbose     && (cd deps/eimp; ./configure)                         0.0s
     => [builder 8/9] RUN MIX_ENV=prod mix release --verbose                                                                                                                                                                                             755.8s
     => => # ===> Compiling idna                                                                                                                                                                                                                                                                                               
     => => # ===> Analyzing applications...                                                                                                                                                                                                                                                                                    
     => => # ===> Compiling luerl                                                                                                                                                                                                                                                                                              
     => => # ==> jose                                                                                                                                                                                                                                                                                                          
     => => # Compiling 113 files (.erl)                                                                                                                                                                                                                                                                                        
     => => # qemu: uncaught target signal 11 (Segmentation fault) - core dumped 
    

    but the error does not always occur on the same line, sometimes it happens later

    /ejabberd/deps/xmpp/asn1/XmppAddr.asn1
    #21 292.5 ===> Analyzing applications...
    #21 293.7 ===> Compiling xmpp
    #21 315.3 ===> Fetching pc v1.15.0
    #21 316.9 ===> Analyzing applications...
    #21 317.0 ===> Compiling pc
    #21 318.6 ===> Analyzing applications...
    #21 318.6 ===> Compiling p1_pgsql
    #21 319.8 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
    

    which is strange because I'm running the same files with the same command and the error appears in different places.

    i used this command

    sudo docker buildx build \
        -t personal/ejabberd \
        -f Dockerfile --platform linux/amd64 .
    

    but also i use these other commands

    sudo ./build.sh 25.03
    sudo ./build.sh 25.04
    sudo ./build.sh 25.07
    sudo ./build.sh 25.08
    sudo ./build.sh 25.10
    sudo ./build.sh 26.01
    sudo ./build.sh 26.02
    

    having this build.sh

    #!/bin/sh
    
    current=$(date +%y.%m)
    version=${1:-$current}
    
    docker build \
        --build-arg VERSION=$version \
        --build-arg VCS_REF=`git rev-parse --short HEAD` \
        --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
        -t ejabberd/ecs:$version --progress=plain --platform linux/amd64 .
    
    [ "$version" = "latest" ] || docker tag ejabberd/ecs:$version ejabberd/ecs:latest
    

    i was using QEMU (Legacy) and i tried to change the Virtual Machine Options of Docker
    i selected
    Apple Virtualization framework
    using Rosetta for x86_64/amd64 emulation on Apple Silicon

    but i got the same error

    this is my Dockerfile

    FROM docker.io/golang:1.25-alpine AS api
    RUN go install -v \
        github.com/processone/ejabberd-api/cmd/ejabberd@latest \
        && mv bin/ejabberd bin/ejabberdapi
    
    FROM docker.io/ejabberd/mix AS builder
    ARG VERSION
    ENV VERSION=${VERSION:-latest} \
        MIX_ENV=prod
    LABEL maintainer="ProcessOne <contact@process-one.net>" \
        product="Ejabberd Community Server builder"
    
    # Get ejabberd sources, dependencies, configuration
    RUN git clone https://github.com/processone/ejabberd.git
    WORKDIR /ejabberd
    COPY vars.config .
    COPY config.exs config/
    COPY rel/*exs rel/
    RUN git checkout ${VERSION/latest/HEAD} \
        \
        && if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then \
            echo '{vsn, "'"$VERSION.0"'"}.' >> vars.config; \
        else \
            echo '{vsn, "0.0.0"}.' >> vars.config; \
        fi \
        \
        && mix deps.get --verbose \
        && (cd deps/eimp; ./configure)
    
    # Compile
    RUN MIX_ENV=prod mix release --verbose
    
    # Prepare runtime environment
    RUN mkdir runtime \
        && tar -C runtime -zxf _build/prod/ejabberd-*.tar.gz \
        && cd runtime \
        && cp releases/*/start.boot bin \
        && cp releases/*/start_clean.boot bin \
        && echo 'beam_lib:strip_files(filelib:wildcard("lib/*/ebin/*beam")), init:stop().' | erl >/dev/null \
        && mv erts*/bin/* bin \
        && EJABBERD_VERSION=`(cd releases; ls -1 -d *.*.*)` \
        && rm -rf releases erts* bin/*src bin/dialyzer bin/typer etc \
        && rm bin/ejabberd \
        && mkdir lib/ejabberd-$EJABBERD_VERSION/priv/bin \
        && cp /usr/lib/elixir/bin/* bin/ \
        && sed -i 's|ERL_EXEC="erl"|ERL_EXEC="/home/ejabberd/bin/erl"|' bin/elixir \
        && cp /ejabberd/tools/captcha*sh bin/ \
        && cp -r /ejabberd/sql lib/ejabberd-*/priv
    
    # Runtime container
    FROM docker.io/alpine:3.22
    ARG VERSION
    ARG VCS_REF
    ARG BUILD_DATE
    ENV TERM=xterm \
        LC_ALL=C.UTF-8 \
        LANG=en_US.UTF-8 \
        LANGUAGE=en_US.UTF-8 \
        REPLACE_OS_VARS=true \
        HOME=/home/ejabberd \
        PATH="$PATH:/home/ejabberd/bin" \
        VERSION=${VERSION:-latest}
    LABEL maintainer="ProcessOne <contact@process-one.net>" \
        product="Ejabberd Community Server Official Docker Image" \
        version=$VERSION \
        org.label-schema.vcs-ref=$VCS_REF \
        org.label-schema.vcs-url="https://github.com/processone/docker-ejabberd" \
        org.label-schema.build-date=$BUILD_DATE \
        org.label-schema.name="Ejabberd Community Server Official Docker Image" \
        org.label-schema.description="Robust, Scalable and Extensible Realtime Server using XMPP, MQTT and SIP" \
        org.label-schema.url="https://www.ejabberd.im/" \
        org.label-schema.vendor="ProcessOne" \
        org.label-schema.version=$VERSION \
        org.label-schema.schema-version="1.0"
    
    # Create directory structure and user for ejabberd
    RUN addgroup ejabberd -g 9000 \
        && adduser -s /bin/sh -D -G ejabberd ejabberd -u 9000 \
        && mkdir -p /home/ejabberd/conf /home/ejabberd/database /home/ejabberd/logs /home/ejabberd/upload \
        && chown -R ejabberd:ejabberd /home/ejabberd \
        && ln -fs /home/ejabberd /opt/ejabberd \
        && ln -fs /home/ejabberd /opt/ejabberd-$VERSION
    
    # Install required dependencies
    RUN apk upgrade --update-cache --no-progress \
        && apk add \
        expat \
        freetds \
        gd \
        jpeg \
        libgd \
        libpng \
        libstdc++ \
        libwebp \
        ncurses-libs \
        openssl \
        sqlite \
        sqlite-libs \
        tini \
        unixodbc \
        yaml \
        zlib \
        && ln -fs /usr/lib/libtdsodbc.so.0 /usr/lib/libtdsodbc.so \
        && rm -rf /var/cache/apk/*
    
    # Install ejabberd
    WORKDIR $HOME
    COPY --from=builder /ejabberd/runtime .
    COPY bin/* bin/
    COPY --from=api /go/bin/ejabberdapi bin/ejabberdapi
    RUN chmod 755 bin/ejabberdctl bin/ejabberdapi bin/erl bin/captcha*.sh \
        && mkdir -p /home/ejabberd/sql \
        && cp /home/ejabberd/lib/ejabberd-*/priv/sql/* /home/ejabberd/database/ \
        && cp /home/ejabberd/lib/ejabberd-*/priv/sql/* /home/ejabberd/sql/
    COPY --chown=ejabberd:ejabberd conf conf/
    ADD --chown=ejabberd:ejabberd https://download.process-one.net/cacert.pem conf/cacert.pem
    
    # Setup runtime environment
    .............more configurations .......................
    

    also i tried to build for arm64 on my MAC

     sudo docker buildx build \                                                                                                                                                                                                           
        -t personal/ejabberd \
        -f Dockerfile . 
    

    i got this error

    [+] Building 8.7s (4/4) FINISHED                                                                                                                                                                                                                                                                       docker:desktop-linux
     => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                   0.0s
     => => transferring dockerfile: 4.94kB                                                                                                                                                                                                                                                                                 0.0s
     => [internal] load metadata for docker.io/library/alpine:3.22                                                                                                                                                                                                                                                         1.9s
     => ERROR [internal] load metadata for docker.io/ejabberd/mix:latest                                                                                                                                                                                                                                                   8.7s
     => [internal] load metadata for docker.io/library/golang:1.25-alpine                                                                                                                                                                                                                                                  1.7s
    ------
     > [internal] load metadata for docker.io/ejabberd/mix:latest:
    ------
    Dockerfile:6
    --------------------
       4 |         && mv bin/ejabberd bin/ejabberdapi
       5 |     
       6 | >>> FROM docker.io/ejabberd/mix AS builder
       7 |     ARG VERSION
       8 |     ENV VERSION=${VERSION:-latest} \
    --------------------
    ERROR: failed to solve: docker.io/ejabberd/mix: failed to resolve source metadata for docker.io/ejabberd/mix:latest: no match for platform in manifest: not found
    
    View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/7tqkz102vln4q9etjc1qag8bz
    

    only amd64 is possible using --platform linux/amd64 flag but using that flag i got the error i wrote before

  4. badlop commented on Mar 12, 2026

    @badlop
    Member

    qemu: uncaught target signal 11 (Segmentation fault) - core dumped

    I don't know if it will be related, but some time ago Qemu had a bug and it crashed compiling "ejabberd" container images with it. The first workaround at that time to build "ejabberd" containers for arm using i386 was using crosstool...

    Later when Qemu got fixed, it was used again...

    But nowadays the "ejabberd" container images are built using native github runners, so Qemu is no longer used to build amd64 and arm64 images.


    On the other hand, the "ecs" container images that you are using right now are only built for amd64, so there is no experience building it with Qemu. In theory it should work, if you are using a recent Qemu version that doesn't have that old bug.


    ERROR: failed to solve: docker.io/ejabberd/mix:
    failed to resolve source metadata for docker.io/ejabberd/mix:latest:
    no match for platform in manifest: not found
    

    Notice that the "ecs" and "mix" container images are built only for amd64.

    In my amd64 machine it works:

    $ podman pull docker.io/ejabberd/mix:latest
    Trying to pull docker.io/ejabberd/mix:latest...
    Getting image source signatures
    Copying blob d49a2dee86fb done   | 
    Copying blob 060c99b0cee6 done   | 
    Copying blob fccbe7bc4dab done   | 
    Copying config fee6c75944 done   | 
    Writing manifest to image destination
    fee6c759447c2615d11b7e5684efe004b16434f6b2270655d115ad61824fac0a
    

    As you noticed, the "ecs" container image is based on the "mix" container image, which is only built for amd64, not ARM.

    Alternatively, you could try using the "ejabberd" container image, which is based on the "erlang" container image, and fortunately that one is built for arm and many other architectures.

    If you are already using the "ecs" container image and switch to use the "ejabberd" container image, in theory all paths should be compatible and not require any changes in your start script. But just in case, check the images comparison table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions