-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy-iot.sh
More file actions
executable file
·42 lines (33 loc) · 909 Bytes
/
deploy-iot.sh
File metadata and controls
executable file
·42 lines (33 loc) · 909 Bytes
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
#! /bin/bash
: '---- CONSTANTS ----'
COMPOSE_FILE="docker-compose.yaml"
IOT_PATH=iot-svc
set -e
# change path to the IOT working dir
function change_path(){
cd $IOT_PATH || exit
echo "This is the current working dir: $IOT_PATH"
}
# stop the existing containers
function stop_running_containers() {
echo "Stopping the running containers ..."
docker compose -f $COMPOSE_FILE down
docker image prune -f
echo "removed the old containers and daggling images ...."
}
function deploy() {
if [ ! -f "$COMPOSE_FILE" ]; then
echo -e "Docker Compose file '$COMPOSE_FILE' not found.\n Exiting..."
exit 1
else
# finally deploy the application
echo "Finally!. Your application is ready for deployment ..."
docker compose -f ${COMPOSE_FILE} up -d --build
fi
}
function main() {
change_path
stop_running_containers
deploy
}
main