diff options
author | louiz’ <louiz@louiz.org> | 2017-04-21 11:49:23 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-04-21 11:49:23 +0200 |
commit | 3666f35e0e884068437fe520dbd5f087bea4d946 (patch) | |
tree | 951b20bbd3bbe56fadccf4b6eb8c51f23a9d8882 /docker | |
parent | eac144acdaca02f018bddde5f623fba3e8cd4ad9 (diff) | |
download | biboumi-3666f35e0e884068437fe520dbd5f087bea4d946.tar.gz biboumi-3666f35e0e884068437fe520dbd5f087bea4d946.tar.bz2 biboumi-3666f35e0e884068437fe520dbd5f087bea4d946.tar.xz biboumi-3666f35e0e884068437fe520dbd5f087bea4d946.zip |
Use alpine for the docker image, and simplify the config + run stuff
Using env variable directly used by the process, it’s easier than calling
sed on the configuration file before we start the process. Also we don’t
need to start as root anymore, and it’s a lot cleaner.
Diffstat (limited to 'docker')
-rw-r--r-- | docker/biboumi/Dockerfile | 35 | ||||
-rw-r--r-- | docker/biboumi/README.md | 16 | ||||
-rw-r--r-- | docker/biboumi/biboumi.cfg | 8 | ||||
-rw-r--r-- | docker/biboumi/entrypoint.sh | 13 |
4 files changed, 32 insertions, 40 deletions
diff --git a/docker/biboumi/Dockerfile b/docker/biboumi/Dockerfile index 7c8d78d..d27421b 100644 --- a/docker/biboumi/Dockerfile +++ b/docker/biboumi/Dockerfile @@ -1,26 +1,25 @@ # This Dockerfile creates a docker image running biboumi -FROM docker.io/fedora:latest +FROM docker.io/alpine:latest -RUN dnf --refresh install -y\ - gcc-c++\ +RUN apk add --no-cache\ + g++\ cmake\ make\ - udns-devel\ - sqlite-devel\ - libuuid-devel\ - expat-devel\ - libidn-devel\ - systemd-devel\ + udns-dev\ + sqlite-dev\ + libuuid\ + util-linux-dev\ + expat-dev\ + libidn-dev\ git\ - python\ - && dnf clean all + python2 # Install botan -RUN git clone https://github.com/randombit/botan.git && cd botan && ./configure.py --prefix=/usr && make -j8 && make install && ldconfig && rm -rf /botan +RUN git clone https://github.com/randombit/botan.git && cd botan && ./configure.py --prefix=/usr && make -j8 && make install && rm -rf /botan # Install litesql -RUN git clone git://git.louiz.org/litesql && mkdir /litesql/build && cd /litesql/build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr && make -j8 && cd /litesql/build && make install && ldconfig && rm -rf /litesql +RUN git clone git://git.louiz.org/litesql && mkdir /litesql/build && cd /litesql/build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr && make -j8 && cd /litesql/build && make install && rm -rf /litesql # Install biboumi RUN git clone git://git.louiz.org/biboumi && mkdir ./biboumi/build && cd ./biboumi/build &&\ @@ -29,17 +28,17 @@ RUN git clone git://git.louiz.org/biboumi && mkdir ./biboumi/build && cd ./bibou -DWITH_BOTAN=1\ -DWITH_LITESQL=1\ -DWITH_LIBIDN=1\ - -DWITH_SYSTEMD=1\ && make -j8 && make install && rm -rf /biboumi -RUN useradd biboumi +RUN adduser biboumi -D -h /home/biboumi RUN mkdir /var/lib/biboumi +RUN chown -R biboumi:biboumi /var/lib/biboumi COPY ./biboumi.cfg /etc/biboumi/biboumi.cfg RUN chown -R biboumi:biboumi /etc/biboumi -COPY ./entrypoint.sh /entrypoint.sh -RUN chmod 755 /entrypoint.sh +WORKDIR /home/biboumi +USER biboumi -ENTRYPOINT ["/entrypoint.sh"] +CMD ["/usr/bin/biboumi", "/etc/biboumi/biboumi.cfg"] diff --git a/docker/biboumi/README.md b/docker/biboumi/README.md index e69c1b0..4b9e1e5 100644 --- a/docker/biboumi/README.md +++ b/docker/biboumi/README.md @@ -32,14 +32,12 @@ docker run --network=host \ Variables --------- -The configuration file inside the image is a template that is completed when the container is started, using the following environment variables: +The configuration file inside the image contains only a few default values. To be able to run, biboumi needs additional configuration. Additional options can be passed using environment variables. Any configuration option can be customized this way (see biboumi’s doc), but the main are listed here for convenience: * BIBOUMI_HOSTNAME: Sets the value of the *hostname* option. -* BIBOUMI_SECRET: Sets the value of the *password* option. +* BIBOUMI_PASSWORD: Sets the value of the *password* option. * BIBOUMI_ADMIN: Sets the value of the *admin* option. -* BIBOUMI_XMPP_SERVER_IP: Sets the value of the *xmpp_server_ip* option. The default is **xmpp**. - -All these variables are optional, but biboumi will probably fail to start if the hostname and secret are missing. +* BIBOUMI_XMPP_SERVER_IP: Sets the value of the *xmpp_server_ip* option. The default value is **xmpp**. You can also directly provide your own configuration file by mounting it inside the container using the -v option: @@ -49,6 +47,8 @@ docker run --link prosody:xmpp \ biboumi ``` +If both a custom configuration file and custom environment variables are passed to the container, the environment variables will take precedence. + Linking with the XMPP server ---------------------------- @@ -60,3 +60,9 @@ Volumes ------- The database is stored in the /var/lib/biboumi/ directory. If you don’t bind a local directory to it, the database will be lost when the container is stopped. If you want to keep your database between each run, bind it with the -v option, like this: **-v /srv/biboumi/:/var/lib/biboumi**. + +Note: Due to a limitation in Docker, to be able to read and write into this database, make sure this mounted directory is owned by UID and GID 1001:1001, on the host. + +``` +chown -R 1001:1001 database/ +``` diff --git a/docker/biboumi/biboumi.cfg b/docker/biboumi/biboumi.cfg index cc5df61..98c5a9f 100644 --- a/docker/biboumi/biboumi.cfg +++ b/docker/biboumi/biboumi.cfg @@ -1,6 +1,6 @@ -xmpp_server_ip=BIBOUMI_XMPP_SERVER_IP +xmpp_server_ip=127.0.0.1 port=5347 db_name=/var/lib/biboumi/biboumi.sqlite -hostname=BIBOUMI_HOSTNAME -password=BIBOUMI_PASSWORD -admin=BIBOUMI_ADMIN +hostname=xmpp +password= +admin= diff --git a/docker/biboumi/entrypoint.sh b/docker/biboumi/entrypoint.sh deleted file mode 100644 index af61260..0000000 --- a/docker/biboumi/entrypoint.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -sed -i s/BIBOUMI_XMPP_SERVER_IP/${BIBOUMI_XMPP_SERVER_IP:-xmpp}/ /etc/biboumi/biboumi.cfg -sed -i s/BIBOUMI_HOSTNAME/${BIBOUMI_HOSTNAME:-biboumi.localhost}/ /etc/biboumi/biboumi.cfg -sed -i s/BIBOUMI_ADMIN/${BIBOUMI_ADMIN:-}/ /etc/biboumi/biboumi.cfg -sed -i s/BIBOUMI_PASSWORD/${BIBOUMI_PASSWORD:-missing_password}/ /etc/biboumi/biboumi.cfg - -chown -R biboumi:biboumi /var/lib/biboumi - -echo "Running biboumi with the following conf: " -cat /etc/biboumi/biboumi.cfg - -exec runuser -u biboumi /usr/bin/biboumi /etc/biboumi/biboumi.cfg |