forked from webvariants/policat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-develop
executable file
·119 lines (103 loc) · 3.68 KB
/
docker-develop
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
if [ -z "$1" ]
then
echo "The 1st parameter must be a port number or hostname for policat webserver."
exit
fi
re='^[0-9]+$'
if [[ $1 =~ $re ]] ; then
POLICAT_RUN="--publish 127.0.0.1:$1:80 --label traefik.enable=false"
else
POLICAT_RUN="-e VIRTUAL_HOST=$1 -e VIRTUAL_PORT=80 -l traefik.port=80 -l traefik.frontend.rule=Host:$1 -l traefik.frontend.passHostHeader=true"
fi
if [ -z "$2" ]
then
echo "The 2nd parameter must be a port number or hostname for test mailserver."
exit
fi
re='^[0-9]+$'
if [[ $2 =~ $re ]] ; then
MAILDEV_RUN="--publish 127.0.0.1:$2:80 --label traefik.enable=false"
else
MAILDEV_RUN="-e VIRTUAL_HOST=$2 -e VIRTUAL_PORT=80 -l traefik.port=80 -l traefik.frontend.rule=Host:$2 -l traefik.frontend.passHostHeader=true"
fi
POLICAT_IMAGE=policat-develop
POLICAT_CONTAINER=policat-develop
MYSQL_CONTAINER=policat-develop-mysql
MEMCACHED_CONTAINER=policat-develop-memcached
MAILDEV_CONTAINER=policat-develop-maildev
set +e
docker build --pull --force-rm -t $POLICAT_IMAGE ./docker/php/
set +e
RUNNING=$(docker inspect --format="{{ .State.Running }}" $MYSQL_CONTAINER 2> /dev/null)
set -e
if [ "$RUNNING" == "" ]; then
docker run \
-d \
--name $MYSQL_CONTAINER \
-e "MYSQL_ROOT_PASSWORD=policat" \
--volume $PWD/docker/data-develop/mysql/:/var/lib/mysql \
--label traefik.enable=false \
mysql:5.6
fi
set +e
RUNNING=$(docker inspect --format="{{ .State.Running }}" $MEMCACHED_CONTAINER 2> /dev/null)
set -e
if [ "$RUNNING" == "" ]; then
docker run \
-d \
--name $MEMCACHED_CONTAINER \
--label traefik.enable=false \
memcached
fi
set +e
RUNNING=$(docker inspect --format="{{ .State.Running }}" $MAILDEV_CONTAINER 2> /dev/null)
set -e
if [ "$RUNNING" == "" ]; then
docker run \
-d \
--name $MAILDEV_CONTAINER \
$MAILDEV_RUN \
djfarrelly/maildev
fi
docker start $MYSQL_CONTAINER $MEMCACHED_CONTAINER $MAILDEV_CONTAINER
mkdir -p \
log \
cache \
docker/data-develop/data \
docker/data-develop/csv_uploads \
docker/data-develop/csv_downloads \
docker/data-develop/keyvisual \
docker/data-develop/pledge_header_visual \
docker/data-develop/pledge_key_visual \
docker/data-develop/store
docker run \
--rm \
-v "${PWD}/:/app/:ro" \
-v "${PWD}/docker/config-develop/data/:/app/data/" \
-v "${PWD}/data/fixtures/:/app/data/fixtures/:ro" \
-v "${PWD}/docker/config-develop/app.yml:/app/config/app.yml:ro" \
-v "${PWD}/docker/config-develop/databases.yml:/app/config/databases.yml:ro" \
-v "${PWD}/docker/config-develop/factories.yml:/app/config/factories.yml:ro" \
-v "${PWD}/docker/config-develop/properties.ini:/app/config/properties.ini:ro" \
-v "${PWD}/docker/data-develop/csv_uploads/:/app/data/csv_uploads" \
-v "${PWD}/docker/data-develop/csv_downloads/:/app/data/csv_downloads" \
-v "${PWD}/docker/data-develop/keyvisual/:/app/web/images/keyvisual" \
-v "${PWD}/docker/data-develop/pledge_header_visual/:/app/web/images/pledge_header_visual" \
-v "${PWD}/docker/data-develop/pledge_key_visual/:/app/web/images/pledge_key_visual" \
-v "${PWD}/docker/data-develop/store/:/app/web/images/store" \
--tmpfs /app/cache \
--tmpfs /app/log \
-e "WEB_ROOT=/app/web" \
-e "WWW_DATA_UID=${UID}" \
-e "WWW_DATA_GID=`id -g $USER`" \
--link "$MAILDEV_CONTAINER:mail" \
--link "$MEMCACHED_CONTAINER:memcached" \
--link "$MYSQL_CONTAINER:mysql" \
--name $POLICAT_CONTAINER \
$POLICAT_RUN \
$POLICAT_IMAGE
echo "Stopping side containers..."
docker stop $MYSQL_CONTAINER
docker stop -t 0 $MEMCACHED_CONTAINER $MAILDEV_CONTAINER
docker rm $MAILDEV_CONTAINER