From 17488fc6c22503d8c502fb7a3c6707be630853fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 29 Jun 2016 22:53:12 +0200 Subject: [PATCH] Add Dockerfile --- Dockerfile | 44 +++++++++++++++++++++++++++++++++++ README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..2220eddcaf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +FROM alpine:3.3 + +RUN adduser -S znc && addgroup -S znc + +RUN mkdir -p /home/znc/src /home/znc/build +WORKDIR /home/znc/build +ADD . /home/znc/src + +ARG config_flags="--enable-perl --enable-python 3.5" +ARG cleanup_cmds="apk del build-dependencies && rm -Rf *" +ARG make_flags="" + +RUN apk add --no-cache --virtual runtime-dependencies \ + icu \ + openssl \ + boost \ + python3 \ + perl \ + cyrus-sasl + +RUN apk add --no-cache --virtual build-dependencies \ + build-base \ + cmake \ + git \ + icu-dev \ + openssl-dev \ + cyrus-sasl-dev \ + perl-dev \ + python3-dev \ + swig \ + gettext-dev \ + boost-dev \ + && /home/znc/src/configure.sh $config_flags \ + && make $make_flags \ + && make install \ + && sh -c "$cleanup_cmds" + +USER znc +WORKDIR /home/znc +VOLUME /home/znc/data + +EXPOSE 6667 + +ENTRYPOINT ["/usr/local/bin/znc", "-f", "-d", "/home/znc/data"] diff --git a/README.md b/README.md index 7a216065b6..de1561b64c 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,73 @@ Perl modules are loaded through the global module Python modules are loaded through the global module [ModPython](http://wiki.znc.in/Modpython). +## Docker + +To build a docker image with the latest version of ZNC, run: + +```shell +docker build -t $(USER)/znc:latest . +``` + +This includes Perl and Python support. Then start ZNC: + +```shell +docker run -i -t -v $HOME/.znc:/home/znc/data -p 6667:6667 $(USER)/znc:latest +``` + +If you haven't set up a configuration yet, you need to pass `--makeconf`: + +```shell +docker run -i -t -v $HOME/.znc:/home/znc/data -p 6667:6667 $(USER)/znc:latest --makeconf +``` + +Then rerun without `--makeconf`, and if everything looks good, start ZNC in the background: + +```shell +docker run -d -v $HOME/.znc:/home/znc/data -p 6667:6667 --name znc $(USER)/znc:latest +``` + +You can verify that everything is running smoothly by running: + +```shell +docker ps && docker logs znc +``` + +To build extra modules, place the source files in `~/.znc/modules` like usual, and then run: + +```shell +docker exec -u root znc apk add --no-cache build-base cmake openssl-dev icu-dev +docker exec -u root znc sh -c 'cd $HOME/modules && znc-buildmod *.cpp' +``` + +Since the module's `.so` file is placed in the exported volume, you don't need to +commit these changes in the container back to the image. + +To restart the container, simply run: + +```shell +docker restart znc +``` + +At any time, you can remove the znc container, and recreate it by running: + +```shell +docker rm znc +docker create -v $HOME/.znc:/home/znc/data -p 6667:6667 --name znc $(USER)/znc:latest +``` + +The docker image can be customized via build arguments, eg. for a development build: + +```shell +docker build -t $(USER)/znc:latest --build-arg config_flags="--enable-perl --enable-python 3.5 --enable-debug" --build-arg cleanup_cmds="" --build-arg make_flags="-j8" . +``` + +And then built in place, if the host source directory is mounted using `-v /host/src:/home/znc/src`: + +```shell +docker exec --user root znc make install -C /home/znc/build && docker restart znc && docker logs znc +``` + ## Further infos Please visit http://znc.in/ or