9a044385c9d60cd1eba6c519b87430ef05d20379
[platform/core/ml/nnfw.git] / infra / command / build-docker-image
1 #!/bin/bash
2
3 function Usage()
4 {
5   echo "Usage: $0 $(basename ${BASH_SOURCE[0]}) [OPTIONS]"
6   echo ""
7   echo "Options:"
8   echo "      --codename                ubuntu codename, default image name is nnfw/one-devtools:[codename]"
9   echo "Options can use as docker build option:"
10   docker build --help
11 }
12
13 DOCKER_FILE_RPATH_BASE="infra/docker"
14 DOCKER_BUILD_ARGS=()
15
16 # Default setting
17 UBUNTU_CODENAME="bionic"
18 DOCKER_TAG="latest"
19
20 while [[ $# -gt 0 ]]
21 do
22   arg="$1"
23   # Handle argument for this script
24   # Set default docker image name, tag
25   case $arg in
26     -h|--help|help)
27       Usage
28       exit 1
29       ;;
30     --codename)
31       UBUNTU_CODENAME=$2
32       DOCKER_TAG=$2
33       shift 2
34       ;;
35     -t|--tag)
36       DOCKER_IMAGE_NAME="$2"
37       shift 2
38       ;;
39     *)
40       DOCKER_BUILD_ARGS+=(${1})
41       shift
42       ;;
43   esac
44 done
45
46 DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-nnfw/one-devtools:$DOCKER_TAG}
47 DOCKER_FILE_RPATH=$DOCKER_FILE_RPATH_BASE/$UBUNTU_CODENAME/Dockerfile
48 DOCKER_BUILD_ARGS+=("-t ${DOCKER_IMAGE_NAME}")
49
50 docker build --build-arg http_proxy="${http_proxy}" \
51   --build-arg https_proxy="${https_proxy}" \
52   ${DOCKER_BUILD_ARGS[@]} \
53   - < ${NNAS_PROJECT_PATH}/${DOCKER_FILE_RPATH}