This repository has been archived by the owner on Aug 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-entrypoint.sh
69 lines (53 loc) · 2.58 KB
/
docker-entrypoint.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
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -eo pipefail
shopt -s nullglob
rm -rf .php_setup
if [ "$1" = 'php-fpm' ] || [ "$1" = 'php' ]; then
mkdir -p var/cache var/logs temp/
echo "parameters:" > app/config/parameters.yml
echo "parameters:" > app/config/parameters.yml.dist
while IFS='=' read -r envvar_key envvar_value
do
if [[ "$envvar_key" =~ ^[symfony]+\_[a-z]+ ]]
then
replaceWith=""
envvar_key=${envvar_key/symfony_/${replaceWith}}
if [ "$envvar_value" == "true" ] || [ "$envvar_value" == "false" ]
then
echo " $envvar_key: $envvar_value" >> app/config/parameters.yml
echo " $envvar_key: $envvar_value" >> app/config/parameters.yml.dist
else
echo " $envvar_key: '$envvar_value'" >> app/config/parameters.yml
echo " $envvar_key: '$envvar_value'" >> app/config/parameters.yml.dist
fi
fi
done < <(env)
if [ "$ISDEV" == "true" ]; then
composer install --optimize-autoloader --no-interaction || (echo >&2 "Composer Install Dev Failed" && exit 1)
else
composer install --optimize-autoloader --no-interaction --no-dev || (echo >&2 "Composer Install Prod Failed" && exit 1)
fi
php bin/console --env="$ENVIRONMENT" doctrine:migrations:migrate --no-interaction || (echo >&2 "Doctrine Migrations Failed" && exit 1)
php bin/console --env="$ENVIRONMENT" assets:install web || (echo >&2 "Assetic Install Failed" && exit 1)
if [ "$ISDEV" == "true" ]; then
php bin/console --env="$ENVIRONMENT" assetic:dump --no-interaction || (echo >&2 "Assetic Dump Dev Failed" && exit 1)
else
php bin/console --env="$ENVIRONMENT" assetic:dump --no-interaction --no-debug || (echo >&2 "Assetic Dump Prod Failed" && exit 1)
fi
if [ "$ISDEV" == "true" ]; then
php bin/console --env="$ENVIRONMENT" cache:warmup || (echo >&2 "Cache Warmup Dev Failed" && exit 1)
else
php bin/console --env="$ENVIRONMENT" cache:warmup --no-debug || (echo >&2 "Cache Warmup Prod Failed" && exit 1)
fi
if [ "$ISDEV" == "true" ]; then
#Save off the db dir number.
numdirs=$(ls -l "$DB_DIR" | grep -v ^d | wc -l | xargs)
echo "Number of db directories is $numdirs"
if [ $numdirs -le 2 ]; then
php bin/console --env="$ENVIRONMENT" doctrine:fixtures:load --no-interaction --multiple-transactions || (echo >&2 "Doctrine Fixtures Failed" && exit 1)
fi
fi
fi
chmod -R 777 var/cache
echo "1" > .php_setup
exec "$@"