@@ -37,7 +37,6 @@ function append_log_file() {
37
37
}
38
38
39
39
log " Target platform: $LINUX_DISTR :$LINUX_DISTR_VER "
40
- [[ " ${CONTRAIL_BUILD_FROM_SOURCE} " == ' true' ]] && log " Contrail source root: $CONTRAIL_SOURCE "
41
40
log " Contrail container tag: $CONTRAIL_CONTAINER_TAG "
42
41
log " Contrail registry: $CONTRAIL_REGISTRY "
43
42
log " Contrail repository: $CONTRAIL_REPOSITORY "
@@ -87,11 +86,6 @@ function process_container() {
87
86
log " Building $container_name " | append_log_file $logfile true
88
87
89
88
local build_arg_opts=' --network host'
90
- if [[ " ${CONTRAIL_BUILD_FROM_SOURCE} " == ' true' ]] ; then
91
- if [[ -e " ${docker_file} .build_from_source" ]] ; then
92
- docker_file=" ${docker_file} .build_from_source"
93
- fi
94
- fi
95
89
if [[ " $docker_ver " < ' 17.06' ]] ; then
96
90
# old docker can't use ARG-s before FROM:
97
91
# comment all ARG-s before FROM
@@ -116,9 +110,6 @@ function process_container() {
116
110
build_arg_opts+=" --build-arg UBUNTU_DISTR=${UBUNTU_DISTR} "
117
111
build_arg_opts+=" --build-arg VENDOR_NAME=${VENDOR_NAME} "
118
112
build_arg_opts+=" --build-arg VENDOR_DOMAIN=${VENDOR_DOMAIN} "
119
- if [[ " ${CONTRAIL_BUILD_FROM_SOURCE} " == ' true' ]] ; then
120
- build_arg_opts+=" --build-arg CONTRAIL_BUILD_FROM_SOURCE=${CONTRAIL_BUILD_FROM_SOURCE} "
121
- fi
122
113
123
114
if [[ -f ./$dir /.externals ]]; then
124
115
local item=' '
@@ -143,57 +134,10 @@ function process_container() {
143
134
local duration=$( date +" %s" )
144
135
(( duration -= start_time ))
145
136
log " Docker build duration: $duration seconds" | append_log_file $logfile
146
- local relative_build_src_path=${dir} /build_src
147
- if [[ ${exit_code} -eq 0 && " ${CONTRAIL_BUILD_FROM_SOURCE} " == ' true' && -e " ${relative_build_src_path} " ]] ; then
148
- local rel_build_src_path=" contrail-container-builder/containers/${dir## ./ } /build_src"
149
- # Setup from source
150
- # RHEL has old docker that does not support neither staged build nor mount option
151
- # 'RUN --mount' (still experimental at the moment of writing this comment).
152
- # So, there is WA: previously build image is empty w/o RPMs but with all
153
- # other stuff required, so, now the final step to run a intermediate container,
154
- # install components inside and commit is as the final image.
155
- log " Rel build src path is ${rel_build_src_path} " | append_log_file $logfile
156
- local cmd=$( sudo docker inspect -f " {{json .Config.Cmd }}" ${target_name} )
157
- local entrypoint=$( sudo docker inspect -f " {{json .Config.Entrypoint }}" ${target_name} )
158
- local intermediate_base=" ${container_name} -src"
159
- local run_arguments=" --name $intermediate_base --network host "
160
- if [[ $container_name == " contrail-base" || $container_name == " contrail-controller-webui-base" ]] ; then
161
- run_arguments+=" -e " BASE_EXTRA_RPMS=${BASE_EXTRA_RPMS} " "
162
- fi
163
- if [[ $container_name == " contrail-general-base" ]] ; then
164
- run_arguments+=" -e " GENERAL_EXTRA_RPMS=${GENERAL_EXTRA_RPMS} " "
165
- run_arguments+=" -e " YUM_ENABLE_REPOS=$YUM_ENABLE_REPOS " "
166
- fi
167
- run_arguments+=" -e " CONTRAIL_SOURCE=/root/contrail" -e " CONTAINER_SOURCE_DATA_PATH=$rel_build_src_path " -e " LINUX_DISTR=${LINUX_DISTR} " -v ${CONTRAIL_SOURCE} :/root/contrail:z --entrypoint /root/contrail/contrail-container-builder/containers/build_from_src.sh ${target_name} "
168
- log " Run command is \" Docker run ${run_arguments} \" " | append_log_file $logfile
169
- sudo docker run ${run_arguments} 2>&1 | append_log_file $logfile
170
- exit_code=${PIPESTATUS[0]}
171
- if [ ${exit_code} -eq 0 ]; then
172
- if [[ " ${cmd} " == ' null' ]]; then
173
- sudo docker commit --change " ENTRYPOINT ${entrypoint} " \
174
- ${intermediate_base} ${intermediate_base} 2>&1 | append_log_file $logfile
175
- exit_code=${PIPESTATUS[0]}
176
- else
177
- sudo docker commit --change " CMD ${cmd} " \
178
- --change " ENTRYPOINT ${entrypoint} " \
179
- ${intermediate_base} ${intermediate_base} 2>&1 | append_log_file $logfile
180
- exit_code=${PIPESTATUS[0]}
181
- fi
182
- # retag containers
183
- [ ${exit_code} -eq 0 ] && sudo docker tag $intermediate_base ${target_name} || exit_code=1
184
- fi
185
- local duration_src=$( date +" %s" )
186
- (( duration_src -= duration ))
187
- log " Docker build from source duration: $duration_src seconds" | append_log_file $logfile
188
- fi
189
137
if [ $exit_code -eq 0 -a ${CONTRAIL_REGISTRY_PUSH} -eq 1 ]; then
190
138
sudo docker push $target_name 2>&1 | append_log_file $logfile
191
139
exit_code=${PIPESTATUS[0]}
192
140
fi
193
- if [[ -n " ${intermediate_base} " && " ${CONTRAIL_BUILD_FROM_SOURCE} " == ' true' ]] ; then
194
- log " Remove ${intermediate_base} temp build container" | append_log_file $logfile
195
- sudo docker rm -f ${intermediate_base} || true 2>&1 | append_log_file $logfile
196
- fi
197
141
duration=$( date +" %s" )
198
142
(( duration -= start_time ))
199
143
if [ ${exit_code} -eq 0 ]; then
0 commit comments