Gergely Csatari | 9205c55 | 2021-09-08 11:53:02 +0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2021 Nokia |
| 4 | # Licensed under the Apache License 2.0 |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | |
| 7 | # Build script to create c2m container. |
| 8 | |
| 9 | set -x |
| 10 | |
| 11 | build_env="no_proxy" |
| 12 | proxy="" |
| 13 | if [[ -z "${http_proxy}" ]]; then |
| 14 | echo "http_proxy is empty" |
| 15 | else |
| 16 | echo "http_proxy is set to $http_proxy" |
| 17 | build_env="proxy" |
| 18 | if [[ $http_proxy =~ ^http:\/\/[0-9] ]]; then |
| 19 | echo "starts with http" |
| 20 | proxy=$http_proxy |
| 21 | elif [[ $http_proxy =~ ^[0-9] ]]; then |
| 22 | echo "starts with number" |
| 23 | proxy=http://$http_proxy |
| 24 | fi |
| 25 | echo "Acquire::http::Proxy \"${proxy}\";" > proxy.conf |
| 26 | fi |
| 27 | |
| 28 | echo "Proxy set to $proxy, build env is $build_env." |
| 29 | |
| 30 | docker build --no-cache --build-arg http_proxy=$proxy --build-arg https_proxy=$proxy --build-arg build_env=$build_env -t c2m:latest -t c2m:`git log -1 --format=%h` . || echo "Build failed." |