Cleanup the Dockerfile

- Reduce the build steps to reduce the number and size of intermediate images
- Set the logging to stdout by default
- Remove default user create, but still allow optional user creation
- Fix entrypoint command setup
This commit is contained in:
Kevin Carter 2014-12-07 19:59:37 -07:00
parent 12dcdb0c64
commit 1b1f0ed951
4 changed files with 40 additions and 33 deletions

View file

@ -7,24 +7,34 @@ FROM ubuntu:14.04
MAINTAINER Lloyd Watkin <lloyd@evilprofessor.co.uk>
RUN mkdir /data
WORKDIR /data
# Install dependencies
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libidn11 \
liblua5.1-expat0 \
libssl1.0.0 \
lua-dbi-mysql \
lua-dbi-postgresql \
lua-dbi-sqlite3 \
lua-event \
lua-expat \
lua-filesystem \
lua-sec \
lua-socket \
lua-zlib \
lua-zlib \
lua5.1 \
openssl \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y openssl lua5.1 lua-expat lua-socket lua-filesystem \
libidn11 lua-event lua-zlib lua-dbi-mysql lua-dbi-postgresql \
lua-dbi-sqlite3 libssl1.0.0 lua-sec lua-zlib liblua5.1-expat0
# Install and configure prosody
COPY ./prosody.deb /tmp/prosody.deb
RUN dpkg -i /tmp/prosody.deb \
&& sed -i '1s/^/daemonize = false;\n/' /etc/prosody/prosody.cfg.lua \
&& perl -i -pe 'BEGIN{undef $/;} s/^log = {.*?^}$/log = {\n {levels = {min = "info"}, to = "console"};\n}/smg' /etc/prosody/prosody.cfg.lua
COPY ./prosody.deb /data/prosody.deb
COPY ./start.sh /data/start.sh
COPY ./entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
RUN chmod 700 /data/start.sh
RUN dpkg -i /data/prosody.deb
# If using default configuration keep a process alive
RUN echo 'daemonize = false;' | cat - /etc/prosody/prosody.cfg.lua > temp && mv temp /etc/prosody/prosody.cfg.lua
EXPOSE 443 80 5222 5269 5347 5280 5281
ENTRYPOINT /data/start.sh
EXPOSE 80 443 5222 5269 5347 5280 5281
CMD ["prosodyctl", "start"]

View file

@ -6,7 +6,7 @@ For images please see here: [Prosody on Docker](https://registry.hub.docker.com/
It works by coping in a recently built `deb` file and running the install on the system.
## Running
## Running
Docker images are built off an __Ubuntu 14.04 LTS__ base.
@ -14,10 +14,10 @@ Docker images are built off an __Ubuntu 14.04 LTS__ base.
docker run -d prosody/prosody --name prosody -p 5222:5222
```
On startup the image will create a default user of `admin@localhost` with password `password`. This can be changed by using environment variables `LOCAL`, `DOMAIN`, and `PASSWORD`. This performs the following action on startup:
A user can be created by using environment variables `LOCAL`, `DOMAIN`, and `PASSWORD`. This performs the following action on startup:
prosodyctl register *local* *domain* *password*
Any error from this script is ignored. Prosody will not check the user exists before running the command (i.e. existing users will be overwritten). It is expected that [mod_admin_adhoc](http://prosody.im/doc/modules/mod_admin_adhoc) will then be in place for managing users (and the server).
### Ports
@ -70,7 +70,7 @@ Use the `build-docker.sh` script as follows:
./build-docker.sh /path/to/built-image.deb version_tag [, ...version_tag2, ...]
```
Where argument 1 is a pointer to the build `deb` file that you'd like to make an image from and 'version_tag' is the tag you'd like to push to the Docker registry with.
Where argument 1 is a pointer to the build `deb` file that you'd like to make an image from and 'version_tag' is the tag you'd like to push to the Docker registry with.
You can specify multiple tags by adding additional tag names to the end of the command. This is useful where a for example release 0.10.4 is made which also consitutes 'latest', '0.10-nightly', '0.10.4', '0.10' images.

8
entrypoint.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
set -e
if [ "$LOCAL" -a "$PASSWORD" -a "$DOMAIN" ] ; then
prosodyctl register $LOCAL $DOMAIN $PASSWORD
fi
exec "$@"

View file

@ -1,11 +0,0 @@
#! /bin/bash
if [ ! "${LOCAL}" ] || [ ! "${PASSWORD}" ] || [ ! "${DOMAIN}" ] ; then
LOCAL="admin"
PASSWORD="password"
DOMAIN="localhost"
fi
prosodyctl register $LOCAL $DOMAIN $PASSWORD || true
prosodyctl start