From 303e3a1c0ca597486bbd5a9e3287b8102d2572a0 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Fri, 21 Jun 2024 14:10:43 +0800 Subject: [PATCH] run.sh for automatic deployments --- run.sh | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/run.sh b/run.sh index f314f75..8c39ca0 100755 --- a/run.sh +++ b/run.sh @@ -1,22 +1,15 @@ #!/bin/sh -# Run setup only if .env file doesn't exist. -if [ ! -e .env.production ] -then -cat > .env.production << EOF -APP_NAME=MyIdlers -APP_DEBUG=false -APP_KEY= +# Load environment variables from .env.production +set -o allexport +source .env.production +set +o allexport -DB_CONNECTION=mysql -DB_HOST=${DB_HOST} -DB_DATABASE=${DB_DATABASE} -DB_USERNAME=${DB_USERNAME} -DB_PASSWORD=${DB_PASSWORD} -APP_URL=${APP_URL} -EOF -php artisan key:generate --no-interaction --force +# Check if the database file exists and is not empty +if [ ! -s $DB_DATABASE ] +then + touch $DB_DATABASE + php artisan migrate:fresh --seed --force fi -# php artisan migrate:fresh --seed -php artisan serve --host=0.0.0.0 --port=8000 --env=production +php artisan serve --host=0.0.0.0 --port=8000 --env=production \ No newline at end of file