-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker_start.sh
47 lines (39 loc) · 1.15 KB
/
docker_start.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
#!/usr/bin/env bash
set -e
role=${CONTAINER_ROLE:-app}
env=${APP_ENV:-production}
migrate=${MIGRATE:-false}
seed=${SEED:-false}
if [ "$migrate" = "true" ]; then
echo "Migration..."
(cd /var/www && php artisan migrate --force)
fi
if [ "$seed" = "true" ]; then
echo "Seeding..."
(cd /var/www && php artisan db:seed && php artisan db:seed --class=Database\\Seeders\\Studies\\TestSeeder )
fi
#only the app container with production settings will set the cache (ideally in redis)
if [ "$env" = "production" ] && [ "$role" = "app" ]; then
echo "Caching configuration..."
(cd /var/www && php artisan config:cache && php artisan route:cache && php artisan view:cache)
#in case cache is in file
chmod -R 755 /var/www/storage/framework
fi
if [ "$role" = "app" ]; then
echo "App started"
php-fpm -D
nginx -g "daemon off;"
elif [ "$role" = "queue" ]; then
echo "Queue role"
supervisord
elif [ "$role" = "scheduler" ]; then
echo "Scheduler role"
while [ true ]
do
php artisan schedule:run --quiet --no-interaction &
sleep 60
done
else
echo "Could not match the container role \"$role\""
exit 1
fi