-
Notifications
You must be signed in to change notification settings - Fork 10
/
docker-run-website
executable file
·53 lines (46 loc) · 1.97 KB
/
docker-run-website
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
50
51
52
53
#!/bin/bash
# On Mac, start docker daemon if not running
if docker-machine > /dev/null 2>&1; then
docker-machine start
docker-machine env
eval $(docker-machine env default)
fi
# Stop and/or remove existing opengrid-website container, if any
if docker ps -a | grep -q opengrid-website; then
echo "Stopping and/or removing existing opengrid-website container."
docker stop opengrid-website > /dev/null
docker rm opengrid-website > /dev/null
fi
# Check environment variable
: "${OPENGRIDPATH:?ERROR: no OPENGRIDPATH found.
Ensure that you have environment variables OPENGRIDPATH and OPENGRIDDATA pointing to the folders with your OpenGrid source code and data.}"
: "${OPENGRIDDATA:?ERROR: no OPENGRIDDATA found.
Ensure that you have environment variables OPENGRIDPATH and OPENGRIDDATA pointing to the folders with your OpenGrid source code and data.}"
echo "The source code for opengrid is in $OPENGRIDPATH"
echo "The data for opengrid is in $OPENGRIDDATA"
# Start the docker, publish port 5000 to host
# mount 3 paths:
# - current folder to /usr/local/website in the container
# - opengrid source code to /usr/local/opengrid
# - data to /data
docker run -d -p 5000:5000 -v $(pwd -P):/usr/local/website -v $OPENGRIDPATH:/usr/local/opengrid -v $OPENGRIDDATA:/data --name opengrid-website opengrid/website:latest
# Give it some time
sleep 5s
URL=http://$(docker-machine ip default):5000
if [ -z "$(docker-machine ip default)"]; then
URL="http://localhost:5000"
fi
echo "Open the notebook server on $URL"
# open the browser
if gnome-open $URL > /dev/null 2>&1; then
echo “OpenGrid website opened in browser”
elif start $URL > /dev/null 2>&1; then
echo “OpenGrid website opened in browser”
elif open $URL > /dev/null 2>&1; then
echo “OpenGrid website opened in browser”
elif xdg-open $URL > /dev/null 2>&1; then
echo “OpenGrid website opened in browser”
else
echo “Opening website in browser failed, surf to $URL“
fi
echo "To stop the docker machine run 'docker-machine stop'"