From 7245f4cc694285607239896939024dad2f1afa1f Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Sat, 25 Jan 2025 21:53:55 -0600 Subject: [PATCH] wip --- docker/Dockerfile | 2 +- docker/entrypoint.sh | 41 +++++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2211f37..cd85345 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -57,4 +57,4 @@ HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhos # Run everything else ENTRYPOINT ["/bin/bash", "./docker/entrypoint.sh"] -CMD ["./docker/entrypoint.sh"] + diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index f5f2ebf..10698a1 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,52 +2,49 @@ cd /var/www/app -su - www-data -c " +echo -e "\n====================== Running entrypoint script... ====================== " -echo -e '\n====================== Running entrypoint script... ====================== ' +if [ ! -f ".env" ]; then + echo " > Ope, gotta create an .env file!" - -if [ ! -f '.env' ]; then - echo ' > Ope, gotta create an .env file!' - - [ -d '.env' ] && rm -rf .env + [ -d ".env" ] && rm -rf .env cp .env.example .env fi -echo -e '\n====================== Validating environment... ====================== ' -if [ $(stat -c '%U' .) != 'www-data' ]; then - echo ' > Setting correct permissions for application...' +echo -e "\n====================== Validating environment... ====================== " +if [ $(stat -c "%U" .) != "www-data" ]; then + echo " > Setting correct permissions for application..." chown -R www-data:www-data . fi -if ( ! grep -q '^APP_KEY=' '.env' || grep -q '^APP_KEY=$' '.env'); then - echo ' > Ah, APP_KEY is missing in .env file. Generating a new key!' +if ( ! grep -q "^APP_KEY=" ".env" || grep -q "^APP_KEY=$" ".env"); then + echo " > Ah, APP_KEY is missing in .env file. Generating a new key!" - /usr/local/bin/php artisan key:generate --force + su - www-data -c "/usr/local/bin/php artisan key:generate --force" fi -if [ ! -L 'public/storage' ]; then - echo ' > Creating symbolic link for app public storage...' +if [ ! -L "public/storage" ]; then + echo " > Creating symbolic link for app public storage..." - /usr/local/bin/php artisan storage:link + su - www-data -c "/usr/local/bin/php artisan storage:link" fi -echo -e '\n====================== Running migrations... ====================== ' +echo -e "\n====================== Running migrations... ====================== " run_migrations() { - /usr/local/bin/php artisan migrate --force + su - www-data -c "/usr/local/bin/php artisan migrate --force" } RETRIES=30 DELAY=5 until run_migrations; do RETRIES=$((RETRIES-1)) if [ $RETRIES -le 0 ]; then - echo ' > Database is not ready after multiple attempts. Exiting...' + echo " > Database is not ready after multiple attempts. Exiting..." exit 1 fi - echo ' > Waiting for database to be ready... retrying in $DELAY seconds.' + echo " > Waiting for database to be ready... retrying in $DELAY seconds." sleep $DELAY done -echo -e '\n====================== Spinning up Supervisor daemon... ====================== ' -exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf" \ No newline at end of file +echo -e "\n====================== Spinning up Supervisor daemon... ====================== " +exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf \ No newline at end of file