forked from Connected-Places/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
develop
executable file
·115 lines (99 loc) · 3.31 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
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
#!/usr/bin/env bash
# Set the docker-compose files to use.
COMPOSE="docker compose"
# Set script scope environment variables to be used in testing
export APP_PORT=${APP_PORT:-80}
export DB_PORT=${DB_PORT:-3306}
export DB_ROOT_PASS=${DB_ROOT_PASSWORD:-secret}
export DB_DATABASE=${DB_DATABASE:-connected_places}
export DB_USERNAME=${DB_USERNAME:-connected_places}
export DB_PASSWORD=${DB_PASSWORD:-secret}
export ELASTICSEARCH_PORT=${ELASTICSEARCH_PORT:-9200}
export KIBANA_PORT=${KIBANA_PORT:-5601}
export CFN_TEMPLATE=${CFN_TEMPLATE:-cloudformation}
# Disable pseudo-TTY allocation for CI. The -T flag removes interaction.
TTY=""
# Travis CI provides a CI environment variable which can be used to check if
# this is running in a CI environment.
if [[ ${CI:-false} == "true" ]]; then
TTY="-T"
else
# Get the script directory
script_dir=`dirname $0`
# Set environment variables for dev
source $script_dir/.env
export WWWUID="$(id -u)"
fi
# Pass arguments to docker-compose, or default to docker-compose ps.
if [[ $# -gt 0 ]]; then
case "$1" in
# Run an artisan command inside a new container
art|artisan )
shift 1
${COMPOSE} run --rm ${TTY} \
-w /var/www/html \
-e WWWUID=${WWWUID} \
app \
php artisan "$@"
;;
# Open a shell inside a new container
bash )
shift 1
$COMPOSE run --rm ${TTY} \
-w /var/www/html \
-e WWWUID=${WWWUID} \
app \
bash "$@"
;;
# Run a composer command inside a new container
composer )
shift 1
${COMPOSE} run --rm ${TTY} \
-w /var/www/html \
-e WWWUID=${WWWUID} \
-e COMPOSER_MEMORY_LIMIT=-1 \
app \
composer "$@"
;;
# Run a node command inside a new container
npm )
shift 1
${COMPOSE} run --rm ${TTY} \
-w /var/www/html \
-e WWWUID=${WWWUID} \
node \
npm "$@"
;;
# Run PHPUnit tests inside a new container
test )
shift 1
$COMPOSE run --rm ${TTY} \
-w /var/www/html \
-e WWWUID=${WWWUID} \
app \
vendor/bin/phpunit "$@"
;;
# Run the Cloudformation generate command inside a new container
cfn|cloudformation )
${COMPOSE} run --rm troposphere > aws/${CFN_TEMPLATE}.json
cat aws/${CFN_TEMPLATE}.json
;;
# Manually work with objects in S3 buckets
store )
docker run --rm -it \
-v `pwd`:/var/www/html \
-w /var/www/html \
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-''} \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-''} \
-e AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-''} \
-e AWS_BUCKET_NAME=${AWS_BUCKET_NAME:-''} \
ubuntu:latest \
bash aws/store.sh
;;
# Run a docker-compose command
* ) ${COMPOSE} "$@"; ;;
esac
else
# Default; list the running containers
${COMPOSE} ps
fi