3 ## Copyright (c) 2010-2019 Intel Corporation
5 ## Licensed under the Apache License, Version 2.0 (the "License");
6 ## you may not use this file except in compliance with the License.
7 ## You may obtain a copy of the License at
9 ## http://www.apache.org/licenses/LICENSE-2.0
11 ## Unless required by applicable law or agreed to in writing, software
12 ## distributed under the License is distributed on an "AS IS" BASIS,
13 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ## See the License for the specific language governing permissions and
15 ## limitations under the License.
19 PROX_IMAGE_NAME="prox_slim"
20 RSA_KEY_FILE_NAME="rapid_rsa_key"
22 DOCKERFILE="Dockerfile"
23 DOCKER_REGISTRY="localhost:5000"
27 IMAGE_BUILD_LOG="dockerimage-build.log"
29 function create_ssh_key()
31 if [ -f ./${RSA_KEY_FILE_NAME} ]; then
32 read -p "RSA key already exist! Do you want to remove it (yYnN)?" -n 1 -r
34 if [ "${REPLY}" == "y" ] || [ "${REPLY}" == "Y" ]; then
35 echo "Removing existing key..."
38 [ -f "./${RSA_KEY_FILE_NAME}" ] && rm -rf ./${RSA_KEY_FILE_NAME}
39 [ -f "./${RSA_KEY_FILE_NAME}.pub" ] && rm -rf ./${RSA_KEY_FILE_NAME}.pub
41 echo "Using existing key..."
46 echo "Generating new RSA key..."
47 ssh-keygen -t rsa -b 4096 -N "" -f ./${RSA_KEY_FILE_NAME}
50 function build_prox_image()
52 if [ "${USE_DOCKER_CACHE}" == "y" ]; then
53 echo "Building image using cache..."
54 docker build --rm -t ${PROX_IMAGE_NAME}:latest -f ${DOCKERFILE} ${PROX_DEPLOY_DIR} 2>&1 | tee ./${IMAGE_BUILD_LOG}
56 echo "Building image without cache..."
57 docker build --no-cache --rm -t ${PROX_IMAGE_NAME}:latest -f ${DOCKERFILE} ${PROX_DEPLOY_DIR} 2>&1 | tee ./${IMAGE_BUILD_LOG}
61 function save_prox_image()
63 echo "Saving image ${PROX_IMAGE_NAME}:latest to ./${PROX_IMAGE_NAME}.tar"
64 docker save -o ./${PROX_IMAGE_NAME}.tar ${PROX_IMAGE_NAME}:latest
67 function load_prox_image()
69 echo "Loading image ./${PROX_IMAGE_NAME}.tar"
70 docker load -i ./${PROX_IMAGE_NAME}.tar
73 function push_prox_image()
75 docker tag ${PROX_IMAGE_NAME}:latest ${DOCKER_REGISTRY}/${PROX_IMAGE_NAME}
76 docker push ${DOCKER_REGISTRY}/${PROX_IMAGE_NAME}
81 echo "${0}: [build|load|push]"
82 echo " build: build and save image ${PROX_IMAGE_NAME}:latest using ${DOCKERFILE}"
83 echo " load: load saved image from ${PROX_IMAGE_NAME}.tar file in the local registry"
84 echo " push: tag and push local ${PROX_IMAGE_NAME}:latest image in the ${DOCKER_REGISTRY}/${PROX_IMAGE_NAME} registry"
87 if [ "$1" == "build" ]; then
91 elif [ "$1" == "load" ]; then
93 elif [ "$1" == "push" ]; then