-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
100 lines (76 loc) · 2.18 KB
/
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
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
#!/bin/sh
# Set the base directory for the app
BASEDIR=/var/www/webapp
# Remove Cache
rm -rf $BASEDIR/bootstrap/cache/*
# Flag to check if it's a fresh install
FIRST_INSTALL=false
# Check if the .env file exists
if [ ! -f "$BASEDIR/.env" ]; then
FIRST_INSTALL=true
fi
# Use FIRST_INSTALL variable as needed in the rest of your script
if [ "$FIRST_INSTALL" = true ]; then
echo "This is a FRESH INSTALL."
# Determine the appropriate environment file based on the PRODUCTION variable
if [ "$PRODUCTION" = "1" ]; then
ENV_FILE=".env.production"
else
ENV_FILE=".env.example"
fi
# Copy the chosen environment file to create the .env file
echo "Generating .env from a copy $ENV_FILE ..."
cp $ENV_FILE .env
echo "File .env generated."
fi
# Clear the old boostrap/cache
php artisan clear-compiled
# Install composer dependencies
if [ "$PRODUCTION" = "1" ]; then
composer install --no-dev --no-interaction --no-scripts
else
composer install --no-interaction --no-scripts
fi
# Run the migrations and seed the database
if [ "$FIRST_INSTALL" = true ]; then
php artisan migrate --seed --force
else
php artisan migrate --force
fi
echo "Generating app key..."
# Generate an application key
php artisan key:generate --force
echo "App key generated."
# Recreate database views
php artisan app:recreate-database-views
# Clear the optimization cache
php artisan optimize:clear
# Remove prior storage links that exist
rm -rf public/storage
# Build up a new storage link
php artisan storage:link
# Set the correct permissions
chmod -R ugo+rw storage
# Queue clear
php artisan queue:clear
# Optimize composer autoloader
composer dump-autoload --optimize
# Route cache
php artisan route:cache
# Install node dependencies
npm install
# Check if running in production or development mode
if [ "$PRODUCTION" = "1" ]; then
npm run build
echo "Running in production mode"
else
echo "Running in development mode"
fi
# Start supervisord
if [ "$PRODUCTION" = "1" ]; then
exec /usr/bin/supervisord -c /etc/supervisord.conf
echo "Supervisord started."
else
exec /usr/bin/supervisord -c /etc/supervisord-dev.conf
echo "Supervisord-dev started."
fi