aboutsummaryrefslogtreecommitdiffstats
path: root/build.sh
blob: 48587215582bd012fab30d826accfbea9f0fd49f (plain)
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
#!/bin/bash

# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0

set -xe

repo=${REPO:-opnfv}
tag=${BRANCH:-iruya}
arch=${arch-"\
amd64 \
arm64 \
arm"}
image="xtesting"
build_opts=(--pull=true --no-cache --force-rm=true)

for arch in ${arch};do
    if [[ ${arch} == arm64 ]]; then
        find . -name Dockerfile -exec sed -i \
            -e "s|alpine:3.9|arm64v8/alpine:3.9|g" {} +
    elif [[ ${arch} == arm ]]; then
        find . -name Dockerfile -exec sed -i \
            -e "s|alpine:3.9|arm32v6/alpine:3.9|g" {} +
    fi
    (cd docker &&   docker build "${build_opts[@]}" \
        -t "${repo}/${image}:${arch}-${tag}" .)
    docker push "${repo}/${image}:${arch}-${tag}"
    [ "$?" == "0" ] &&
        (sudo docker rmi "${repo}/${image}:${arch}-${tag}"|| true)
    find . -name Dockerfile -exec git checkout \{\} +;
done
exit $?