Skip to content

Commit 6881096

Browse files
author
Slyke
committed
Fixed IOTstack source directory for docker menu builds
1 parent f162f79 commit 6881096

File tree

6 files changed

+46
-31
lines changed

6 files changed

+46
-31
lines changed

.internal/ctrl_api.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
CPWD=$(pwd)
44

5-
cd .internal/ 2>/dev/null
5+
if [[ ! "$(basename $CPWD)" == ".internal" ]]; then
6+
cd .internal/
7+
fi
68

79
source ./meta.sh
810
DNAME=iostack_api
@@ -31,16 +33,16 @@ else
3133
docker rmi $FULL_NAME --force
3234
echo ""
3335
echo "Rebuilding container:"
34-
echo "docker build --no-cache -t $FULL_NAME -f ./.internal/api.Dockerfile ."
36+
echo "docker build --no-cache -t $FULL_NAME -f ./api.Dockerfile ."
3537
docker pull node:14 # Docker occasionally fails to pull image when building when it is not cached.
36-
docker build --no-cache -t $FULL_NAME -f ./.internal/api.Dockerfile .
38+
docker build --no-cache -t $FULL_NAME -f ./api.Dockerfile .
3739
else
3840
if [[ "$(docker images -q $FULL_NAME 2> /dev/null)" == "" ]]; then
3941
echo "Building '$FULL_NAME'"
4042
echo "This may take 5 to 10 minutes."
4143
docker pull node:14 # Docker occasionally fails to pull image when building when it is not cached.
4244
echo ""
43-
docker build --quiet -t $FULL_NAME -f ./.internal/api.Dockerfile .
45+
docker build --quiet -t $FULL_NAME -f ./api.Dockerfile .
4446
DBR=$?
4547
if [[ ! $DBR -eq 0 ]]; then
4648
echo ""
@@ -51,13 +53,13 @@ else
5153
echo ""
5254
echo "Examples:"
5355
echo " Update owner:"
54-
echo " sudo chown -R $HOSTUSER $(pwd)/.internal/"
56+
echo " sudo chown -R $HOSTUSER $IOTSTACKPWD/.internal/"
5557
echo ""
5658
echo " Update permissions:"
57-
echo " sudo chmod -R 755 $(pwd)/.internal/"
59+
echo " sudo chmod -R 755 $IOTSTACKPWD/.internal/"
5860
echo ""
5961
echo " Checking owner and permissions:"
60-
echo " ls -ahl $(pwd)/.internal/"
62+
echo " ls -ahl $IOTSTACKPWD/.internal/"
6163
echo ""
6264
echo "-----------------------------------"
6365
echo ""

.internal/ctrl_pycli.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
CPWD=$(pwd)
44

5-
cd .internal/ 2>/dev/null
5+
if [[ ! "$(basename $CPWD)" == ".internal" ]]; then
6+
cd .internal/
7+
fi
68

79
source ./meta.sh
810
DNAME=iostack_pycli
@@ -25,17 +27,17 @@ else
2527
docker stop $(docker ps -q --format "{{.Image}} {{.ID}}" | grep "$DNAME" | cut -d ' ' -f2) 2> /dev/null || docker rmi $FULL_NAME --force 2> /dev/null
2628
echo ""
2729
echo "Rebuilding container:"
28-
echo "docker build --no-cache -t $FULL_NAME -f ./.internal/pycli.Dockerfile ."
30+
echo "docker build --no-cache -t $FULL_NAME -f ./pycli.Dockerfile ."
2931
docker pull python:3 # Docker occasionally fails to pull image when building when it is not cached.
30-
docker build --no-cache -t $FULL_NAME -f ./.internal/pycli.Dockerfile .
32+
docker build --no-cache -t $FULL_NAME -f ./pycli.Dockerfile .
3133
echo ""
3234
else
3335
if [[ "$(docker images -q $FULL_NAME 2> /dev/null)" == "" ]]; then
3436
echo "Building '$FULL_NAME'"
3537
echo "This may take 5 to 10 minutes."
3638
docker pull python:3 # Docker occasionally fails to pull image when building when it is not cached.
3739
echo ""
38-
docker build --quiet -t $FULL_NAME -f ./.internal/pycli.Dockerfile .
40+
docker build --quiet -t $FULL_NAME -f ./pycli.Dockerfile .
3941
DBR=$?
4042
if [[ ! $DBR -eq 0 ]]; then
4143
echo ""
@@ -46,13 +48,13 @@ else
4648
echo ""
4749
echo "Examples:"
4850
echo " Update owner:"
49-
echo " sudo chown -R $HOSTUSER $(pwd)/.internal/"
51+
echo " sudo chown -R $HOSTUSER $IOTSTACKPWD/.internal/"
5052
echo ""
5153
echo " Update permissions:"
52-
echo " sudo chmod -R 755 $(pwd)/.internal/"
54+
echo " sudo chmod -R 755 $IOTSTACKPWD/.internal/"
5355
echo ""
5456
echo " Checking owner and permissions:"
55-
echo " ls -ahl $(pwd)/.internal/"
57+
echo " ls -ahl $IOTSTACKPWD/.internal/"
5658
echo ""
5759
echo "-----------------------------------"
5860
echo ""

.internal/ctrl_wui.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
CPWD=$(pwd)
44

5-
cd .internal/ 2>/dev/null
5+
if [[ ! "$(basename $CPWD)" == ".internal" ]]; then
6+
cd .internal/
7+
fi
68

