summaryrefslogtreecommitdiffstats
path: root/tools/build-c2m.sh
blob: b5ad40fb84f724a57062b1fe27e72e161de1dc19 (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
#!/bin/bash

# Copyright 2021 Nokia
# Licensed under the Apache License 2.0
# SPDX-License-Identifier: Apache-2.0

# Build script to create c2m container.

set -x

build_env="no_proxy"
proxy=""
if [[ -z "${http_proxy}" ]]; then
    echo "http_proxy is empty"
else
    echo "http_proxy is set to $http_proxy"
    build_env="proxy"
    if [[ $http_proxy =~ ^http:\/\/[0-9] ]]; then
        echo "starts with http"
        proxy=$http_proxy
    elif [[ $http_proxy =~ ^[0-9] ]]; then
        echo "starts with number"
        proxy=http://$http_proxy
    fi
    echo "Acquire::http::Proxy \"${proxy}\";" > proxy.conf
fi

echo "Proxy set to $proxy, build env is $build_env."

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."