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