Skip to content

Commit f407caf

Browse files
committed
Exit script on all errors
except docker commands that can fail if the containers/images don't exist
1 parent 3a197ca commit f407caf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

run.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/bin/sh
22

3+
set -o pipefail
4+
set -e
5+
36
cyan='\033[0;36m'
47
blue='\033[0;34m'
58
no_color='\033[0m' # No Color
69

710
echo "${cyan}Stopping the backend container and removing its image...${no_color}"
8-
docker rm -f backend &>/dev/null
9-
docker rmi -f backend-image &>/dev/null
11+
docker rm -f backend &>/dev/null || true
12+
docker rmi -f backend-image &>/dev/null || true
1013
echo "${cyan}Building a new backend image...${no_color}"
1114
docker build -t="backend-image" --force-rm hosts/backend
1215
echo "${cyan}Starting a new backend image...${no_color}"
@@ -45,8 +48,8 @@ for proxy_dir in hosts/proxy/*; do
4548
cp -r lib/ hosts/proxy/$proxy_name/nginx/lua
4649

4750
echo "${blue}Stopping the container and removing the image${no_color}"
48-
docker rm -f "proxy-$proxy_name" &>/dev/null
49-
docker rmi -f "proxy-$proxy_name-image" &>/dev/null
51+
docker rm -f "proxy-$proxy_name" &>/dev/null || true
52+
docker rmi -f "proxy-$proxy_name-image" &>/dev/null || true
5053

5154
echo "${blue}Building the new image${no_color}"
5255
docker build -t="proxy-$proxy_name-image" --force-rm hosts/proxy/$proxy_name

0 commit comments

Comments
 (0)