Tag Archives: docker

using docker to build Varnish VMODs

Docker is containers. Let’s use it to create a build environment we can delete after we’re done. Part one is figuring out what we need to build vmods.

I like using Fedora:
mkdir /tmp/vmods
docker run -v /tmp/vmods:/data -it fedora:24 bash
dnf install -y git
dnf install -y autoconf automake libtool m4 perl-Thread-Queue make
dnf install -y varnish-libs-devel.x86_64 varnish
# dnf install -y dnf-plugins-core /usr/bin/rpmbuild
cd /usr/src
# dnf download --source varnish # no longer have to build Varnish from source to compile VMODs
# rpm -ivh varnish*src.rpm
# dnf install -y groff jemalloc-devel libedit-devel ncurses-devel pcre-devel python-docutils

dnf install -y GeoIP-devel.x86_64
git clone https://github.com/varnish/libvmod-geoip.git
cd libvmod-geoip
bash autogen.sh
./configure VMOD_DIR=/data
make
make install

dnf install -y libmhash-devel
git clone https://github.com/varnish/libvmod-digest
cd libvmod-digest
bash autogen.sh
./configure VMOD_DIR=/data
make
make install

So we split that into a docker file and a script to build the vmod:

FROM fedora:24
RUN dnf update -y
RUN dnf install -y git autoconf automake libtool m4 perl-Thread-Queue make python-docutils
RUN dnf install -y varnish-libs-devel.x86_64 varnish

ADD build_vmods.sh /

CMD bash /build_vmods.sh


OUT_DIR=/data

usage() {
echo github URL must be set for each VMOD
exit 1
}
build() {
[ -z "$URL" ] && usage
[ ! -z "$DEPS" ] && dnf install -y $DEPS

src_dir=$(mktemp -d)

git clone $URL $src_dir
cd $src_dir
bash autogen.sh
./configure VMOD_DIR=$OUT_DIR
make
make install
}

DEPS="GeoIP-devel.x86_64"
URL="https://github.com/varnish/libvmod-geoip.git"
build

DEPS="libmhash-devel"
URL="https://github.com/varnish/libvmod-digest"
build

Influx DB Docker

Note on fedora24 with digital ocean: firewalld is the new firewall management daemon for F24, but it’s not installed by default on d.o:
dnf install firewalld
service firewalld start
setenforce 0 # if you want to disable selinux

Also firewalld and docker can conflict, docker needs to be started after firewalld.

Installing influx on docker:

dnf install docker
service docker start
docker pull docker.io/tutum/influxdb
mkdir /var/influxdb
firewall-cmd --add-port=8083/tcp
docker run -d --name influx --volume=/var/influxdb:/data -p 8083:8083 -p 8086:8086 tutum/influxdb
docker logs influx # check that it's running ok

Getting Docker working with ansible:

pip install 'docker-py>=1.7.0' # host side

Docs:
http://docs.ansible.com/ansible/guide_docker.html
https://docs.ansible.com/ansible/docker_container_module.html
https://docs.ansible.com/ansible/docker_image_module.html