-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.sh
More file actions
executable file
·61 lines (52 loc) · 1.78 KB
/
application.sh
File metadata and controls
executable file
·61 lines (52 loc) · 1.78 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
#!/bin/bash
set -e
#---------------------------------------------------------------------------
# env vars specific to .docker/application.sh
#---------------------------------------------------------------------------
# allows to enable / disable automatic database creation (doctrine:database:create)
DB_CREATE=${DB_CREATE:-0}
# allows to enable / disable automatic schema upgrade (doctrine:schema:update)
DB_UPGRADE=${DB_UPGRADE:-1}
# run (apache2) / backend / test
ACTION=${1:-run}
run(){
#---------------------------------------------------------------------------
# Ensure that database is created and schema is up to date.
#---------------------------------------------------------------------------
if [ "$DB_CREATE" = "1" ];
then
bin/console doctrine:database:create --if-not-exists
fi
if [ "$DB_UPGRADE" = "1" ];
then
bin/console doctrine:schema:update --force --complete
fi
#---------------------------------------------------------------------------
# start apache2 server
#---------------------------------------------------------------------------
exec apache2-foreground
}
backend(){
exec bash loop-validate.sh
}
archive(){
exec bash archive.sh
}
test(){
export APP_ENV=test
export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@database:5432/validator_api_test?serverVersion=15&charset=utf8"
bin/console --env=test doctrine:database:create --if-not-exists
bin/console --env=test doctrine:schema:update --complete --force
XDEBUG_MODE=coverage vendor/bin/phpunit
}
if [ $ACTION = "run" ]; then
run;
elif [ $ACTION = "backend" ]; then
backend;
elif [ $ACTION = "archive" ]; then
archive;
elif [ $ACTION = "test" ]; then
test;
else
echo "undefined action $ACTION"
fi