Browse code

pkg/kamailio/alpine_docker: Alpine docker scripts moved to subproject

Sergey Safarov authored on 07/11/2017 21:45:27
Showing 7 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,3 @@
1
+[submodule "pkg/docker"]
2
+	path = pkg/docker
3
+	url = https://github.com/kamailio/kamailio-ci.git
0 4
new file mode 160000
... ...
@@ -0,0 +1 @@
1
+Subproject commit 27cd32c1c5fa799cb3b240c25e90ed83a0812b6c
... ...
@@ -2,6 +2,7 @@
2 2
 # Contributor: Michael Mason <ms13sp@gmail.com>
3 3
 # Contributor: Leonardo Arena <rnalrd@gmail.com>
4 4
 # Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
5
+
5 6
 pkgname=kamailio
6 7
 pkgver=5.1.0
7 8
 pkgrel=0
8 9
deleted file mode 100644
... ...
@@ -1,5 +0,0 @@
1
-FROM scratch
2
-
3
-ADD kamailio_img.tar.gz /
4
-
5
-ENTRYPOINT ["kamailio", "-DD", "-E"]
6 0
deleted file mode 100644
... ...
@@ -1,85 +0,0 @@
1
-About
2
-
3
-Container designed to run on host, bridge and swarm network.
4
-Size of container decreased to 50MB (23MB compressed)
5
-Significantly increased security - removed all libs except libc, busybox, tcpdump, dumpcap, kamailio and dependent libs.
6
-Docker container is created useing Alpine linux packaging
7
-
8
-Usage container
9
-
10
-```sh
11
-docker run --net=host --name kamailio \
12
-           -v /etc/kamailio/:/etc/kamailio \
13
-           kamailio/kamailio -m 64 -M 8
14
-```
15
-
16
-systemd unit file
17
-
18
-You can use this systemd unit files on your docker host.
19
-Unit file can be placed to ```/etc/systemd/system/kamailio-docker.service``` and enabled by commands
20
-```sh
21
-systemd start kamailio-docker.service
22
-systemd enable kamailio-docker.service
23
-```
24
-
25
-host network
26
-============
27
-
28
-```sh
29
-$ cat /etc/systemd/system/kamailio-docker.service
30
-[Unit]
31
-Description=kamailio Container
32
-After=docker.service network-online.target
33
-Requires=docker.service
34
-
35
-
36
-[Service]
37
-Restart=always
38
-TimeoutStartSec=0
39
-#One ExecStart/ExecStop line to prevent hitting bugs in certain systemd versions
40
-ExecStart=/bin/sh -c 'docker rm -f kamailio; \
41
-          docker run -t --net=host --name kamailio \
42
-                 -v /etc/kamailio/:/etc/kamailio \
43
-                 kamailio/kamailio'
44
-ExecStop=-/bin/sh -c '/usr/bin/docker stop kamailio; \
45
-          /usr/bin/docker rm -f kamailio;'
46
-
47
-[Install]
48
-WantedBy=multi-user.target
49
-```
50
-
51
-default bridge network
52
-======================
53
-```sh
54
-[Unit]
55
-Description=kamailio Container
56
-After=docker.service network-online.target
57
-Requires=docker.service
58
-
59
-
60
-[Service]
61
-Restart=always
62
-TimeoutStartSec=0
63
-#One ExecStart/ExecStop line to prevent hitting bugs in certain systemd versions
64
-ExecStart=/bin/sh -c 'docker rm -f kamailio; \
65
-          docker run -t --network bridge --name kamailio \
66
-                 -p 5060:5060/udp -p 5060:5060 \
67
-                 -v /etc/kamailio/:/etc/kamailio \
68
-                 kamailio/kamailio'
69
-
70
-ExecStop=-/bin/sh -c '/usr/bin/docker stop kamailio; \
71
-          /usr/bin/docker rm -f kamailio;'
72
-
73
-[Install]
74
-WantedBy=multi-user.target
75
-```
76
-
77
-.bashrc file
78
-To simplify kamailio managment you can add alias for ```kamctl``` to ```.bashrc``` file as example bellow.
79
-```sh
80
-alias kamctl='docker exec -i -t kamailio /usr/sbin/kamctl'
81
-```
82 0
deleted file mode 100755
... ...
@@ -1,144 +0,0 @@
1
-#!/bin/sh -e
2
-
3
-# This script is wrote by Sergey Safarov <s.safarov@gmail.com>
4
-
5
-BUILD_ROOT=/tmp/kamailio
6
-FILELIST=/tmp/filelist
7
-FILELIST_BINARY=/tmp/filelist_binary
8
-TMP_TAR=/tmp/kamailio_min.tar.gz
9
-IMG_TAR=kamailio_img.tar.gz
10
-
11
-prepare_build() {
12
-apk add --no-cache abuild git gcc build-base bison db-dev flex expat-dev perl-dev postgresql-dev python2-dev pcre-dev mariadb-dev \
13
-    libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev sqlite-dev lua-dev openldap-dev \
14
-    libressl-dev net-snmp-dev libuuid libev-dev jansson-dev json-c-dev libevent-dev linux-headers \
15
-    libmemcached-dev rabbitmq-c-dev hiredis-dev libmaxminddb-dev libunistring-dev freeradius-client-dev lksctp-tools-dev
16
-
17
-    adduser -D build && addgroup build abuild
18
-    echo "%abuild ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/abuild
19
-    su - build -c "git config --global user.name 'Your Full Name'"
20
-    su - build -c "git config --global user.email 'your@email.address'"
21
-    su - build -c "abuild-keygen -a -i"
22
-}
23
-
24
-build_and_install(){
25
-    cd /usr/src/kamailio
26
-    REPO_OWNER=$(git remote get-url origin 2> /dev/null | sed -e 's|^.*github.com/||' -e 's|^git@github.com:||' -e 's|/.*\.git||')
27
-    if [ ! -z "$REPO_OWNER" ]; then
28
-        sed -i -e "s:github.com/kamailio:github.com/$REPO_OWNER:" /usr/src/kamailio/pkg/kamailio/alpine/APKBUILD
29
-    fi
30
-    if [ ! -z "$GIT_TAG" ]; then
31
-        sed -i -e "s/^_gitcommit=.*/_gitcommit=$GIT_TAG/" /usr/src/kamailio/pkg/kamailio/alpine/APKBUILD
32
-    fi
33
-    chown -R build /usr/src/kamailio
34
-    su - build -c "cd /usr/src/kamailio/pkg/kamailio/alpine; abuild snapshot"
35
-    su - build -c "cd /usr/src/kamailio/pkg/kamailio/alpine; abuild -r"
36
-    cd /home/build/packages/kamailio/x86_64
37
-    ls -1 kamailio-*.apk |  xargs apk --no-cache --allow-untrusted add
38
-}
39
-
40
-list_installed_kamailio_packages() {
41
-	apk info | grep kamailio
42
-}
43
-
44
-kamailio_files() {
45
-    local PACKAGES
46
-    PACKAGES=$(apk info | grep kamailio)
47
-    PACKAGES="musl $PACKAGES"
48
-    for pkg in $PACKAGES
49
-    do
50
-        # list package files and filter package name
51
-        apk info --contents $pkg 2> /dev/null | sed -e '/\S\+ contains:/d'  -e '/^$/d' -e 's/^/\//'
52
-    done
53
-}
54
-
55
-extra_files() {
56
-    cat << EOF
57
-/etc
58
-/bin
59
-/bin/busybox
60
-/usr/bin
61
-/usr/bin/dumpcap
62
-/usr/lib
63
-/usr/sbin
64
-/usr/sbin/tcpdump
65
-/var
66
-/var/run
67
-/run
68
-/tmp
69
-EOF
70
-}
71
-
72
-sort_filelist() {
73
-    sort $FILELIST | uniq > $FILELIST.new
74
-    mv -f $FILELIST.new $FILELIST
75
-}
76
-
77
-filter_unnecessary_files() {
78
-# excluded following files and directories recursive
79
-# /usr/lib/debug/usr/lib/kamailio/
80
-# /usr/share/doc/kamailio
81
-# /usr/share/man
82
-# /usr/share/snmp
83
-
84
-    sed -i \
85
-        -e '\|^/usr/lib/debug/|d' \
86
-        -e '\|^/usr/share/doc/kamailio/|d' \
87
-        -e '\|^/usr/share/man/|d' \
88
-        -e '\|^/usr/share/snmp/|d' \
89
-        $FILELIST
90
-}
91
-
92
-ldd_helper() {
93
-    TESTFILE=$1
94
-    LD_PRELOAD=/usr/sbin/kamailio ldd $TESTFILE 2> /dev/null > /dev/null || return
95
-
96
-    LD_PRELOAD=/usr/sbin/kamailio ldd $TESTFILE | sed -e 's/^.* => //' -e 's/ (.*)//' -e 's/\s\+//' -e '/^ldd$/d'
97
-}
98
-
99
-find_binaries() {
100
-    rm -f $FILELIST_BINARY
101
-    set +e
102
-    for f in $(cat $FILELIST)
103
-    do
104
-        ldd_helper /$f >> $FILELIST_BINARY
105
-    done
106
-    set -e
107
-    sort $FILELIST_BINARY | sort | uniq > $FILELIST_BINARY.new
108
-    mv -f $FILELIST_BINARY.new $FILELIST_BINARY
109
-
110
-    # Resolving symbolic links and removing duplicates
111
-    cat $FILELIST_BINARY | xargs realpath > $FILELIST_BINARY.new
112
-    cat $FILELIST_BINARY.new >> $FILELIST_BINARY
113
-    sort $FILELIST_BINARY | sort | uniq > $FILELIST_BINARY.new
114
-    mv -f $FILELIST_BINARY.new $FILELIST_BINARY
115
-}
116
-
117
-tar_files() {
118
-    local TARLIST=/tmp/tarlist
119
-    cat $FILELIST > $TARLIST
120
-    cat $FILELIST_BINARY >> $TARLIST
121
-    tar -czf $TMP_TAR --no-recursion -T $TARLIST
122
-    rm -f $TARLIST
123
-}
124
-
125
-make_image_tar() {
126
-    mkdir -p $BUILD_ROOT
127
-    cd $BUILD_ROOT
128
-    tar xzf $TMP_TAR
129
-    /bin/busybox --install -s bin
130
-    tar czf /usr/src/kamailio/pkg/kamailio/alpine_docker/$IMG_TAR *
131
-}
132
-
133
-prepare_build
134
-build_and_install
135
-#install PCAP tools
136
-apk add --no-cache wireshark-common tcpdump
137
-
138
-kamailio_files > $FILELIST
139
-extra_files >> $FILELIST
140
-sort_filelist
141
-filter_unnecessary_files
142
-find_binaries
143
-tar_files
144
-make_image_tar
145 0
deleted file mode 100755
... ...
@@ -1,14 +0,0 @@
1
-#!/bin/bash -e
2
-
3
-echo "=> Build Kamailio source code"
4
-
5
-if [ ! -z "$SOURCE_BRANCH" ];then
6
-    ENV_OPT="-e SOURCE_BRANCH=$SOURCE_BRANCH"
7
-fi
8
-
9
-if [ ! -z "$GIT_TAG" ];then
10
-    ENV_OPT="$ENV_OPT -e GIT_TAG=$GIT_TAG"
11
-fi
12
-
13
-docker run --volume=`pwd`/../../..:/usr/src/kamailio --volume=`pwd`/build.sh:/build.sh --entrypoint=/build.sh $ENV_OPT alpine:edge
14
-exit $?