-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·92 lines (77 loc) · 2.48 KB
/
deploy.sh
File metadata and controls
executable file
·92 lines (77 loc) · 2.48 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
#!/bin/bash
#---------------------------- PRE-REQUIREMENTS ----------------------------
if ! [ -x "$(command -v git)" ]; then
echo 'Error: git is not installed.' >&2
echo 'Installing git'
sudo apt install git-all -y
fi
if ! [ -x "$(command -v docker)" ]; then
echo 'Error: docker is not installed.' >&2
echo 'Installing docker'
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
if ! getent group docker > /dev/null 2>&1; then
sudo groupadd docker
fi
if ! groups | grep docker &> /dev/null; then
sudo usermod -aG docker $USER
# newgrp docker # logins in new console => BAD
fi
fi
if ! [ -f "docker-compose" ]; then
echo 'Error: docker-compose doesnt exists' >&2
wget "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" \
-O ./docker-compose
chmod +x ./docker-compose
fi
if [ "$1" != "" ]; then
PROJECT_DIR="$1"
else
PROJECT_DIR="$(pwd)"
fi
echo "Project folder is set to $PROJECT_DIR"
if ! [ -d "$PROJECT_DIR" ]; then
echo "Creating project folder"
mkdir "$PROJECT_DIR"
fi
#---------------------------- CLONING GIT ----------------------------
git clone https://github.com/CsteerDevops1/wiki-framework "$PROJECT_DIR"
cd "$PROJECT_DIR"
git checkout develop
git pull origin develop
cd ../
#---------------------------- STARTING CORE SERVICE ----------------------------
if [ -d "~/.volumes/mongo/data/db" ]; then
:
else
echo "Creating ~/.volumes/mongo/data/db folder"
mkdir -p ~/.volumes/mongo/data/db
fi
echo "Launching docker-compose"
touch $PROJECT_DIR/telegramBots/userBot/.env
touch $PROJECT_DIR/telegramBots/initBot/.env
touch $PROJECT_DIR/telegramBots/editBot/.env
# used to config user for mongodb
export UID=${UID}
export GID=${GID}
# export HOSTNAME
echo "REACT_APP_HOSTNAME=https://wf.csteer.pro" > $PROJECT_DIR/web/.env
./docker-compose -f $PROJECT_DIR/docker-compose.yml up --build -d
# # don't use sudo if it's unnecessary
# if ! groups | grep docker &> /dev/null; then
# sudo ./docker-compose -f ./docker-compose.yml up --build -d
# else
# docker-compose -f ./docker-compose.yml up --build -d
# fi