-
Notifications
You must be signed in to change notification settings - Fork 160
/
minishift-importer.sh
executable file
·89 lines (80 loc) · 3.08 KB
/
minishift-importer.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2018, 2022 Eurotech and/or its affiliates and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eurotech- initial API and implementation
###############################################################################
#
# This script copies Docker images from the local Docker registry into Minishift VM's one.
#
# This is done by saving local images to /tmp/kapua-containers-{someRandomness}/ using command:
# docker save -o /tmp/kapua-containers-{someRandomness}/{outputFileName} {sourceImageName}
#
# Then sets Minishift Docker registry overriding environment variables:
# DOCKER_CERT_PATH=~/.minishift/certs
# DOCKER_HOST=tcp://192.168.99.100:2376
# DOCKER_TLS_VERIFY=1
#
# And loading into the registry by running:
# docker load < /tmp/kapua-containers-{theSameRandonessAsBefore}/{outputFileName}
#
ERROR=0
DOCKER_ACCOUNT=${DOCKER_ACCOUNT:=kapua}
IMAGE_VERSION=${IMAGE_VERSION:=1.6.10}
SERVICES=("console" "api" "sql" "broker" "events-broker")
TMP_DIR="/tmp/kapua-containers-$(date +%s)"
echo "Creating tmp directory: ${TMP_DIR}..."
mkdir -p ${TMP_DIR} || die "Cannot create directory '${TMP_DIR}' where to copy files."
echo "Creating tmp directory... DONE!"
echo ""
(
echo "Exporting Kapua images..."
for SERVICE in ${SERVICES[@]}; do
echo " kapua-${SERVICE}:${IMAGE_VERSION}"
docker save -o ${TMP_DIR}/${SERVICE} kapua/kapua-${SERVICE}:${IMAGE_VERSION} &> /dev/null ||
{
echo " Cannot export image: kapua-${SERVICE}:${IMAGE_VERSION}"
echo " Perhaps it is not present in the local Docker registry?"
echo ""
exit 1
}
done
echo "Exporting Kapua images... DONE!"
echo ""
eval $(minishift docker-env)
echo "Importing Kapua images into Minishift..."
for SERVICE in ${SERVICES[@]}; do
echo "kapua-${SERVICE}:${IMAGE_VERSION}"
docker load < ${TMP_DIR}/${SERVICE} &> /dev/null ||
{
echo " Cannot import image: kapua-${SERVICE}:${IMAGE_VERSION}"
echo " Perhaps due to previous errors?"
exit 1
}
done
echo "Importing Kapua images into Minishift... DONE!"
echo ""
) ||
{
ERROR=1;
echo "Exporting/Importing Kapua images... FAILED!"
echo " Perhaps docker images are not present in the local Docker registry?"
echo " Please check running command:"
echo " docker images"
echo " If no 'kapua/kapua*:${IMAGE_VERSION}' images are present, please build them running command:"
echo " mvn clean install -Pconsole,docker"
echo ""
}
echo "Removing tmp directory: ${TMP_DIR}..."
if [ -d "${TMP_DIR}" ]; then
rm -rf ${TMP_DIR}
fi
echo "Removing tmp directory... DONE!"
exit ${ERROR}