-
Notifications
You must be signed in to change notification settings - Fork 3
/
run
executable file
·49 lines (41 loc) · 1.29 KB
/
run
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
#!/bin/bash
if [ "$1" = "--quick" ]; then
repo=rastapank/flow-dashboard:latest
docker pull $repo
containerName=flow-dashboard-upstream
else
repo=rastapank/flow-dashboard:local-build
containerName=flow-dashboard-local
fi
# Make a shared directory, which can be accessed by both host and container.
# It can be used for sharing schedule files.
sharedDirName=schedules
mkdir -p $sharedDirName
if [ -d "$sharedDirName" ]; then
hostSharedDirPath=`pwd`/$sharedDirName
containerSharedDirPath=/opt/flow-dashboard/$sharedDirName
makeSharedDir="-v $hostSharedDirPath:$containerSharedDirPath"
else
echo "[!] Shared directory \"$sharedDir\" not found. Manual copy of the schedule to/from container is required."
makeSharedDir=""
fi
runCommand="docker run -t --rm -P $makeSharedDir --name $containerName $repo"
echo "[*] Executing: $runCommand"
$runCommand &
sleep 2
hostPort=`docker port $containerName | cut -d ":" -f 2`
if [ -n "$hostPort" ]; then
URL="http://localhost:$hostPort"
echo "[*] App is running on: $URL"
if [ -n "$BROWSER" ]; then
$BROWSER $URL
elif which xdg-open > /dev/null; then
xdg-open $URL
elif which gnome-open > /dev/null; then
gnome-open $URL
elif [ `uname -s` = "Darwin" ]; then
open $URL
else
echo "Could not detect the web browser to use. Please visit: $URL"
fi
fi