Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
torarnv committed Jun 29, 2016
1 parent b7309cd commit 17488fc
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
44 changes: 44 additions & 0 deletions 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"]
67 changes: 67 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down

0 comments on commit 17488fc

Please sign in to comment.