2
0
mirror of https://github.com/processone/docker-ejabberd synced 2024-11-10 13:10:37 +00:00
docker-ejabberd/mix/README.md

88 lines
2.9 KiB
Markdown
Raw Normal View History

## Docker image for ejabberd developers
2016-11-30 13:33:07 +00:00
2016-12-05 11:29:24 +00:00
Thanks to this image, you can build ejabberd with dependencies provided in Docker image, without the need to install build software (beside Docker) directly on your own machine.
2016-11-30 13:33:07 +00:00
Please note that this image can likely be reused as is to build other Erlang or Elixir software.
2016-11-30 13:33:07 +00:00
### Building ejabberd from source
2016-11-30 13:33:07 +00:00
You can build ejabberd from source with all dependencies, with the following commands:
2016-11-30 13:33:07 +00:00
```bash
git clone https://github.com/processone/ejabberd.git
2018-01-12 09:49:34 +00:00
cd ejabberd
2016-11-30 13:33:07 +00:00
docker run --rm -v $(pwd):$(pwd) -w $(pwd) ejabberd/mix do deps.get, deps.compile, compile
```
2016-12-01 08:35:19 +00:00
Alternatively if you do not have Git installed, you can do:
```bash
wget https://github.com/processone/ejabberd/archive/master.zip
2018-01-12 09:49:34 +00:00
unzip master.zip
2016-12-01 08:35:19 +00:00
cd ejabberd-master
docker run --rm -v $(pwd):$(pwd) -w $(pwd) ejabberd/mix do deps.get, deps.compile, compile
```
## Run ejabberd with mix command-line tool attached
2016-11-30 13:33:07 +00:00
2016-12-02 13:12:35 +00:00
You can customize the configuration by editing the file `config/ejabberd.yml`. As a default, you can run ejabberd with console attached on "localhost" domain:
2016-11-30 13:33:07 +00:00
```bash
docker run --rm -it -p 5222:5222 -p 5280:5280 -v $(pwd):$(pwd) -w $(pwd) --entrypoint="/usr/bin/iex" ejabberd/mix -S mix
```
2016-12-02 13:12:35 +00:00
You can then create a user from Elixir shell:
```bash
Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]
Interactive Elixir (1.3.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :ejabberd_auth.try_register("test", "localhost", "passw0rd")
{:atomic, :ok}
```
You can then connect with user test@localhost (password: passw0rd) on server on localhost port 5222 and use those parameters to connect with an XMPP client.
2016-11-30 13:33:07 +00:00
## Get into the container
2016-11-30 13:33:07 +00:00
If you want to run Erlang command line, you can do so by opening a shell inside the container:
2016-11-30 13:33:07 +00:00
```bash
docker run -it -v $(pwd):$(pwd) -w $(pwd) --entrypoint="/bin/sh" ejabberd/mix
```
2016-12-02 13:12:35 +00:00
## Getting Elixir version
```bash
docker run -it --rm -v $(pwd):$(pwd) -w $(pwd) ejabberd/mix --version
Erlang/OTP 19 [erts-8.1] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]
Mix 1.3.4
```
## Build the image
2016-11-30 13:33:07 +00:00
Building the image is not needed if you simply want to use it. You can simply use the one from [ejabberd Docker Hub](https://hub.docker.com/u/ejabberd/dashboard/).
2016-11-30 13:33:07 +00:00
```bash
docker build -t ejabberd/mix .
```
## Troubleshooting
2016-11-30 13:33:07 +00:00
### Clock resync
2016-11-30 13:33:07 +00:00
If you have warning about file timestamp being out of sync (Like 'Clock skew detected'), you may want to force resync your clock before running the build. Docker on MacOS does not force clock resync of Docker after the laptop went to sleep.
2016-11-30 13:33:07 +00:00
You can force clock resync as follow:
```bash
docker run -it --rm --privileged --entrypoint="/sbin/hwclock" ejabberd/mix -s
```
You can check if the clock of your laptop is in sync with the one inside Docker with the following command:
2016-11-30 13:33:07 +00:00
```bash
docker run --rm --entrypoint="/bin/sh" ejabberd/mix -c date -u && date -u
```