-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompose.yml
345 lines (315 loc) · 8.82 KB
/
compose.yml
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
include:
- core.yml
- billing.yml
- monitor.yml
x-kamailio: &kamailio
image: kamailio
command: -f /etc/ims/kamailio.cfg
environment: &env
REALM: ${REALM}
expose:
- 5060/tcp
- 5060/udp
dns: ${DNSIP}
healthcheck:
test: wget -qO- 127.0.0.1:9090/check
retries: 60
interval: 5s
start_period: 5s
services:
pcscf:
<< : *kamailio
environment:
<< : *env
IPSEC: ${IPSEC}
configs:
- source: pcscf.cfg
target: /etc/ims/kamailio.cfg
- source: pcscf.xml
target: /etc/ims/diameter.xml
- source: monitor.cfg
target: /etc/ims/monitor.cfg
cap_add:
- NET_ADMIN
networks:
default:
ipv4_address: ${IPSEC}
depends_on:
kmod:
condition: service_completed_successfully
build:
context: .
dockerfile_inline: |
FROM alpine:edge
RUN apk add kamailio-extras kamailio-ims kamailio-redis kamailio-presence kamailio-debugger
ENTRYPOINT ["kamailio", "-DD", "-E"]
icscf:
<< : *kamailio
environment:
<< : *env
DBURL: redis://redis:6379/1
configs:
- source: icscf.cfg
target: /etc/ims/kamailio.cfg
- source: icscf.xml
target: /etc/ims/diameter.xml
- source: s_cscf.map
target: /etc/ims/schema/s_cscf
- source: s_cscf_capabilities.map
target: /etc/ims/schema/s_cscf_capabilities
- source: nds_trusted_domains.map
target: /etc/ims/schema/nds_trusted_domains
- source: monitor.cfg
target: /etc/ims/monitor.cfg
depends_on:
dbprep:
condition: service_completed_successfully
scscf:
<< : *kamailio
configs:
- source: scscf.cfg
target: /etc/ims/kamailio.cfg
- source: scscf.xml
target: /etc/ims/diameter.xml
- source: CxData.xsd
target: /etc/ims/CxData.xsd
- source: monitor.cfg
target: /etc/ims/monitor.cfg
dns:
image: coredns/coredns
command: -conf /etc/coredns/Corefile
configs:
- source: dns
target: /etc/coredns/Corefile
networks:
default:
ipv4_address: ${DNSIP}
rtpengine:
command: --no-log-timestamps --config-file=/etc/rtpengine.conf
configs:
- source: rtpengine
target: /etc/rtpengine.conf
networks:
default:
ipv4_address: ${RTPIP}
build:
context: .
dockerfile_inline: |
FROM ubuntu:noble
RUN apt update && apt install --no-install-recommends -y rtpengine-daemon
ENTRYPOINT ["rtpengine"]
# as UE IPs will not be in the setup IP range, they need special attention
route:
image: alpine
command: ip route add ${UENET} via ${UPFIP}
network_mode: service:pcscf
cap_add:
- NET_ADMIN
kmod:
image: alpine
command:
- modprobe
- -a
- ah4
- ah6
- esp4
- esp6
- xfrm4_tunnel
- xfrm6_tunnel
- xfrm_user
- ip_tunnel
- tunnel4
- tunnel6
cap_add:
- SYS_MODULE
volumes:
- /lib/modules:/lib/modules
dbprep:
image: valkey/valkey:8.1-alpine
command: valkey-cli -u redis://redis:6379/1 HSET s_cscf:entry::1 s_cscf_uri sip:scscf.ims.${REALM}
restart: on-failure
redis:
image: valkey/valkey:8.1-alpine
expose:
- 6379/tcp
test:
profiles:
- test
command: gtp
environment:
K: ${K}
OPC: ${OPC}
PLMN: ${MCC}${MNC}
DIAL: ${DIAL}
SCALE: ${SCALE}
REALM: ims.${REALM}
IPSEC: /usr/lib/ipsec.so
cap_add:
- NET_ADMIN
depends_on:
icscf:
condition: service_healthy
scscf:
condition: service_healthy
build:
context: .
dockerfile_inline: |
FROM ubuntu:jammy AS build
RUN apt update && apt install -y --no-install-recommends \
git build-essential cmake ninja-build libtool yasm bind9-host \
ragel \
libsrtp2-dev libssl-dev libopus-dev \
libspeexdsp-dev \
libavutil-dev libswscale-dev libavcodec-dev \
libvpx-dev libyuv-dev libgsm1-dev swig \
python3-dev python3-pip
RUN git clone --depth=1 https://github.com/lyatanski/doubango.git
WORKDIR doubango
RUN cmake -B out -G Ninja #-D CMAKE_BUILD_TYPE=Debug
RUN cmake --build out --target install && cp out/_deps/libmnl/usr/lib/libmnl.so* /usr/local/lib/ && ldconfig
FROM golang AS gobld
COPY ./test /go
RUN go build -o gtp
FROM ubuntu:jammy
RUN apt update && apt install --no-install-recommends -y python3-pip iproute2 bind9-host
COPY --from=build /doubango/out/_deps/libmnl/usr/lib/libmnl.so* /usr/local/lib/
COPY --from=build /doubango/out/plugins/ipsec_linux/ipsec.so /usr/lib/
COPY --from=gobld /go/gtp /usr/bin/
COPY ./test/sip.py /opt/
RUN --mount=type=bind,from=build,source=/doubango/out/bindings/python/,target=/opt/python,rw ldconfig && pip install /opt/python
configs:
monitor.cfg:
content: |
listen=tcp:0.0.0.0:9090
http_reply_parse=yes
tcp_accept_no_cl=yes
loadmodule "xhttp.so"
loadmodule "xhttp_prom.so"
modparam("xhttp_prom", "xhttp_prom_stats", "all")
event_route[xhttp:request] {
if(prom_check_uri())
prom_dispatch();
else if(HEALTH)
xhttp_reply("200", "OK", "text/plain", "ready to serve");
else
xhttp_reply("500", "KO", "text/plain", "try again later");
}
pcscf.cfg:
file: cscf/proxy.cfg
pcscf.xml:
content: |
<?xml version="1.0" encoding="UTF-8"?>
<DiameterPeer
FQDN="pcscf.ims.${REALM}"
Realm="ims.${REALM}"
Vendor_Id="10415"
Product_Name="CDiameterPeer"
Workers="1"
>
<Peer FQDN="pcrf.epc.${REALM}" Realm="epc.${REALM}" port="3868"/>
<Auth id="16777236" vendor="10415"/> <!-- Rx 3GPP -->
<SupportedVendor vendor="10415" />
<DefaultRoute FQDN="pcrf.epc.${REALM}" metric="1"/>
</DiameterPeer>
icscf.cfg:
file: cscf/interrogating.cfg
icscf.xml:
content: |
<?xml version="1.0" encoding="UTF-8"?>
<DiameterPeer
FQDN="icscf.ims.${REALM}"
Realm="ims.${REALM}"
Vendor_Id="10415"
Product_Name="CDiameterPeer"
Workers="1"
>
<Peer FQDN="hss.epc.${REALM}" Realm="epc.${REALM}" port="3868"/>
<Auth id="16777216" vendor="10415"/> <!-- Cx 3GPP -->
<SupportedVendor vendor="10415" />
<DefaultRoute FQDN="hss.epc.${REALM}" metric="1"/>
</DiameterPeer>
s_cscf.map:
content: |
id/int,name/string,s_cscf_uri/string
1
s_cscf_capabilities.map:
content: |
id/int,id_s_cscf/int,capability/int
1
nds_trusted_domains.map:
content: |
id/int,trusted_domain/string
1
scscf.cfg:
file: cscf/serving.cfg
CxData.xsd:
file: cscf/CxData_Type_Rel18.xsd
scscf.xml:
content: |
<?xml version="1.0" encoding="UTF-8"?>
<DiameterPeer
FQDN="scscf.ims.${REALM}"
Realm="ims.${REALM}"
Vendor_Id="10415"
Product_Name="CDiameterPeer"
Workers="1"
>
<Peer FQDN="hss.epc.${REALM}" Realm="epc.${REALM}" port="3868"/>
<Peer FQDN="ocs.${REALM}" Realm="${REALM}" port="3868"/>
<Auth id="16777216" vendor="10415"/> <!-- Cx 3GPP -->
<Auth id="4" vendor="10415"/> <!-- Ro 3GPP -->
<SupportedVendor vendor="10415" />
<Realm name="${REALM}">
<Route FQDN="ocs.${REALM}" metric="1"/>
</Realm>
<DefaultRoute FQDN="hss.epc.${REALM}" metric="1"/>
</DiameterPeer>
rtpengine:
content: |
[rtpengine]
foreground = true
log-level = 6
log-stderr = true
table = -1
listen-ng = 0.0.0.0:9910
interface = internal/${RTPIP}
timeout = 60
silent-timeout = 3600
tos = 184
port-min = 30000
port-max = 40000
dns:
content: |
. {
errors
log
health {
lameduck 5s
}
ready
template IN SRV {
match (^|[.])(?P<name>.cscf)\.ims\.mnc\d{2,3}\.mcc\d{3}\.3gppnetwork.org
answer "{{ .Name }} 1D SRV 0 0 5060 {{ .Group.name }}."
fallthrough
}
template IN SRV {
match ims\.mnc\d{2,3}\.mcc\d{3}\.3gppnetwork.org
answer "{{ .Name }} 1D SRV 0 0 5060 icscf."
fallthrough
}
template IN ANY {
match (^|[.])(?P<name>[^.]*).*\.mnc\d{2,3}\.mcc\d{3}\.3gppnetwork.org
answer "{{ .Name }} 1D IN CNAME {{ .Group.name }}."
fallthrough
}
forward . /etc/resolv.conf
cache 30
loop
reload
loadbalance
}
networks:
default:
ipam:
config:
- subnet: ${SUBNET}