-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-build.sh
executable file
·56 lines (44 loc) · 1.15 KB
/
docker-build.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
#!/bin/bash
DIR="logs"
# if dir does not exists create it
if
[ ! -d "$DIR" ]
then
mkdir -p "$DIR" && chmod -R 755 "$DIR"
fi
URL=$"http://localhost:8895"
process_id=$!
DATE=$(date +"%Y-%m-%dT%H:%M:%S")
# output all console info to file
exec > >(tee -i logs/"$DATE"-image-build.log)
exec 2>&1
docker stop forrestgreen_app
echo "container stopped"
wait $process_id
docker rm forrestgreen_app
wait $process_id
echo "container removed"
docker rmi alpine
wait $process_id
docker rmi forrestgreen
wait $process_id
echo "alpine images removed"
docker build -t forrestgreen:latest -f Dockerfile .
echo "new alpine image build"
wait $process_id
docker run -dt --name forrestgreen_app -p 8895:80 forrestgreen:latest
echo "running new container now"
wait $process_id
echo "Exit status: $?"
echo "all processes finished"
[[ -x $BROWSER ]] && exec "$BROWSER" "$URL"
path=$(which xdg-open || which gnome-open) && exec "$path" "$URL"
if open -Ra "Google Chrome" --args --incognito "$URL"; then
echo "opening application now"
open -na "Google Chrome" --args --incognito "$URL"
else
echo "no system browser installed"
fi
# exit script after 10 seconds
sleep 10
kill -15 $PPID