-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathup.sh
executable file
·46 lines (36 loc) · 1.13 KB
/
up.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
#!/bin/bash
work_dir=$(pwd)
echo $work_dir
# For all reporitories specified in 'repositories.conf'
while read -r repo_url; do
echo
# Extract repository name from repository url
repo_name=$(echo $repo_url | grep -oP '(?<=\/)(.*)(?=\.git)')
echo ">>> $repo_name"
# If directory not exists: clone repository, else: pull updates
if [ ! -d "../$repo_name" ]; then
echo "Cloning ${repo_name} from ${repo_url}"
git clone $repo_url "../$repo_name"
cd "../$repo_name"
pwd
else
echo "Pull updates for ${repo_name}"
cd "../$repo_name"
pwd
git pull
fi
# Remove potentially existing containers and respective images
echo "Stopping potentially running Docker containers"
docker container stop $repo_name
echo "Removing potentially running Docker containers"
docker rm $repo_name
echo "Removing potentially running Docker images"
docker rmi $repo_name
docker build -t $repo_name .
# Go back to 'work_dir'
cd $work_dir
pwd
done <repositories.conf
echo "All containers up to date"
echo "Launch platform"
docker-compose up -d