forked from natcl/node-red-project-template
-
Notifications
You must be signed in to change notification settings - Fork 14
/
watchDocker
executable file
·30 lines (25 loc) · 909 Bytes
/
watchDocker
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
#! /bin/bash
# You need to set environment variable $ANARCHY to your Node-RED credential secret.
# Always start by getting latest copy.
old_rev="none"
#old_rev=`git log -1 --pretty="%H"`
# Get directory name as project name for name of docker image
thisdir="$(basename "$(pwd)")"
while [ 1 ]; do
new_rev=`git ls-remote "$(git config --get remote.origin.url)" HEAD | cut -f 1`
if [ $new_rev != $old_rev ]; then
old_rev=$new_rev
echo "SHA now "$old_rev
# force overwrite of local files with remote
git fetch --all
git reset --hard origin/master
# re-build docker image
docker build -t $thisdir .
# stop and remove existing
docker stop my_$thisdir
docker rm my_$thisdir
# restart new
docker run -d -p 1880:1880 -e NODE_RED_CREDENTIAL_SECRET=$ANARCHY --name my_$thisdir $thisdir
fi
sleep 60
done