diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..3a65ef157e --- /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 /home/znc/build /home/znc/src" +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..39a189211b 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/znc/data/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