-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-build.sh
executable file
·74 lines (59 loc) · 1.66 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
DIR="logs"
# if dir does not exists create it
if
[ ! -d "$DIR" ]
then
mkdir -p "$DIR" && chmod -R 755 "$DIR"
fi
URL1=$"http://localhost:8888"
URL2=$"http://localhost:9999/nginx-health"
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 oceanblue-app
wait $process_id
echo "container stopped"
docker rm oceanblue-app
wait $process_id
echo "container removed"
docker rmi alpine
wait $process_id
docker rmi oceanblue
wait $process_id
echo "alpine images removed"
docker build -t oceanblue:latest -f Dockerfile .
wait $process_id
echo "new alpine image build"
#docker scan oceanblue
#wait $process_id
#echo "scanned docker oceanblue image with snyk"
#docker scan alpine
#wait $process_id
#echo "scanned docker alpine image with snyk"
docker run -dt --name oceanblue-app -p 8888:80 -p 9999:90 oceanblue:latest
wait $process_id
echo "running new container now"
echo "Exit status: $?"
echo "all processes finished"
[[ -x $BROWSER ]] && exec "$BROWSER" "$URL1"
path=$(which xdg-open || which gnome-open) && exec "$path" "$URL1"
if open -Ra "Google Chrome" --args --incognito "$URL1"; then
echo "opening application now"
open -na "Google Chrome" --args --incognito "$URL1"
else
echo "no system browser installed"
fi
[[ -x $BROWSER ]] && exec "$BROWSER" "$URL2"
path=$(which xdg-open || which gnome-open) && exec "$path" "$URL2"
if open -Ra "Google Chrome" --args --incognito "$URL2"; then
echo "opening healthcheck now"
open -na "Google Chrome" --args --incognito "$URL2"
else
echo "no system browser installed"
fi
# exit script after 10 seconds
sleep 10
kill -15 $PPID