Skip to content

Commit

Permalink
Dockerize the gw
Browse files Browse the repository at this point in the history
  • Loading branch information
abousselmi committed May 15, 2024
1 parent 31f8399 commit 0271933
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM alpine:3.19 as buildenv

RUN apk add --no-cache git ca-certificates \
libmnl-dev build-base make automake autoconf libtool pkgconfig

RUN git clone https://gitea.osmocom.org/cellular-infrastructure/libgtpnl \
&& cd /libgtpnl && autoreconf -fi && ./configure && make

FROM alpine:3.19

WORKDIR /nf-gtp-gw

COPY --from=buildenv /libgtpnl/src/.libs/libgtpnl.so* /usr/lib/
COPY --from=buildenv /libgtpnl/tools/.libs/* .
COPY ./startup.sh ./

RUN apk add --no-cache libmnl iproute2 \
&& ldconfig /

ENV TEID_N3_GNB=100 \
TEID_N3_UPF=200 \
N3_UPF_IP=127.0.0.1 \
N6_APP_SERVER_IP=127.0.0.2 \
N6_APP_SERVER_SUBNET=127.0.0.0/8

ENTRYPOINT ["./startup.sh"]
37 changes: 37 additions & 0 deletions startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

# User defined variables
#TEID_N3_UPF
#TEID_N3_GNB
#N3_UPF_IP
#N6_APP_SERVER_IP
#N6_APP_SERVER_SUBNET

# Pre-defined variables
IP_VERSION="ip"
MTU=1500
GTP_DEV="ue-tun"

function log {
echo -e "[INFO] $1"
sleep 1
}

function start {
log "create gtp devices (run in bg mode)"
./gtp-link add $GTP_DEV $IP_VERSION &

log "configure mtu of gtp devices"
ip link set mtu $MTU dev $GTP_DEV

log "create gtp tunnel: [TEID_N3_GNB=$TEID_N3_GNB, TEID_N3_UPF=$TEID_N3_UPF, \
N3_UPF_IP=$N3_UPF_IP, N6_APP_SERVER_IP=$N6_APP_SERVER_IP]"
./gtp-tunnel add $GTP_DEV v1 $TEID_N3_UPF $TEID_N3_GNB $N6_APP_SERVER_IP $N3_UPF_IP
log "$(./gtp-tunnel list)"

log "configure routes using gtp devices"
ip route add $N6_APP_SERVER_SUBNET dev $GTP_DEV
}

start
sleep infinity

0 comments on commit 0271933

Please sign in to comment.