ppikula / mongooseim-docker

Dockerized MongooseIM 1.5
http://github.com/esl/MongooseIM
Apache License 2.0
20 stars 13 forks source link

Compile and user ejabberd modules #4

Open rrigoni opened 8 years ago

rrigoni commented 8 years ago

Hello,

Is there any way to compile and include an ejabberd module to forward offline messages to a http host?

Modules like mod_interact, mod_http_offline and so on.

I tried to compile and include it in the modules folder and it doesn't work.

Thanks.

ppikula commented 8 years ago

Hi! How did you do that, where did you copied it? Did you enable modules in the config file? All in all, it think it should work, if you copied them(compiled beam files) into correct place. This place should look like this /opt/mongooseim/rel/mongooseim/lib/ejabberd-2.1.8+mim-1.4.0-884-g44f7e85/ebin/ The problem is this "random" suffix is generated from git commit sha, so it is going to change with every new commit/version.

I see a couple different, possible solutions to your problem.

  1. You can fork Mongoose, add the modules, check if they work and replace the link to the repo here. Then, it will clone you modified version
  2. Modify Dockerfile in the same place, before running make rel. In this approach you don't need to fork and it is likely to work with new versions of Mongoose.
&& make configure with-mysql with-pgsql with-redis with-cassandra \
&& make rel \

to

ADD ./mod_interact.erl ~/mod_interact.erl 

[... skipped] 

&& make configure with-mysql with-pgsql with-redis with-cassandra \
&& mv ~/mod_interact.erl  /opt/mongooseim/apps/ejabberd/src/ \
&& make rel \

Let me know if any of the ideas above solve you problem or we should look for a different one

ppikula commented 8 years ago

Hey, I thought about it and I think, I found more clean solution. Just do the same as when you want to replace the config file.

FROM mongooseim/mongooseim-docker

## add the module to the source directory 
ADD ./mod_http_offline.erl /opt/mongooseim/apps/ejabberd/src/

## recreate mongoose release  - will compile the new module and will add it where it 
## needs to be
RUN cd /opt/mongooseim && make rel

##  uncomment if you want alter config file, do that after make rel! otherwise
##  it will be overwritten 
# ADD ./ejabberd.cfg  /opt/mongooseim/rel/mongooseim/etc/ejabberd.cfg

I was trying to do that on my own and I saw the following error during compilation, which might be the reason why it doesn't work in your case:

/opt/mongooseim/apps/ejabberd/src/mod_http_offline.erl:47: Warning: call to http:request/4 will fail, since it was removed in R15B; use httpc:request/4
ppikula commented 8 years ago

@rrigoni any updates? have you managed to enable the modules?

rrigoni commented 8 years ago

Hi @ppikula. Yes, I did. But I did a lot of adjustments in the modules to get it working. The module was written to ejabberd 2.2.x and a lot of things changed.

Now I have a version of Mongooseim working like a charm with push notifications.

Would you like to merge them into the docker image?

I can submit a pull request with my solution.

The solution I used is your last suggestion. I simply copied the modules to Mongooseim's folder and call make rel.

Thanks . On Sep 9, 2015 07:24, "Paweł Pikuła" notifications@github.com wrote:

@rrigoni https://github.com/rrigoni any updates? have you managed to enable the modules?

— Reply to this email directly or view it on GitHub https://github.com/ppikula/mongooseim-docker/issues/4#issuecomment-138866627 .

ppikula commented 8 years ago

Hi @rrigoni !

To be honest I don't see a point in merging it into the docker image. I think it is good as it is - to create a new docker file, which derives from the "base" image and then add your stuff like modules/config.

However, if you put effort in porting this module and it works. I think It is a good idea to make a pull request to Mongoose, of course if the license allows it and others will agree. IMO It is valuable, and I can help you to get it merged into the master branch, unless It should stay in a separate repo for some reasons.