-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
104 lines (85 loc) · 2.31 KB
/
start.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
alias docker='podman'
handleExecution(){
if [ $1 -eq 0 ]
then
echo "SUCCESS:" "$2" " Complete !"
else
echo "ERROR:" "$2" " FAILED !" >&2
exit 1
fi
}
function rem_image() {
image_id=$1
image_name=$2
docker rm -f $(docker ps -a -q --filter="ancestor=$image_name") 2>&- || echo "Found no containers for that image"
docker rmi $image_id
handleExecution $? 'Image deletetion'
}
function docker_clean() {
pattern=$1
for image_id in `docker images | grep $pattern | awk '{ print $3}'`
do
echo Removing... $image_id
rem_image $image_id $pattern
done
}
echo "Cleaning images and associated containers":
docker_clean none
docker_clean psql
docker_clean codeganak-api
docker_clean codeganak-ui
echo "Cleaning Complete !!":
echo ''
echo ''
echo "Creating network for codeganak:"
docker network rm -f codeganak_net
docker network create --driver bridge codeganak_net
echo "Network codeganak_net created:"
echo ''
echo ''
echo 'Building Postgres...'
cd db/
docker rmi psql:latest
docker build -t psql:latest .
handleExecution $? 'Postgres'
echo 'Starting Postgres...'
docker container run -d --rm -p 2345:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_USER=postgres --name psql-db --network codeganak_net psql:latest
echo 'Completed Postgres...'
echo ''
echo ''
cd ..
echo 'Building backend...'
cd codeganak/
docker rmi codeganak-api:latest
docker build -t codeganak-api:latest .
handleExecution $? 'codeganak-api'
echo 'Starting backend...'
docker container run -d --rm -p 8082:8082 -e DB_URL=jdbc:postgresql://psql-db:5432/codeganak --name codeganak-api-container --network codeganak_net codeganak-api:latest
echo 'Completed backend...'
echo ''
echo ''
cd ..
echo 'Building UI...'
cd ace-builds-master/
docker rmi codeganak-ui:latest
docker build -t codeganak-ui:latest .
handleExecution $? 'codeganak-ui'
echo 'Starting UI...'
docker container run -d --rm -p 9999:3000 -e API_URL=http://codeganak-api-container:8082 --name codeganak-ui-container --network codeganak_net codeganak-ui:latest
echo 'Completed UI...'
echo ''
echo ''
cd ..
echo 'Cleaning unnamed images'
docker_clean none
echo 'Cleaning Complete'
echo ''
echo ''
echo 'Access the application at:'
echo '-------------------------------'
echo ''
echo ' http://localhost:9999/ '
echo ''
echo '-------------------------------'
echo ''