-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-image.sh
executable file
·53 lines (45 loc) · 1.32 KB
/
build-image.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2020, Intel Corporation
#
# build-image.sh <OS-VER> <ARCH> - prepares a Docker image with <OS>-based
# environment intended for the <ARCH> CPU architecture
# designed for building PMDK project, according to
# the Dockerfile.<OS-VER> file located in the same directory.
#
# The script can be run locally.
#
set -e
OS_VER=$1
CPU_ARCH=$2
function usage {
echo "Usage:"
echo " build-image.sh <OS-VER> <ARCH>"
echo "where:"
echo " <OS-VER> - can be for example 'ubuntu-19.10' provided "\
"a Dockerfile named 'Dockerfile.ubuntu-19.10' "\
"exists in the current directory and"
echo " <ARCH> - is a CPU architecture, for example 'x86_64'"
}
# Check if two first arguments are not empty
if [[ -z "$2" ]]; then
usage
exit 1
fi
# Check if the file Dockerfile.OS-VER exists
if [[ ! -f "Dockerfile.$OS_VER" ]]; then
echo "Error: Dockerfile.$OS_VER does not exist."
echo
usage
exit 1
fi
if [[ -z "${DOCKER_REPO}" ]]; then
echo "Error: DOCKER_REPO environment variable is not set"
exit 1
fi
# Build a Docker image tagged as follows:
tag=${DOCKER_REPO}:${IMG_VER}-${OS_VER}-${CPU_ARCH}
docker build -t $tag \
--build-arg http_proxy=$http_proxy \
--build-arg https_proxy=$https_proxy \
-f Dockerfile.$OS_VER .