-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile_opensips
More file actions
190 lines (165 loc) · 4.71 KB
/
Dockerfile_opensips
File metadata and controls
190 lines (165 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# syntax=docker/dockerfile:1
ARG UBUNTUVER="25.10"
# This is for building opensips
FROM ubuntu:$UBUNTUVER AS build
LABEL org.opencontainers.image.authors="https://github.com/RVgo4it"
# Update and install dev env for opensips
RUN apt -y update && \
# Install common tools
apt -y install sudo \
vim \
wget \
file \
# Install development tools
make \
bison \
flex \
curl \
libcurl4t64 \
libcurl4-openssl-dev \
libssl-dev \
dpkg-dev \
debhelper \
libevent-dev \
libcurl4-openssl-dev \
libglib2.0-dev \
libhiredis-dev \
libpcre3-dev \
libssl-dev \
libxmlrpc-core-c3-dev \
markdown \
zlib1g-dev \
module-assistant \
dkms \
gettext \
libavcodec-dev \
libavfilter-dev \
libavformat-dev \
libjson-glib-dev \
libpcap-dev \
nfs-common \
libbencode-perl \
libcrypt-rijndael-perl \
libdigest-hmac-perl \
libio-socket-inet6-perl \
libsocket6-perl \
libmysqlclient-dev \
libconfuse-dev \
libdb-dev \
libexpat1-dev \
libmaxminddb-dev \
libjson-c-dev \
librdkafka-dev \
libldap2-dev \
liblua5.1-0-dev \
libmemcached-dev \
libmicrohttpd-dev \
libncurses5-dev \
libperl-dev \
libpq-dev \
librabbitmq-dev \
libradcli-dev \
libsctp-dev \
libsnmp-dev \
libsqlite3-dev \
libxml2-dev \
python-is-python3 \
python3-dev \
python-dev-is-python3 \
unixodbc-dev \
xsltproc \
git
USER root
WORKDIR /root
# master or other releases
ARG BRANCH="3.6"
RUN git clone https://github.com/OpenSIPS/opensips.git --recursive -b ${BRANCH} ~/opensips
# modules
ARG MODS="tls_wolfssl db_sqlite tls_openssl tls_mgm proto_tls proto_udp sqlops presence xcap presence_xml json rest_client xml"
RUN echo Make modules: ${MODS}
# force make's Makefile to use nproc, not getconf for CPU count. this mostly for wolfssl
RUN rm /bin/getconf
# use bash for all shells w/ ~/.bashstart
SHELL ["bash", "-c"]
RUN ln -s bash /bin/sh.bash && \
mv /bin/sh.bash /bin/sh
ENV BASH_ENV=/root/.bashstart
RUN echo BASH_ENV=/root/.bashstart >> ~/.bashstart
# check host memory for build options
RUN read X KELO Y < /proc/meminfo && \
echo from /proc/meminfo = ${KELO}kb && \
MEGS=$((KELO/1024)); \
echo Memory: ${MEGS}mb && \
if [ $MEGS -le 512 ] ; then \
echo export OMP_THREAD_LIMIT=1 >> ~/.bashstart ; \
elif [ $MEGS -le 1024 ] ; then \
echo export OMP_THREAD_LIMIT=2 >> ~/.bashstart ; \
elif [ $MEGS -le 2048 ] ; then \
echo export OMP_THREAD_LIMIT=3 >> ~/.bashstart ; \
fi
RUN echo $CPU Limit: $OMP_THREAD_LIMIT && \
printf "nproc = " && nproc
# build opensips
RUN cd ~/opensips && \
make clean && \
ln -s /root/opensips/modules/tls_wolfssl/lib/wolfssl /root/opensips/modules/tls_wolfssl/lib/include && \
mkdir -p /root/inst/lib && \
mkdir /root/inst/lib64 && \
make prefix=/ include_modules="${MODS}" all && \
make prefix=/ basedir=/root/inst include_modules="${MODS}" install
# This is for compiling opensips-cli
FROM ubuntu:$UBUNTUVER AS compile-image
LABEL org.opencontainers.image.authors="https://github.com/RVgo4it"
USER root
WORKDIR /root
# Set Environment Variables
ENV DEBIAN_FRONTEND=noninteractive
# Update and install dev env for opensips
RUN apt -y update && \
apt -y install git libffi-dev python3-setuptools python3-dev python3-full default-libmysqlclient-dev gcc
# Make virtual python env for opensips-cli
RUN python3 -m venv /opt/venv
# Make sure we use the virtual env.
ENV PATH="/opt/venv/bin:$PATH"
RUN git clone https://github.com/OpenSIPS/opensips-cli.git /usr/src/opensips-cli
COPY mmsgate2/tls-patch/hashes.txt mmsgate2/tls-patch/tls.patch ./
RUN if md5sum --check hashes.txt; then patch /usr/src/opensips-cli/opensipscli/modules/tls.py <tls.patch; else echo Skipping patch; fi
RUN cd /usr/src/opensips-cli && \
pip3 install . && \
pip3 install --upgrade urllib3 && \
pip3 install cryptography && \
python -m pip install --upgrade pip && \
rm -rf /usr/src/opensips-cli
# This is the final image
FROM ubuntu:$UBUNTUVER
LABEL org.opencontainers.image.authors="https://github.com/RVgo4it"
# Update and install items needed for opensips
RUN apt -y update && \
apt -y upgrade && \
# Install common tools
apt -y install sudo \
iputils-ping \
iproute2 \
sqlite3 \
# Install all dependencies
python3 \
libmysqlclient24
# Clean
RUN apt -y autoremove && \
apt -y clean
# need sopts for opensips
RUN mkdir -m=755 /etc/opensips && \
mkdir -m=777 /run/opensips
# bring over the python virtual env
COPY --from=compile-image /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN echo 'PATH=/opt/venv/bin:$PATH' >/etc/profile.d/opensips.sh
# bring over opensips
COPY --from=build /root/inst/etc/opensips/ /etc/opensips/
COPY --from=build /root/inst/sbin/ /usr/sbin/
COPY --from=build /root/inst/lib64/ /usr/lib64/
COPY --from=build /root/inst/lib/ /usr/lib/
COPY --from=build /root/inst/share/ /usr/share/
USER root
WORKDIR /root
CMD ["bash"]