-
Notifications
You must be signed in to change notification settings - Fork 6
/
dbuild.sh
executable file
·56 lines (42 loc) · 1.31 KB
/
dbuild.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
#!/bin/bash
set -x
NETWORK=${5:-host}
TAG=${4:-2.2}
CONTAINER=${3:-filsender-test}
REPOSITORY=${2:-filesender-phpfpm}
ACTION=${1:-BUILD}
DAEMONIZE=-d
# Delete test container built from docker file
docker stop $CONTAINER
docker rm $CONTAINER
if [ "$ACTION" = "BUILD" ]; then
# Delete test image built from docker file
docker image rm $REPOSITORY:$TAG
# Create test image from docker file
docker build --rm -t $REPOSITORY:$TAG .
ACTION=DEBUG
fi
if [ "$ACTION" = "DEBUG" ]; then
DAEMONIZE=""
DEBUG="--user root -it --entrypoint /bin/bash"
fi
if [ "$ACTION" = "COMPOSE" ]; then
NETWORK=test_default
docker run --user root -it --entrypoint /bin/bash \
--net=$NETWORK \
--link db-host:test_db-host_1 \
-e DB_HOST="db-host" \
--tmpfs /var/log/php-fpm:uid=33,gid=33,mode=755,noexec,nodev,nosuid \
--tmpfs /run/lock:uid=0,gid=0,mode=1777,noexec,nodev \
--tmpfs /run/php:uid=33,gid=33,mode=775,noexec,nodev,nosuid \
--name $CONTAINER \
$REPOSITORY:$TAG
else
docker run $DAEMONIZE $DEBUG \
--net=$NETWORK \
--tmpfs /var/log/php-fpm:uid=33,gid=33,mode=755,noexec,nodev,nosuid \
--tmpfs /run/lock:uid=0,gid=0,mode=1777,noexec,nodev \
--tmpfs /run/php:uid=33,gid=33,mode=775,noexec,nodev,nosuid \
--name $CONTAINER \
$REPOSITORY:$TAG
fi