This repository has been archived by the owner on Jun 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.sh
executable file
·126 lines (105 loc) · 3.5 KB
/
build.sh
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
#!/usr/bin/env bash
F5GC_GIT="https://bitbucket.org/free5GC/free5gc-stage-2.git"
RED='\e[0;31m'
GREEN='\e[0;32m'
MAGENTA='\e[0;35m'
NC='\e[0m'
function banner_echo {
echo -e "${MAGENTA}$1${NC}"
}
function print_banner {
banner_echo " ____ _ _____ ____ ____ ____ "
banner_echo "| _ \ ___ ___| | _____ _ __ | ___| __ ___ ___| ___| / ___|/ ___|"
banner_echo "| | | |/ _ \ / __| |/ / _ \ '__| | |_ | '__/ _ \/ _ \___ \| | _| | "
banner_echo "| |_| | (_) | (__| < __/ | | _|| | | __/ __/___) | |_| | |___ "
banner_echo "|____/ \___/ \___|_|\_\___|_| |_| |_| \___|\___|____/ \____|\____|"
echo ""
}
function log {
echo -e "🔥${GREEN} $(date +"%F %r")[INFO] $0 $1 ${NC}"
}
function logerr {
echo -e "🔥${RED} $(date +"%F %r")[ERRO] $0 $1 ${NC}"
}
[[ -z "$F5GC_VERSION" ]] \
&& {
logerr "F5GC_VERSION env var is not set";
versions=$(git ls-remote --tags $F5GC_GIT | awk -F/ '{ print $3 }' | grep -v '{}' | tr '\n' ' ')
logerr "available versions are: $versions"
logerr "try: export F5GC_VERSION=v2.0.2"
exit 1;
}
function build_base {
DOCKER_IMAGE="free5gc-base-v2:$F5GC_VERSION"
IMG_CHECK=$(docker images -q $DOCKER_IMAGE)
if [ "$IMG_CHECK" != "" ] ; then
log "docker image '$DOCKER_IMAGE' is found locally, skipping build"
else
log "build 'base' image"
docker build \
--build-arg F5GC_VERSION=$F5GC_VERSION \
-t $DOCKER_IMAGE \
./base > /dev/null
fi
}
function build_nfs {
# Build: amf ausf nrf nssf pcf smf udm udr n3iwf
for module in amf ausf nrf nssf pcf smf udm udr n3iwf; do
export F5GC_MODULE=$module
DOCKER_IMAGE="free5gc-$F5GC_MODULE-v2:$F5GC_VERSION"
IMG_CHECK=$(docker images -q $DOCKER_IMAGE)
if [ "$IMG_CHECK" != "" ] ; then
log "docker image '$DOCKER_IMAGE' is found locally, skipping build"
else
log "build image for function '$module'"
docker build \
--build-arg F5GC_VERSION=$F5GC_VERSION \
--build-arg F5GC_MODULE=$F5GC_MODULE \
-t $DOCKER_IMAGE \
./nfs > /dev/null
fi
done
}
function build_upf {
# Build upf
export F5GC_MODULE="upf"
DOCKER_IMAGE="free5gc-$F5GC_MODULE-v2:$F5GC_VERSION"
IMG_CHECK=$(docker images -q $DOCKER_IMAGE)
if [ "$IMG_CHECK" != "" ] ; then
log "docker image '$DOCKER_IMAGE' is found locally, skipping build"
else
log "build image for module 'upf'"
docker build \
--build-arg F5GC_VERSION=$F5GC_VERSION \
--build-arg F5GC_MODULE=$F5GC_MODULE \
-t $DOCKER_IMAGE \
./upf > /dev/null
fi
}
function build_webui {
# Build webui
export F5GC_MODULE="webui"
DOCKER_IMAGE="free5gc-$F5GC_MODULE-v2:$F5GC_VERSION"
IMG_CHECK=$(docker images -q $DOCKER_IMAGE)
if [ "$IMG_CHECK" != "" ] ; then
log "docker image '$DOCKER_IMAGE' is found locally, skipping build"
else
log "build image for module 'webui'"
docker build \
--build-arg F5GC_VERSION=$F5GC_VERSION \
--build-arg F5GC_MODULE=$F5GC_MODULE \
-t $DOCKER_IMAGE \
./webui > /dev/null
fi
}
clear
print_banner
echo -e "Grab a coffee, this might take some time.."
start=`date +%s`
build_base
build_nfs
build_upf
build_webui
end=`date +%s`
duration=$((end-start))
log "completed in $duration seconds"