-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-start.sh
executable file
·54 lines (47 loc) · 1.5 KB
/
docker-start.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
#!/bin/bash
if [ -z "$1" ]; then
echo 'Usage:'
echo " $0 ip:port"
echo 'Example: for only allow localhost (recommended)'
echo " $0 127.0.0.1:8888"
echo 'Example: this will expose your port (use carefully)'
echo " $0 0.0.0.0:8888"
exit 1
fi
CONTAINER_NAME=neticrm-ci-php7
TAG_NAME=drone-php7
DRUPAL_VERSION=7
WORKDIR=`pwd`
if [ -d $HOME/mnt/neticrm-7/civicrm ];then
MOUNT=$HOME/mnt/neticrm-7/civicrm
else
MOUNT=/mnt/neticrm-7/civicrm
fi
# always fetch latest image
docker pull rg.netivism.com.tw/netivism/docker-neticrm-ci:$TAG_NAME
# purge previous container
EXISTS_CONTAINER=$(docker ps -q -f "name=$CONTAINER_NAME")
if [ -n $EXISTS_CONTAINER ]; then
docker rm -f $CONTAINER_NAME
echo "Remove old container $CONTAINER_NAME successfully"
fi
# purge previous images
OLD_IMAGE=$(docker images rg.netivism.com.tw/netivism/docker-neticrm-ci --filter "dangling=true" -q)
if [ -n "$OLD_IMAGE" ]; then
docker rmi $(docker images rg.netivism.com.tw/netivism/docker-neticrm-ci --filter "dangling=true" -q)
fi
# start container
docker run -d \
--name $CONTAINER_NAME \
-p $1:8080 \
-v /etc/localtime:/etc/localtime:ro \
-v $WORKDIR/container/init-$DRUPAL_VERSION.sh:/init.sh \
-v $MOUNT:/mnt/neticrm-7/civicrm \
-e "TZ=Asia/Taipei" \
-e "RUNPORT=8080" \
-e "DRUPAL_ROOT=/var/www/html" \
-e "CIVICRM_TEST_DSN=mysqli://root@localhost/neticrmci" \
-e "DRUPAL=$DRUPAL_VERSION" \
rg.netivism.com.tw/netivism/docker-neticrm-ci:$TAG_NAME
# install drupal
docker exec $CONTAINER_NAME /init.sh