Enter the folder where Dockerfile is, run command:
docker build -t buildserver .
The command will create a docker image called buildserver. We will use the docker image to create a docker in which we compile Ejabberd's source code.
Check out Ejabberd's source code from https://github.com/liangdefeng/ejabberd.git to a folder, and switch to 20.12_for_spokechat branch.
git clone https://github.com/liangdefeng/ejabberd.git
cd ejabberd
git checkout 20.12_for_spokechat
cd <where the Ejabberd's repository is checked out>
docker run --rm -v $(pwd):$(pwd) --name buildserver -it buildserver
./autogen.sh
./configure
make
exit
The beam files can be found in ebin folder. We will copy the beam file from the folder to the Ejabberd server.
docker-compose up
The command will start up three docker servers for verification purpose.
-
main: The Ejabberd server.
-
mysql: The MySQL server Ejabberd connects to.
-
adminer: The admin page to view the mysql database.
If you want to deploy the module to your existing Ejabberd, before copy the module to your Ejabberd server, run the SQL:
ALTER TABLE spool ADD persist boolean NOT NULL DEFAULT false;
CREATE INDEX i_spool_p on spool(persist);
Example: copy the mod_offline_sql module to the servers.
docker cp <where the Ejabberd's repository is checked out>/ebin/mod_offline_sql.beam main:/home/ejabberd/lib/ejabberd-20.12.0/ebin/
The command will copy the mod_offline_sql module to main docker's /home/ejabberd/lib/ejabberd-20.12.0/ebin/ folder.
docker exec -it main bin/ejabberdctl debug
The command will let us enter Ejabberd's debug mode.
In Ejabberd's debug console, enter:
l(mod_offline_sql).
The command will load the mod_offline_sql into Ejabberd.
-
http://localhost:5280/admin - Ejabberd's admin page.
-
http://localhost:8080/ - The page to view mysql database.
System: MySQL
Server: mysql
Username: ejabberd
Password: ejabberd
Database: ejabberd
Create two accounts: user1 and user2, let them become each other's friend.
user2 is offline, user1 sends user2 two messages:
- One message without persist element.
- Another message with persist element.
Example messages:
<message to='user2@localhost' id='Ko1mN-131' type='chat'>
<body>offline message without persist</body>
</message>
<message to='user2@localhost' id='Ko1mN-132' type='chat'>
<body>offline message with persist</body>
<persist/>
</message>
The value of the persist field of the Ko1mN-131 message is 0; and its value of the Ko1mN-132 message is 1.
In the Ejabberd server, run the command:
$EJABBERD_HOME/bin/ejabberdctl delete_old_messages 0
You will see that the Ko1mN-132 message is still in the spool table.
user2 will receive the Ko1mN-132 message, and if you will see that the Ko1mN-132 message disappear in spool table.