Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ecs/Dockerfile: Include mod_ecaptcha #100

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions ecs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ RUN go install -v \
&& mv bin/ejabberd bin/ejabberdapi

FROM ejabberd/mix as builder
ARG BUILD_DIR='/ejabberd'
ARG VERSION
ENV VERSION=${VERSION:-latest} \
MIX_ENV=prod
Expand All @@ -12,7 +13,23 @@ LABEL maintainer="ProcessOne <[email protected]>" \

# Get ejabberd sources, dependencies, configuration
RUN git clone https://github.com/processone/ejabberd.git
WORKDIR /ejabberd

# include mod_ecaptcha from ejabberd-contrib
WORKDIR $BUILD_DIR/.ejabberd-modules/sources/ejabberd-contrib
RUN git clone https://github.com/processone/ejabberd-contrib --depth 1 . \
&& cp mod_ecaptcha/src/mod_ecaptcha.erl $BUILD_DIR/src \
&& sed -i '/^{deps,/a \ \
\n {ecaptcha, ".*", {git, "https://github.com/seriyps/ecaptcha", {branch, "master"}}},' \
$BUILD_DIR/rebar.config \
&& sed -i '/^ {:xmpp, ">= .*"},/a \ \
\n {:ecaptcha, github: "seriyps/ecaptcha"},' \
$BUILD_DIR/mix.exs \
&& sed -i '/^ included_applications:/a \ \
\n :ecaptcha,' \
$BUILD_DIR/mix.exs \
&& rm -rf mod_ecaptcha

WORKDIR $BUILD_DIR
COPY vars.config .
RUN echo '{vsn, "'${VERSION}'.0"}.' >>vars.config
COPY config.exs config/
Expand All @@ -25,9 +42,8 @@ RUN git checkout ${VERSION/latest/HEAD} \
RUN MIX_ENV=prod mix release

# Prepare runtime environment
RUN mkdir runtime \
&& tar -C runtime -zxf _build/prod/ejabberd-*.tar.gz \
&& cd runtime \
WORKDIR $BUILD_DIR/runtime
RUN tar -zxf $BUILD_DIR/_build/prod/ejabberd-*.tar.gz \
&& 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 \
Expand All @@ -38,8 +54,8 @@ RUN mkdir runtime \
&& 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 lib/ejabberd-$EJABBERD_VERSION/priv/bin \
&& cp -r /ejabberd/sql lib/ejabberd-*/priv
&& cp $BUILD_DIR/tools/captcha*sh lib/ejabberd-$EJABBERD_VERSION/priv/bin \
&& cp -r $BUILD_DIR/sql lib/ejabberd-*/priv

# Runtime container
FROM alpine:3.17
Expand Down
6 changes: 6 additions & 0 deletions ecs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ docker exec -it ejabberd bin/ejabberdctl debug

## CAPTCHA

### Using mod_ecaptcha

`ejabberd/ecs` includes mod_ecpatcha precompiled from [ejabberd-contrib](https://github.com/processone/ejabberd-contrib/tree/master/mod_ecaptcha).

### Using CAPTCHA scripts

ejabberd includes two example CAPTCHA scripts.
If you want to use any of them, first install some additional required libraries:

Expand Down
3 changes: 3 additions & 0 deletions ecs/conf/ejabberd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ acme:
contact: "mailto:[email protected]"
ca_url: "https://acme-staging-v02.api.letsencrypt.org/directory"

captcha_cmd: mod_ecaptcha

modules:
mod_adhoc: {}
mod_admin_extra: {}
Expand All @@ -216,6 +218,7 @@ modules:
mod_client_state: {}
mod_configure: {}
mod_disco: {}
mod_ecaptcha: {}
mod_fail2ban: {}
mod_http_api: {}
mod_http_upload:
Expand Down