-
Notifications
You must be signed in to change notification settings - Fork 34
/
build-priv.sh
executable file
·161 lines (138 loc) · 6.37 KB
/
build-priv.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
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
#!/bin/bash
# Build opflex and aci-containers private images in non jenkins environment
# 1. go get github.com/noironetworks/aci-containers
# 2. mkdir -p $HOME/work && cd $HOME/work
# 3. git clone https://github.com/noironetworks/opflex opflex
# 4. docker login as DOCKER_HUB_ID
# 5. cd docker && git checkout * when switching between UBI and Alpine builds
# usage: build_priv.sh <ubi|alpine> docker-id :tag
# example: ./build-priv.sh <alpine|ubi> challa :demo
set -x
TYPE=$1
DOCKER_HUB_ID=$2
DOCKER_TAG=$3
UBI_URI="registry.access.redhat.com\/ubi8\/ubi:latest"
UBI_MIN_URI="registry.access.redhat.com\/ubi8\/ubi-minimal:latest"
UBIBASE_OPFLEX="registry.hub.docker.com\/noirolabs\/ubibase-opflex:latest"
UBIBASE_OPFLEX_BUILD_BASE="registry.hub.docker.com\/noirolabs\/ubibase-opflex-build-base:latest"
UBIBASE_ACI="registry.hub.docker.com\/noirolabs\/ubibase-aci:latest"
opflex_arr='Dockerfile-opflex Dockerfile-opflexserver'
containers_arr='Dockerfile-controller Dockerfile-host Dockerfile-cnideploy Dockerfile-gbpserver Dockerfile-openvswitch'
if [ "$#" -ne 3 ]; then
echo "usage: build_priv.sh <ubi|alpine> docker-id :tag"
exit -1
fi
if [[ $TYPE == "alpine" ]]; then
echo "Starting Alpine build"
DOCKER_DIR=docker/dev/alpine
elif [[ $TYPE == "ubi" ]]; then
echo "Starting Ubi build"
DOCKER_DIR=docker
sed -i -e "s/FROM ${UBI_MIN_URI}/FROM ${UBIBASE_OPFLEX_BUILD_BASE}/g" -e ':a;N;$!ba;s/RUN microdnf.*microdnf clean all/RUN :/g' \
$DOCKER_DIR/Dockerfile-opflex-build-base
for c in $opflex_arr; do
sed -i -e "s/FROM ${UBI_URI}/FROM ${UBIBASE_OPFLEX}/g" -e ':a;N;$!ba;s/RUN yum.*yum clean all/RUN :/g' $DOCKER_DIR/$c
done
for c in $containers_arr; do
sed -i -e "s/FROM ${UBI_URI}/FROM ${UBIBASE_ACI}/g" -e ':a;N;$!ba;s/RUN yum.*yum clean all/RUN :/g' $DOCKER_DIR/$c
done
fi
# Modify docker/Dockerfile-opflex-build to reflect DOCKER_HUB_ID and DOCKER_TAG
sed -i -e "s/FROM noiro\/opflex-build-base/FROM $DOCKER_HUB_ID\/opflex-build-base$DOCKER_TAG/g" \
$DOCKER_DIR/Dockerfile-opflex-build
[ -z "$GOPATH" ] && GOPATH=$HOME/go
export GOPATH
ACICONTAINERS_DIR=.
[ -z "$OPFLEX_DIR" ] && OPFLEX_DIR=$HOME/work/opflex
export OPFLEX_DIR
[ -z "$DOCKER_TAG" ] && DOCKER_TAG=
export DOCKER_HUB_ID
export DOCKER_TAG
set -Eeuxo pipefail
echo "starting opflex build"
pushd $ACICONTAINERS_DIR
rm -Rf build
docker build -t $DOCKER_HUB_ID/opflex-build-base$DOCKER_TAG -f $DOCKER_DIR/Dockerfile-opflex-build-base docker
#docker push $DOCKER_HUB_ID/opflex-build-base$DOCKER_TAG
pushd $OPFLEX_DIR/genie
mvn compile exec:java
popd
docker build -t $DOCKER_HUB_ID/opflex-build$DOCKER_TAG -f $DOCKER_DIR/Dockerfile-opflex-build $OPFLEX_DIR
#docker push $DOCKER_HUB_ID/opflex-build$DOCKER_TAG
mkdir -p build/opflex/dist
mkdir -p build/opflex/dist/agent
mkdir -p build/opflex/dist/server
docker run $DOCKER_HUB_ID/opflex-build$DOCKER_TAG tar -c -C /usr/local \
bin/opflex_agent bin/gbp_inspect bin/mcast_daemon bin/opflex_server \
| tar -x -C build/opflex/dist
docker run -w /usr/local $DOCKER_HUB_ID/opflex-build$DOCKER_TAG /bin/sh -c 'find lib \(\
-name '\''libopflex*.so*'\'' -o \
-name '\''libmodelgbp*so*'\'' -o \
-name '\''libopenvswitch*so*'\'' -o \
-name '\''libsflow*so*'\'' -o \
-name '\''libprometheus-cpp-*so*'\'' -o \
-name '\''libgrpc*so*'\'' -o \
-name '\''libproto*so*'\'' -o \
-name '\''libre2*so*'\'' -o \
-name '\''libupb*so*'\'' -o \
-name '\''libabsl*so*'\'' -o \
-name '\''libssl*so*'\'' -o \
-name '\''libcrypto*so*'\'' -o \
-name '\''libaddress_sorting*so*'\'' -o \
-name '\''libgpr*so*'\'' -o \
-name '\''libofproto*so*'\'' \
\) ! -name '\''*debug'\'' \
| xargs tar -c ' \
| tar -x -C build/opflex/dist
docker run -w /usr/local $DOCKER_HUB_ID/opflex-build$DOCKER_TAG /bin/sh -c 'find lib \(\
-name '\''libopflex*.so*'\'' -o \
-name '\''libmodelgbp*so*'\'' -o \
-name '\''libopenvswitch*so*'\'' -o \
-name '\''libsflow*so*'\'' -o \
-name '\''libprometheus-cpp-*so*'\'' -o \
-name '\''libofproto*so*'\'' \
\) ! -name '\''*debug'\'' \
| xargs tar -c ' \
| tar -x -C build/opflex/dist/agent
docker run -w /usr/local $DOCKER_HUB_ID/opflex-build$DOCKER_TAG /bin/sh -c 'find lib \(\
-name '\''libopflex*.so*'\'' -o \
-name '\''libmodelgbp*so*'\'' -o \
-name '\''libprometheus-cpp-*so*'\'' -o \
-name '\''libgrpc*so*'\'' -o \
-name '\''libproto*so*'\'' -o \
-name '\''libre2*so*'\'' -o \
-name '\''libupb*so*'\'' -o \
-name '\''libabsl*so*'\'' -o \
-name '\''libssl*so*'\'' -o \
-name '\''libcrypto*so*'\'' -o \
-name '\''libaddress_sorting*so*'\'' -o \
-name '\''libgpr*so*'\'' \
\) ! -name '\''*debug'\'' \
| xargs tar -c ' \
| tar -x -C build/opflex/dist/server
docker run -w /usr/local $DOCKER_HUB_ID/opflex-build$DOCKER_TAG /bin/sh -c \
'find lib bin -name '\''*.debug'\'' | xargs tar -cz' \
> opflex-debuginfo.tar.gz
cp docker/launch-opflexagent.sh build/opflex/dist/bin/
cp docker/launch-mcastdaemon.sh build/opflex/dist/bin/
cp docker/launch-opflexserver.sh build/opflex/dist/bin/
cp $DOCKER_DIR/Dockerfile-opflex build/opflex/dist/
cp -Rf $DOCKER_DIR/licenses build/opflex/dist/
docker build -t $DOCKER_HUB_ID/opflex$DOCKER_TAG -f ./build/opflex/dist/Dockerfile-opflex build/opflex/dist
docker push $DOCKER_HUB_ID/opflex$DOCKER_TAG
echo "starting aci-containers build"
make all-static
make go-gbp-build
docker build -t $DOCKER_HUB_ID/aci-containers-controller$DOCKER_TAG -f $DOCKER_DIR/Dockerfile-controller .
docker push $DOCKER_HUB_ID/aci-containers-controller$DOCKER_TAG
docker/copy_iptables.sh $DOCKER_HUB_ID/opflex-build-base$DOCKER_TAG dist-static
docker build -t $DOCKER_HUB_ID/aci-containers-host$DOCKER_TAG -f $DOCKER_DIR/Dockerfile-host .
docker push $DOCKER_HUB_ID/aci-containers-host$DOCKER_TAG
docker build -t $DOCKER_HUB_ID/cnideploy$DOCKER_TAG -f $DOCKER_DIR/Dockerfile-cnideploy docker
docker push $DOCKER_HUB_ID/cnideploy$DOCKER_TAG
docker build -t $DOCKER_HUB_ID/gbp-server$DOCKER_TAG -f $DOCKER_DIR/Dockerfile-gbpserver .
docker push $DOCKER_HUB_ID/gbp-server$DOCKER_TAG
echo "starting openvswitch build"
docker build -t $DOCKER_HUB_ID/openvswitch$DOCKER_TAG -f $DOCKER_DIR/Dockerfile-openvswitch .
docker push $DOCKER_HUB_ID/openvswitch$DOCKER_TAG
popd