-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·78 lines (66 loc) · 3.1 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·78 lines (66 loc) · 3.1 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
#!/bin/bash
# This file is part of the IG Parser project (URL: https://github.com/chrfrantz/IG-Parser).
# Maintainer: Christopher Frantz (cf@christopherfrantz.org)
# Clears current instance of IG Parser and redeploys after pulling from git repository.
# Ensure to run the script with sudo (e.g., 'sudo ./deploy.sh')!
# The script requires the following tools to be installed (see IG Parser README.MD for more details):
# - docker
# - docker-compose
# - git
echo "Initiating (re)deployment of latest version of the IG Parser ..."
# Create logs folder if it does not already exist
if [ ! -d ./logs ]; then
echo "Creating './logs' folder ..."
mkdir -p ./logs;
if [ $? -ne 0 ]; then
echo "Error during folder creation. Ensure you are running the script with superuser permissions (e.g., sudo)."
exit 1
fi
fi
# Tear down current version
echo "Undeploying running IG Parser instance ..."
docker-compose down
if [ $? -ne 0 ]; then
echo "Error when stopping service. Ensure that docker-compose is installed (check with 'docker-compose version'), and whether you are running the script with superuser permissions (e.g., sudo)."
exit 1
fi
# Delete runtime image generated as part of previous build process
echo "Deleting image of undeployed IG Parser instance ..."
docker image prune --filter label=stage=runner -f
if [ $? -ne 0 ]; then
echo "Error when deleting runner images following undeploying. Ensure that docker is properly installed (check with 'docker version'), and whether you are running the script with superuser permissions (e.g., sudo)."
exit 1
fi
# Pull latest version
echo "Retrieving latest version ..."
git pull
if [ $? -ne 0 ]; then
echo "Error when pulling latest version of repo. Ensure that git is properly installed (check with 'git version'), and whether you are running the script with superuser permissions (e.g., sudo)."
exit 1
fi
# Create docker network if not already existing
echo "Checking network setup ..."
docker network inspect tunnel_network > /dev/null
if [ $? -ne 0 ]; then
echo "Dedicated docker network does not exist. Creating 'tunnel_network' ..."
docker network create tunnel_network
if [ $? -ne 0 ]; then
echo "Docker network creation failed. Ensure you are running the script with superuser permissions (e.g., sudo). Check output for error."
exit 1
fi
fi
# Deploy
echo "Deploying latest version of IG Parser ..."
docker-compose up -d --build
if [ $? -ne 0 ]; then
echo "Error during deployment. Ensure that docker-compose is installed (check with 'docker-compose version'), and whether you are running the script with superuser permissions (e.g., sudo)."
exit 1
fi
# Remove remaining build containers
echo "Removing all intermediate images created during build process ..."
docker image prune --filter label=stage=builder -f
if [ $? -ne 0 ]; then
echo "Error when deleting intermediate images created during build. Ensure that docker is properly installed (check with 'docker version'), and whether you are running the script with superuser permissions (e.g., sudo)."
exit 1
fi
echo "Completed deployment of latest IG Parser version (check output for potential errors)"