summaryrefslogtreecommitdiff
path: root/scripts/command/build-docker
blob: 2da70be78b6a3adfceb738576149e6071da33137 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

function Usage()
{
  echo "Usage: $0 $(basename ${BASH_SOURCE[0]}) [OPTIONS]"
  echo ""
  echo "Options:"
  echo "      --tizen                   Build docker image for tizen build"
  echo "Options can use as docker build option:"
  docker build --help
}

DOCKER_FILE_RPATH="docker/Dockerfile"
DOCKER_BUILD_ARGS=()

# Handle argument for this script
# Set default docker image name, tag
for i in "$@"
do
  case $i in
    -h|--help|help)
      Usage
      exit 1
      ;;
    --tizen)
      DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-nnfw_docker_tizen}
      DOCKER_FILE_RPATH="docker/Dockerfile_tizen"
      ;;
  esac
done
source "$NNFW_SCRIPT_PATH/config/image_name.configuration"
DOCKER_BUILD_ARGS+="-t ${DOCKER_IMAGE_NAME}"

# Argument for docker build commands
for i in "$@"
do
  case $i in
    -h|--help|help)
    --tizen)
      # Already handled argument
      ;;
    *)
      DOCKER_BUILD_ARGS+=($1)
      ;;
  esac
  shift
done

docker build --build-arg http_proxy="$http_proxy" \
  --build-arg https_proxy="$https_proxy" \
  ${DOCKER_BUILD_ARGS[@]} \
  - < $NNFW_SCRIPT_PATH/$DOCKER_FILE_RPATH