diff --git a/.gitignore b/.gitignore index 0281e107cf7dffbcb13725e43d5617dc001b16da..1a6deef24f1026188de6a94807318a2b2e6f30bf 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,5 @@ menuselect-tree *.gcda latex doxygen.log +out/ diff --git a/contrib/docker/Dockerfile.asterisk b/contrib/docker/Dockerfile.asterisk new file mode 100644 index 0000000000000000000000000000000000000000..41bf4352413ab148b518641e625f461a994fe083 --- /dev/null +++ b/contrib/docker/Dockerfile.asterisk @@ -0,0 +1,19 @@ +# Version 0.0.3 +FROM centos:7 +MAINTAINER Leif Madsen <leif@leifmadsen.com> +ENV REFRESHED_AT 2016-02-25 +ENV STARTDIR /tmp +ENV RPMPATH ./out + +# copy is required because you can't mount volumes during build +COPY $RPMPATH/*.rpm $STARTDIR + +# install dependencies and Asterisk RPM +RUN yum install epel-release -y && \ + yum install -y *.rpm && \ + yum clean all && \ + yum autoremove -y && \ + /sbin/ldconfig + +ENTRYPOINT ["/usr/sbin/asterisk"] +CMD ["-c", "-vvvv", "-g"] diff --git a/contrib/docker/Dockerfile.packager b/contrib/docker/Dockerfile.packager new file mode 100644 index 0000000000000000000000000000000000000000..35882106227137fe6aa3e900fa9fd9d1fe11b454 --- /dev/null +++ b/contrib/docker/Dockerfile.packager @@ -0,0 +1,9 @@ +FROM alanfranz/fwd-centos-7:latest +MAINTAINER Leif Madsen <leif@leifmadsen.com> +ENV REFRESHED_AT 2016-02-25 +ADD contrib/scripts/install_prereq /tmp/install_prereq +RUN yum clean metadata && \ + yum -y update && \ + yum install epel-release -y && \ + yum clean all &&\ + /tmp/install_prereq install diff --git a/contrib/docker/README.md b/contrib/docker/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2a9bd66d43b093638a357a53f9771c1acb40f149 --- /dev/null +++ b/contrib/docker/README.md @@ -0,0 +1,39 @@ +# Building Asterisk into a Docker Container Image +The following set of steps should leave you with a Docker container that +is relatively small, built from your local checked out source, and even +provides you with a nice little RPM too! + +## Build the package container image +Build the package container image. This uses FPM[1] so no `spec` files and +such are necessary. +``` +docker build --pull -f contrib/docker/Dockerfile.packager -t asterisk-build . +``` + +## Build your Asterisk RPM from source +Build the Asterisk RPM from the resulting container image. +``` +docker run -ti \ + -v $(pwd):/application:ro \ + -v $(pwd)/out:/build \ + -w /application asterisk-build \ + /application/contrib/docker/make-package.sh 13.6.0 +``` +> **NOTE**: If you need to build this on a system that has SElinux enabled +> you'll need to use the following command instead: +> ``` +> docker run -ti \ +> -v $(pwd):/application:Z \ +> -v $(pwd)/out:/build:Z \ +> -w /application asterisk-build \ +> /application/contrib/docker/make-package.sh 13.6.0 +> ``` + +## Create your Asterisk container image +Now create your own Asterisk container image from the resulting RPM. +``` +docker build --rm -t madsen/asterisk:13.6.0-1 -f contrib/docker/Dockerfile.asterisk . +``` + +# References +[1] https://github.com/jordansissel/fpm diff --git a/contrib/docker/make-package.sh b/contrib/docker/make-package.sh new file mode 100755 index 0000000000000000000000000000000000000000..261df60e3feb7174799d31ef6d6d22b00fa910e1 --- /dev/null +++ b/contrib/docker/make-package.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# This script intended to be run from the packager container. Please see the +# README.md file for more information on how this script is used. +# +set -ex +[ -n "$1" ] +mkdir -p /opt + +# move into the application directory where Asterisk source exists +cd /application + +# strip the source of any Git-isms +rsync -av --exclude='.git' . /tmp/application + +# move to the build directory and build Asterisk +cd /tmp/application +./configure +cd menuselect +make menuselect +cd .. +make menuselect-tree + +menuselect/menuselect --check-deps menuselect.makeopts + +# Do not include sound files. You should be mounting these from and external +# volume. +sed -i -e 's/MENUSELECT_MOH=.*$/MENUSELECT_MOH=/' menuselect.makeopts +sed -i -e 's/MENUSELECT_CORE_SOUNDS=.*$/MENUSELECT_CORE_SOUNDS=/' menuselect.makeopts + +# Build it! +make all install DESTDIR=/tmp/installdir + +rm -rf /tmp/application +cd /build + +# Use the Fine Package Management system to build us an RPM without all that +# reeking effort. +fpm -t rpm -s dir -n asterisk-custom --version "$1" \ + --depends libedit \ + --depends libxslt \ + --depends jansson \ + --depends pjproject \ + --depends openssl \ + --depends libxml2 \ + --depends unixODBC \ + --depends libcurl \ + --depends libogg \ + --depends libvorbis \ + --depends speex \ + --depends spandsp \ + --depends freetds \ + --depends net-snmp \ + --depends iksemel \ + --depends corosynclib \ + --depends newt \ + --depends lua \ + --depends sqlite \ + --depends freetds \ + --depends radiusclient-ng \ + --depends postgresql \ + --depends neon \ + --depends libical \ + --depends openldap \ + --depends sqlite2 \ + --depends mysql \ + --depends bluez \ + --depends gsm \ + --depends libuuid \ + --depends libsrtp \ + -C /tmp/installdir etc usr var + +chown -R --reference /application/contrib/docker/make-package.sh .