Restructure server
[ta/remote-installer.git] / scripts / build.sh
1 #!/bin/bash
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 cd "$(dirname "$0")"/..
17
18 TAR_IMAGE="remote-installer.tar"
19
20 help()
21 {
22         echo -e "$(basename $0) [-hs]"
23         echo -e "   -h  display this help"
24         echo -e "   -s  save image as tar to $TAR_IMAGE"
25     echo
26     echo -e "Proxy configuration is taken from environment variables"
27     echo -e "http_proxy, https_proxy and no_proxy"
28 }
29
30 while getopts "hs" arg; do
31     case $arg in
32         h)
33             help
34                         exit 0
35             ;;
36         s)
37                     SAVE_IMAGE="yes"
38             ;;
39   esac
40 done
41
42 docker build \
43   --no-cache \
44   --force-rm \
45   --build-arg HTTP_PROXY="${http_proxy}" \
46   --build-arg HTTPS_PROXY="${https_proxy}" \
47   --build-arg NO_PROXY="${no_proxy}" \
48   --build-arg http_proxy="${http_proxy}" \
49   --build-arg https_proxy="${https_proxy}" \
50   --build-arg no_proxy="${no_proxy}" \
51   --tag remote-installer \
52   --file docker-build/remote-installer/Dockerfile .
53
54
55 # could be compressed but it's only used until there is an registry
56 if [ -n "$SAVE_IMAGE" ]
57 then
58     echo -e "Creating image tar ball at : $(dirname "$0")/$TAR_IMAGE"
59     docker image save remote-installer >"$(dirname "$0")"/"$TAR_IMAGE"
60 fi