Merge "Add initial support to build Docker images" into 13

changes/70/2370/12
zuul 9 years ago committed by Gerrit Code Review
commit aeef52db9f

1
.gitignore vendored

@ -33,4 +33,5 @@ menuselect-tree
*.gcda
latex
doxygen.log
out/

@ -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"]

@ -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

@ -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

@ -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 .
Loading…
Cancel
Save