79
source ./meta.sh
810
DNAME=iostack_wui
@@ -29,17 +31,17 @@ else
2931
docker stop $(docker ps -q --format "{{.ID}} {{.Ports}}" | grep "$WUI_PORT" | cut -d ' ' -f1) 2> /dev/null
3032
echo ""
3133
echo "Rebuilding container:"
32-
echo "docker build --no-cache -t $FULL_NAME -f ./.internal/wui/wui.dev.Dockerfile ."
34+
echo "docker build --no-cache -t $FULL_NAME -f ./wui/wui.dev.Dockerfile ."
3335
docker pull node:14 # Docker occasionally fails to pull image when building when it is not cached.
34-
docker build --no-cache -t $FULL_NAME -f ./.internal/wui/wui.dev.Dockerfile .
36+
docker build --no-cache -t $FULL_NAME -f ./wui/wui.dev.Dockerfile .
3537
else
3638
if [[ "$(docker images -q $FULL_NAME 2> /dev/null)" == "" ]]; then
3739
echo "React WUI production build not found."
3840
echo "Building '$FULL_NAME'"
3941
echo "This may take 5 to 10 minutes."
4042
docker pull node:14 # Docker occasionally fails to pull image when building when it is not cached.
4143
echo ""
42-
docker build --quiet -t $FULL_NAME -f ./.internal/wui.Dockerfile .
44+
docker build --quiet -t $FULL_NAME -f ./wui.Dockerfile .
4345
DBR=$?
4446
if [[ ! $DBR -eq 0 ]]; then
4547
echo ""
@@ -50,13 +52,13 @@ else
5052
echo ""
5153
echo "Examples:"
5254
echo " Update owner:"
53-
echo " sudo chown -R $HOSTUSER $(pwd)/.internal/"
55+
echo " sudo chown -R $HOSTUSER $IOTSTACKPWD/.internal/"
5456
echo ""
5557
echo " Update permissions:"
56-
echo " sudo chmod -R 755 $(pwd)/.internal/"
58+
echo " sudo chmod -R 755 $IOTSTACKPWD/.internal/"
5759
echo ""
5860
echo " Checking owner and permissions:"
59-
echo " ls -ahl $(pwd)/.internal/"
61+
echo " ls -ahl $IOTSTACKPWD/.internal/"
6062
echo ""
6163
echo "-----------------------------------"
6264
echo ""

.internal/docker_menu.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
CPWD=$(pwd)
44

5-
cd .internal/ 2>/dev/null
5+
if [[ ! "$(basename $CPWD)" == ".internal" ]]; then
6+
cd .internal/
7+
fi
68

7-
if [ "$1" = "stop" ]; then
9+
if [ "$1" == "stop" ]; then
810
bash ./ctrl_api.sh stop
911
bash ./ctrl_wui.sh stop
1012
bash ./ctrl_pycli.sh stop

.internal/meta.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
export VERSION="v0.0.1"
55

66
# Used for the interal docker menu instances to know where IOTstack is installed
7-
export IOTSTACKPWD="${IOTSTACK_IOTSTACKPWD:-$(pwd)}"
7+
export IOTSTACKPWD="${IOTSTACK_IOTSTACKPWD:-$(cd .. && pwd)}"
88

99
# Used for the interal docker menu instances to know which user to set permissions for, and for SSH connections
1010
export HOSTUSER="${IOTSTACK_HOSTUSER:-$(whoami)}"

menu.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,14 @@ else
181181
echo "You either recently installed or upgraded IOTstack. The menu docker images need to be rebuilt in order for the menu to run correctly. This will take about 10 minutes and is completely automatic."
182182
echo ""
183183
echo "Spinning down container instances"
184-
bash ./.internal/docker_menu.sh stop
184+
# Change directory to .internal for docker build
185+
CPWD=$(pwd)
186+
187+
if [[ ! "$(basename $CPWD)" == ".internal" ]]; then
188+
cd .internal/
189+
fi
190+
191+
bash ./docker_menu.sh stop
185192

186193
sleep 1
187194

@@ -194,10 +201,6 @@ else
194201
sleep 1
195202
echo ""
196203

197-
# Change directory to .internal for docker build
198-
CPWD=$(pwd)
199-
cd .internal/
200-
201204
# Build all asynchronously, so it's faster. Give PyCLI a slight headstart to keep the user waiting the shortest time.
202205
docker build --quiet -t iostack_pycli:$VERSION -f ./pycli.Dockerfile . > /dev/null &
203206
sleep 1
@@ -291,12 +294,16 @@ fi
291294
PYCLI_ID="$(docker ps --format '{{.ID}} {{.Image}}' | grep -w iostack_pycli:$VERSION | cut -d ' ' -f1 | head -n 1)"
292295
if [[ "$PYCLI_ID" == "" ]]; then
293296
CPWD=$(pwd)
294-
cd .internal/
297+
if [[ ! "$(basename $CPWD)" == ".internal" ]]; then
298+
cd .internal/
299+
fi
295300
bash ./docker_menu.sh
296301
cd $CPWD
297302
else
298303
CPWD=$(pwd)
299-
cd .internal/
304+
if [[ ! "$(basename $CPWD)" == ".internal" ]]; then
305+
cd .internal/
306+
fi
300307
bash ./ctrl_api.sh > /dev/null
301308
cd $CPWD
302309
echo "PyCLI menu is already running. Reattaching..."

0 commit comments

Comments
 (0)