-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev
More file actions
executable file
·147 lines (122 loc) · 4.04 KB
/
dev
File metadata and controls
executable file
·147 lines (122 loc) · 4.04 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env bash
# Mac: Get host address
export XDEBUG_HOST=$(ipconfig getifaddr en0)
# Linux: Get host address
# Via: http://stackoverflow.com/questions/13322485/how-to-i-get-the-primary-ip-address-of-the-local-machine-on-linux-and-os-x
#export XDEBUG_HOST=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n1)
# Other env variables
export APP_ENV=${APP_ENV:-local}
export APP_PORT=${APP_PORT:-80}
export DB_PORT=${DB_PORT:-3306}
export DB_ROOT_PASS=${DB_ROOT_PASS:-root}
export DB_HOST=${DB_HOST:-db}
export DB_NAME=${DB_NAME:-api}
export DB_USER=${DB_USER:-root}
export DB_PASS=${DB_PASS:-root}
currentdir="$PWD"
# Decide which docker-compose file to use
COMPOSE_FILE="dev"
# Disable pseudo-TTY allocation for CI (Jenkins)
TTY=""
if [ ! -z "$BUILD_NUMBER" ]; then
COMPOSE_FILE="ci"
TTY="-T"
fi
COMPOSE="docker-compose -f docker-compose.$COMPOSE_FILE.yml"
if [ $# -gt 0 ];then
###############################################
# COMPOSER
#
# If "composer" is used, pass-thru to "composer"
# inside a new container
###############################################
if [ "$1" == "composer" ]; then
shift 1
$COMPOSE run --rm $TTY \
-w /var/www/html \
app \
composer "$@"
###############################################
# Database
#
###############################################
elif [ "$1" == "dbdestroy" ]; then
shift 1
echo "this will destroy and reinstall the datase. Are you sure? [y/N]"
read sure
if [ "$sure" != "y" ]; then
echo "cancelling on user request"
exit 1
fi
$0 exec db mysql -u root -proot -e "DROP DATABASE ${DB_NAME}"
$0 exec db mysql -u root -proot -e "CREATE DATABASE ${DB_NAME}"
$0 exec db mysql -u root -proot ${DB_NAME} < resources/schema.sql
$0 install
###############################################
# TAIL
#
# Tail the logfiles
###############################################
elif [ "$1" == "tail" ]; then
shift 1
tail -f storage/logs/*.log &
###############################################
# INSTALL
#
# For now: composer install && create database
###############################################
elif [ "$1" == "install" ]; then
shift 1
$COMPOSE exec db mysql -u $DB_USER -p$DB_PASS -e "CREATE DATABASE IF NOT EXISTS $DB_NAME"
$COMPOSE exec db mysql -u $DB_USER -p$DB_PASS $DB_NAME < resources/schema.sql
composer install
chmod -R 777 storage
###############################################
# SERVE
#
# Start the single-threaded internal PHP server
###############################################
elif [ "$1" == "serve" ]; then
shift 1
cd web
php -S 0.0.0.0:8000
###############################################
# TEST
#
# If "test" is used, run unit tests,
# pass-thru any extra arguments to php-unit
###############################################
elif [ "$1" == "test" ]; then
shift 1
cd tests/behat
# execute behat
echo $PWD
../../vendor/bin/behat "$@"
cd $currentdir
###############################################
# BASH SHELL IN CONTAINER: $ ./dev bash [app|db]
###############################################
elif [ "$1" == "bash" ]; then
container="$2"
if [ "$container" == "" ]; then
echo "ERROR: no container provided. Supply the container where you want the bash shell for as second argument";
$0
exit 1;
fi
shift 2
$COMPOSE exec $container bash
###############################################
# RESTART
###############################################
elif [ "$1" == "restart" ]; then
shift 1
$COMPOSE down && $COMPOSE up "$@"
###############################################
# ELSE
###############################################
else
$COMPOSE "$@"
fi
else
$COMPOSE ps
fi