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 function create_ssh_key()
29 if [ -f ./${RSA_KEY_FILE_NAME} ]; then
30 read -p "RSA key already exist! Do you want to remove it (yYnN)?" -n 1 -r
32 if [ "$REPLY" == "y" ] || [ "$REPLY" == "Y" ]; then
33 echo "Removing existing key..."
36 [ -f "./${RSA_KEY_FILE_NAME}" ] && rm -rf ./${RSA_KEY_FILE_NAME}
37 [ -f "./${RSA_KEY_FILE_NAME}.pub" ] && rm -rf ./${RSA_KEY_FILE_NAME}.pub
39 echo "Using existing key..."
44 echo "Generating new RSA key..."
45 ssh-keygen -t rsa -b 4096 -N "" -f ./${RSA_KEY_FILE_NAME}
48 function build_prox_image()
50 if [ "${USE_DOCKER_CACHE}" == "y" ]; then
51 echo "Building image using cache..."
52 docker build --rm -t ${PROX_IMAGE_NAME}:latest -f ${DOCKERFILE} ${PROX_DEPLOY_DIR}
54 echo "Building image without cache..."
55 docker build --no-cache --rm -t ${PROX_IMAGE_NAME}:latest -f ${DOCKERFILE} ${PROX_DEPLOY_DIR}
59 function save_prox_image()
61 echo "Saving image ${PROX_IMAGE_NAME}:latest to ./${PROX_IMAGE_NAME}.tar"
62 docker save -o ./${PROX_IMAGE_NAME}.tar ${PROX_IMAGE_NAME}:latest
65 function load_prox_image()
67 echo "Loading image ./${PROX_IMAGE_NAME}.tar"
68 docker load -i ./${PROX_IMAGE_NAME}.tar
71 function push_prox_image()
73 docker tag ${PROX_IMAGE_NAME}:latest ${DOCKER_REGISTRY}/${PROX_IMAGE_NAME}
74 docker push ${DOCKER_REGISTRY}/${PROX_IMAGE_NAME}
79 echo "${0}: [build|load|push]"
80 echo " build: build and save image ${PROX_IMAGE_NAME}:latest using ${DOCKERFILE}"
81 echo " load: load saved image from ${PROX_IMAGE_NAME}.tar file in the local registry"
82 echo " push: tag and push local ${PROX_IMAGE_NAME}:latest image in the ${DOCKER_REGISTRY}/${PROX_IMAGE_NAME} registry"
85 if [ "$1" == "build" ]; then
89 elif [ "$1" == "load" ]; then
91 elif [ "$1" == "push" ]; then