-
Notifications
You must be signed in to change notification settings - Fork 0
/
odam.sh
executable file
·67 lines (55 loc) · 1.99 KB
/
odam.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
MYDIR=`dirname $0` && [ ! `echo "$0" | grep '^\/'` ] && MYDIR=`pwd`/$MYDIR
# Development mode: 0 => use only source files within the docker images; 1 => use local source files
DEV=0
# URL Proxy for the "getdata" web-services
GETDATA_URL_PROXY=http://myhost.org:8081/
# Path root of the data repository
GETDATA_DATAREPOS=/opt/DataRepos
# GetData Container
GETDATA_PORT=8081
GETDATA_IMAGE=docker.io/odam/getdata
GETDATA_CONTAINER=gdata
# Dataexplorer Container
DATAEXPLORER_PORT=8080
DATAEXPLORER_IMAGE=docker.io/odam/dataexplorer
DATAEXPLORER_CONTAINER=dataexplorer
CMD=$1
# the local data repository mounted as a volume
VOLS="-v $GETDATA_DATAREPOS:/opt/data"
usage() { echo "usage: sh $0 start|stop|restart|ps|build|push|pull"; exit 1; }
case "$CMD" in
start)
# run getData
VOLSRC=''; [ $DEV -eq 1 ] && VOLSRC="-v $MYDIR/getData/www:/var/www/html"
sudo docker run -d -e "GETDATA_URL_PROXY="$GETDATA_URL_PROXY $VOLS $VOLSRC -p $GETDATA_PORT:80 \
--name $GETDATA_CONTAINER $GETDATA_IMAGE
# run dataexplorer
VOLSRC=''; [ $DEV -eq 1 ] && VOLSRC="-v $MYDIR"/dataexplorer":/srv/shiny-server/"
sudo docker run -d -e "GETDATA_URL_PROXY="$GETDATA_URL_PROXY $VOLSRC -p $DATAEXPLORER_PORT:3838 \
--name $DATAEXPLORER_CONTAINER $DATAEXPLORER_IMAGE
# show logs
sudo docker logs $GETDATA_CONTAINER
sudo docker logs $DATAEXPLORER_CONTAINER
;;
stop)
sudo docker rm -f $GETDATA_CONTAINER $DATAEXPLORER_CONTAINER
;;
restart)
( sh $0 stop ; sh $0 start )
;;
ps)
sudo docker ps | head -1
sudo docker ps | grep "odam/"
;;
build)
( cd $MYDIR/getdata; sudo docker build -t $GETDATA_IMAGE . )
( cd $MYDIR/dataexplorer; sudo docker build -t $DATAEXPLORER_IMAGE . )
;;
pull)
sudo docker pull $GETDATA_IMAGE
sudo docker pull $DATAEXPLORER_IMAGE
;;
*) usage
exit 2
esac