| 1 |
#!/usr/bin/env bash |
| 2 |
# |
| 3 |
# SPDX-License-Identifier: BSD-3-Clause |
| 4 |
# Copyright 2016-2021, Intel Corporation |
| 5 |
# |
| 6 |
|
| 7 |
# |
| 8 |
# build-image.sh <OS-VER> - prepares a Docker image with <OS>-based |
| 9 |
# environment for testing miniasync, according |
| 10 |
# to the Dockerfile.<OS-VER> file located |
| 11 |
# in the same directory. |
| 12 |
# |
| 13 |
# The script can be run locally. |
| 14 |
# |
| 15 |
|
| 16 |
set -e |
| 17 |
|
| 18 |
function usage { |
| 19 |
echo "Usage:" |
| 20 |
echo " build-image.sh <DOCKER_REPO> <OS-VER>" |
| 21 |
echo "where <OS-VER>, for example, can be 'fedora-30', provided " \ |
| 22 |
"a Dockerfile named 'Dockerfile.fedora-30' exists in the " \ |
| 23 |
"current directory." |
| 24 |
} |
| 25 |
|
| 26 |
# Check if the first and second argument is nonempty |
| 27 |
if [[ -z "$1" || -z "$2" ]]; then |
| 28 |
usage |
| 29 |
exit 1 |
| 30 |
fi |
| 31 |
|
| 32 |
# Check if the file Dockerfile.OS-VER exists |
| 33 |
if [[ ! -f "Dockerfile.$2" ]]; then |
| 34 |
echo "ERROR: wrong argument." |
| 35 |
usage |
| 36 |
exit 1 |
| 37 |
fi |
| 38 |
|
| 39 |
# Build a Docker image tagged with ${DOCKER_REPO}:${IMG_VER}-${OS}-${OS_VER} |
| 40 |
docker build -t $1:${IMG_VER}-$2 \ |
| 41 |
--build-arg http_proxy=$http_proxy \ |
| 42 |
--build-arg https_proxy=$https_proxy \ |
| 43 |
-f Dockerfile.$2 . |