-
Notifications
You must be signed in to change notification settings - Fork 1
/
stage-deploy.sh
59 lines (48 loc) · 1.68 KB
/
stage-deploy.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
#!/bin/bash
echo "================="
echo "Starting Stage Deploy Script"
echo "================="
echo "================="
echo "Update"
echo "================="
sudo apt-get update -y
echo "================="
echo "Upgrade"
echo "================="
sudo apt-get upgrade -y
sudo apt-get install -y ca-certificates curl gnupg
echo "================="
echo "Get docker compose version"
echo "================="
docker compose version
if [ $? -ne 0 ]
then
echo "Docker Compose does not exit"
echo "================="
echo "Install docker and docker compose"
echo "================="
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update -y
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
fi
echo "================="
echo "Bring docker containers down"
echo "================="
sudo docker compose --profile stage down
echo "================="
echo "Restart docker service"
echo "================="
sudo systemctl restart docker
echo "================="
echo "Docker compose up by building in detached mode"
echo "================="
sudo docker compose --profile stage up --build --detach
echo "================="
echo "Successfully executed Stage Deploy Script"
echo "================="