forked from dockdoo/dockdoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockdoo-install
executable file
·101 lines (87 loc) · 2.26 KB
/
dockdoo-install
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
#!/bin/bash
usage()
{
cat << EOF
All parameters are obligatory
SYNOPSIS
dockdoo-install [[-t token -v version -o organization -c client ]]
COMMAND-LINE OPTIONS:
-t Token used on github
-v Odoo version
-o Organization
-c Client
EOF
}
TOKEN=
VERSION=
ORGANIZATION=
CLIENT=
while getopts "t:v:o:c:h" OPTION
do
case $OPTION in
t)
TOKEN=$OPTARG
;;
v)
VERSION=$OPTARG
;;
o)
ORGANIZATION=$OPTARG
;;
c)
CLIENT=$OPTARG
;;
h | *)
usage
exit 1
;;
esac
done
if [ $OPTIND -eq 1 ]
then
usage
exit 1
fi
if [ "$TOKEN" = "" ] || [ "$VERSION" = "" ] || [ "$ORGANIZATION" = "" ] || [ "$CLIENT" = "" ]
then
usage
exit 1
fi
#AUTOMATICALLY ADD VARIABLE $CLIENT
echo "# Used by dockdoo" >> ~/.bashrc
echo 'export CLIENT=''"'$CLIENT'"' >> ~/.bashrc
#INSTALL GIT
apt-get install -y git
#INSTALL DOCKER
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable"
apt-get update
apt-get -y install docker-ce
#INSTALL DOCKER-COMPOSE
sudo curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
#Dockdoo Script
git clone -b master https://github.com/$ORGANIZATION/dockdoo.git /dockdoo
ln -s /dockdoo/dockdoo /bin/dockdoo && chmod u+x /dockdoo/dockdoo
#traefik
git clone -b master https://github.com/$ORGANIZATION/traefik.git /traefik
cd /traefik && docker-compose -p inverseproxy -f inverseproxy.yaml up -d
#SCAFFOLDING-prod
git clone -b $VERSION.0 https://$TOKEN@github.com/$ORGANIZATION/$CLIENT.git /$CLIENT-$VERSION
cd /$CLIENT-$VERSION
ln -s prod.yaml docker-compose.yml && docker-compose -f prod.yaml up --build --remove-orphans -d
#SCAFFOLDING-test
git clone -b $VERSION.0 https://$TOKEN@github.com/$ORGANIZATION/$CLIENT.git /test-$CLIENT-$VERSION
cd /test-$CLIENT-$VERSION
ln -s test.yaml docker-compose.yml && docker-compose -f test.yaml up --build -d