[cmd] Docker image build command (#7981)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 8 Oct 2019 07:44:19 +0000 (16:44 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 8 Oct 2019 07:44:19 +0000 (16:44 +0900)
Add argument in build docker image command for additional dockerfile - ubuntu 18.04

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
infra/command/build-docker-image

index 12f622d..7653a0c 100644 (file)
@@ -4,40 +4,46 @@ function Usage()
 {
   echo "Usage: $0 $(basename ${BASH_SOURCE[0]}) [OPTIONS]"
   echo ""
+  echo "Options:"
+  echo "      --extension               dockerfile extension in infra/docker"
   echo "Options can use as docker build option:"
   docker build --help
 }
 
-DOCKER_FILE_RPATH="infra/docker/Dockerfile"
+DOCKER_FILE_RPATH_BASE="infra/docker/Dockerfile"
 DOCKER_BUILD_ARGS=()
+DOCKER_FILE_RPATH=${DOCKER_FILE_RPATH_BASE}
+DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-nnas}
 
-# Handle argument for this script
-# Set default docker image name, tag
-for i in "$@"
+while [[ $# -gt 0 ]]
 do
-  case ${i} in
+  arg="$1"
+  # Handle argument for this script
+  # Set default docker image name, tag
+  case $arg in
     -h|--help|help)
       Usage
       exit 1
       ;;
-  esac
-done
-
-DOCKER_BUILD_ARGS+="-t ${DOCKER_IMAGE_NAME:-nnas}"
-
-# Argument for docker build commands
-for i in "$@"
-do
-  case ${i} in
-    -h|--help|help)
-      # Already handled argument
+    --extension)
+      DOCKER_FILE_RPATH="${DOCKER_FILE_RPATH_BASE}.$2"
+      shift
+      shift
+      ;;
+    -t|--tag)
+      DOCKER_IMAGE_NAME="$2"
+      shift
+      shift
       ;;
     *)
-      DOCKER_BUILD_ARGS+=(${i})
+      DOCKER_BUILD_ARGS+=(${1})
+      shift
       ;;
   esac
 done
 
+DOCKER_BUILD_ARGS+=("-t ${DOCKER_IMAGE_NAME}")
+
 docker build --build-arg http_proxy="${http_proxy}" \
   --build-arg https_proxy="${https_proxy}" \
   ${DOCKER_BUILD_ARGS[@]} \