forked from hall757/raritan-mpc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
create
executable file
·49 lines (44 loc) · 1.29 KB
/
create
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
CONTAINER=mpc
IMAGE=hall757/raritan-mpc
VOLUME=$(pwd)
CONFIGDIR="${VOLUME}/config"
echo Config directory: $CONFIGDIR
mkdir -p $CONFIGDIR
hostname=$(hostname)
DOMAIN=${hostname#*.*}
echo dockergen-nginx will use $CONTAINER.$DOMAIN as the virtual host name.
pushd mpc
#JAVAIMAGE=docker.io/store/oracle/serverjre:8
#if [ ! -f java.tgz ]
#then
# sudo docker run -i -t --rm -v `pwd`:/export $JAVAIMAGE tar -zchf /export/java.tgz /usr/java/latest
#fi
#if [ ! -f java.tgz ]
#then
# echo Failed to extract java from $JAVAIMAGE
# echo This requires that have accepted the java license and that docker is logged in.
# echo Please see https://hub.docker.com/_/oracle-serverjre-8 for details.
# echo This unfortunaly means you have to build you own image as this cannot be built on docker hub.
# exit 1
#fi
sudo docker build . -t $IMAGE || exit 1
popd
# kill any running containers
sudo docker stop $CONTAINER > /dev/null 2>&1
sudo docker rm $CONTAINER > /dev/null 2>&1
cmd=$( echo \
sudo docker run -d \
-p 8080 \
-h $CONTAINER \
-e "VIRTUAL_HOST=$CONTAINER.$DOMAIN" \
-e "VIRTUAL_PORT=8080" \
-e "SSL_CLIENT_VERIFY=on" \
-v "${CONFIGDIR}:/config" \
--name $CONTAINER \
--restart always \
-t $IMAGE \
)
echo $cmd
ID=$($cmd)
echo $CONTAINER container: $ID