forked from SUSE/Portus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose-setup.sh
More file actions
executable file
·108 lines (89 loc) · 2.62 KB
/
compose-setup.sh
File metadata and controls
executable file
·108 lines (89 loc) · 2.62 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
set -e
setup_database() {
set +e
TIMEOUT=90
COUNT=0
printf "Portus: configuring database..."
docker-compose run --rm web rake db:create db:migrate db:seed &> /dev/null
while [ $? -ne 0 ]; do
printf " [FAIL]\n"
echo "Waiting for mariadb to be ready"
if [ "$COUNT" -ge "$TIMEOUT" ]; then
printf " [FAIL]\n"
echo "Timeout reached, exiting with error"
exit 1
fi
sleep 5
COUNT=$((COUNT+5))
printf "Portus: configuring database..."
docker-compose run --rm web rake db:create db:migrate db:seed &> /dev/null
done
printf " [SUCCESS]\n"
set -e
}
clean() {
echo "The setup will destroy the containers used by Portus, removing also their volumes."
if [ $FORCE -ne 1 ]; then
while true; do
read -p "Are you sure to delete all the data? (Y/N)" yn
case $yn in
[Yy]* )
break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
fi
docker-compose kill
docker-compose rm -fv
}
usage() {
echo "Usage: $0 [-f]"
echo " -f force removal of data"
}
# Get the docker host by picking the IP from the docker0 interface. This is the
# safest way to reference the Docker host (see issues #417 and #382).
DOCKER_HOST=${DOCKER_HOST=$(/sbin/ifconfig docker0 | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | head -1)}
echo "DOCKER_HOST=${DOCKER_HOST}" > docker/environment
FORCE=0
while getopts "fh" opt; do
case "${opt}" in
f)
FORCE=1
;;
h)
usage
exit 0
;;
*)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
esac
done
clean
docker-compose up -d
setup_database
cat <<EOM
###################
# SUCCESS #
###################
EOM
echo "Make sure port 3000 and 5000 are open on host ${DOCKER_HOST}"
printf "\n"
echo "Open http://${DOCKER_HOST}:3000 with your browser and perform the following steps:"
echo " 1 - Create an admin account"
echo " 2 - Add a new registry: choose a custom name, enter ${DOCKER_HOST}:5000 as hostname"
printf "\n"
echo "Perform the following actions on the docker hosts that need to interact with your registry:"
echo " - Ensure the docker daemon is started with the '--insecure-registry ${DOCKER_HOST}:5000'"
echo " - Perform the docker login"
echo "To authenticate against your registry using the docker cli do:"
echo " docker login -u <portus username> -p <password> -e <email> ${DOCKER_HOST}:5000"
printf "\n"
echo "To push an image to the private registry:"
echo " docker pull busybox"
echo " docker tag busybox ${DOCKER_HOST}:5000/<username>busybox"
echo " docker push ${DOCKER_HOST}:5000/<username>busybox"