forked from shipping-docker/dockerized-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
develop
executable file
·86 lines (73 loc) · 2.19 KB
/
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
#!/usr/bin/env bash
# Mac: Get host address
export XDEBUG_HOST=$(ipconfig getifaddr en1)
# 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:-secret}
export DB_NAME=${DB_NAME:-helpspot}
export DB_USER=${DB_USER:-helpspot}
export DB_PASS=${DB_PASS:-secret}
# 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
if [ "$1" == "art" ]; then
shift 1
$COMPOSE run --rm $TTY \
-w /var/www/html \
app \
php artisan "$@"
# If "composer" is used, pass-thru to "composer"
# inside a new container
elif [ "$1" == "composer" ]; then
shift 1
$COMPOSE run --rm $TTY \
-w /var/www/html \
app \
composer "$@"
# If "test" is used, run unit tests,
# pass-thru any extra arguments to php-unit
elif [ "$1" == "test" ]; then
shift 1
$COMPOSE run --rm $TTY \
-w /var/www/html \
app \
./vendor/bin/phpunit "$@"
elif [ "$1" == "t" ]; then
shift 1
$COMPOSE exec \
app \
sh -c "cd /var/www/html && ./vendor/bin/phpunit $@"
# If "npm" is used, run npm
# from our node container
elif [ "$1" == "npm" ]; then
shift 1
$COMPOSE run --rm $TTY \
-w /var/www/html \
node \
npm "$@"
# If "gulp" is used, run gulp
# from our node container
elif [ "$1" == "gulp" ]; then
shift 1
$COMPOSE run --rm $TTY \
-w /var/www/html \
node \
./node_modules/.bin/gulp "$@"
else
$COMPOSE "$@"
fi
else
$COMPOSE ps
fi