Closed zzzZLRzzz closed 7 months ago
Years ago, the container used Distillery because that was the only method to build a release of an erlang program. However, an improved method is available in newer versions of Elixir, so the Dockerfile changed in 2ae9f006a3989a0203442be19e2b42cb76a0c345 which was included in ejabberd 22.05:
Use Elixir's release instead of Distillery's release
You are right, the Dockerfile could use a specific tag of the mix container to ensure that it uses a version that is known to work. From now on, when the mix
image changes, I'll try to get it tagged and referenced in ecs/Dockerfile
.
Now trying to solve your problem: It seems you want to build a container of a specific ejabberd version, 21.07, right? And you used docker-ejabberd git tag 21.07, you did something like this:
cd docker-ejabberd
cd ecs
git checkout 21.07
./build.sh
It is possible to build any ejabberd version using the latest version of docker-ejabberd, and tell build.sh to download the desired ejabberd version, as mentioned in Generating ejabberd release:
cd docker-ejabberd
cd ecs
git checkout master
./build.sh 21.07
Unfortunately, that doesn't work with so old versions of ejabberd as 21.07:
72.81 ===> Compiling p1_oauth2
73.87 escript: exception error: undefined function enc:main/1
73.87 in function escript:run/2 (escript.erl, line 750)
73.87 in call from escript:start/1 (escript.erl, line 277)
73.87 in call from init:start_em/1
73.87 in call from init:do_boot/3
73.87 ===> Hook for compile failed!
73.87
73.88 ** (Mix) Could not compile dependency :jiffy, "/root/.mix/elixir/1-14/rebar3 bare compile --paths /ejabberd/_build/prod/lib/*/ebin" command failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile jiffy", update it with "mix deps.update jiffy" or clean it with "mix deps.clean jiffy"
73.88 ==> ejabberd
Here is a solution that lets you generate a container that includes ejabberd 21.07:
First generate a mix
image compatible with ejabberd 21.07:
cd docker-ejabberd
cd mix
git checkout 856296e3a4f0dd26f0205afc3dfd515778cc007c
docker build -t personal/mix .
cd ..
Now prepare the ejabberd Dockerfile to use that old mix
image:
cd ecs
git checkout master
Edit Dockerfile
to change those two lines:
diff --git a/ecs/Dockerfile b/ecs/Dockerfile
index 140a936..d534bc8 100644
--- a/ecs/Dockerfile
+++ b/ecs/Dockerfile
@@ -3,7 +3,7 @@ RUN go install -v \
github.com/processone/ejabberd-api/cmd/ejabberd@master \
&& mv bin/ejabberd bin/ejabberdapi
-FROM ejabberd/mix as builder
+FROM personal/mix as builder
ARG VERSION
ENV VERSION=${VERSION:-latest} \
MIX_ENV=prod
@@ -42,7 +42,7 @@ RUN mkdir runtime \
&& cp -r /ejabberd/sql lib/ejabberd-*/priv
# Runtime container
-FROM alpine:3.17
+FROM alpine:3.14
ARG VERSION
ARG VCS_REF
ARG BUILD_DATE
And finally build the image, telling to download ejabberd 21.07:
./build.sh 21.07
Let's try the result:
docker run -it -p 5222:5222 ejabberd/ecs:21.07 live
...
2024-02-05 11:03:04.878534+00:00 [info] ejabberd 21.7.0 is started in the node ejabberd@localhost in 2.66s
2024-02-05 11:03:04.878983+00:00 [info] Start accepting TCP connections at [::]:5269 for ejabberd_s2s_in
2024-02-05 11:03:04.879083+00:00 [info] Start accepting TCP connections at [::]:1883 for mod_mqtt
2024-02-05 11:03:04.879133+00:00 [info] Start accepting TCP connections at [::]:5280 for ejabberd_http
2024-02-05 11:03:04.879171+00:00 [info] Start accepting TCP connections at 172.17.0.2:7777 for mod_proxy65_stream
2024-02-05 11:03:04.879257+00:00 [info] Start accepting TCP connections at [::]:5222 for ejabberd_c2s
2024-02-05 11:03:04.879175+00:00 [info] Start accepting TLS connections at [::]:5443 for ejabberd_http
Eshell V12.0 (abort with ^G)
Thanks, it works. By the way, I found that there're 3 tags of ejabberd/mix's image on Dockerhub: https://hub.docker.com/r/ejabberd/mix/tags latest 4 months ago 19.02 2 years ago 18.06 6 years ago It seems that there's not an available image for ejabberd 21.07 so that I need to build the personal mix image by myself. Is the latest image be overwritten everytime it updated?
Right. As I said:
From now on, when the mix image changes, I'll try to get it tagged and referenced in ecs/Dockerfile.
Done!
Since https://github.com/processone/docker-ejabberd/commit/abea089e142ce6e58f9124e15abddb0d21f89d93, the mix
container image is pushed and tagged automatically at the same time that the ecs
image, both in Docker Hub and in the GitHub Container Registry.
I tried to build docker image by using dockerfile in ecs directory, tag "21.07" an error occured:
I found that the first line in ecs's dockerfile is
"FROM ejabberd/mix as builder"
should it specify the version of ejabberd/mix image?