diff --git a/docker-compose.yml b/docker-compose.yml index f5cda523..6f168ce0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -83,7 +83,7 @@ services: container_name: ogamex-phpmyadmin restart: always ports: - - 8080:80 + - "8080:80" environment: - PMA_ARBITRARY=1 - PMA_HOST=ogame-db diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 45b5e6e1..56ae574d 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,3 +1,5 @@ +#!/bin/bash + role=${CONTAINER_ROLE:-none} # Extract environment information @@ -9,45 +11,44 @@ fi # Configure Git to trust the working directory git config --global --add safe.directory /var/www -if [ "$role" = "scheduler" ]; then - while [ true ] - do - php /var/www/html/artisan schedule:run --verbose --no-interaction & - sleep 60 - done -elif [ "$role" = "app" ]; then - # Check APP_ENV and run appropriate composer install - if [ "$is_production" = true ]; then - echo "Production environment detected. Running composer install --no-dev..." - composer install --no-dev - else - echo "Development environment detected. Running composer install..." - composer install - fi - - # Generate APP_KEY if not set in the .env file - if grep -q "^APP_KEY=" .env; then - if [ -z "$(grep "^APP_KEY=" .env | cut -d '=' -f2)" ]; then +if [[ "$role" == "scheduler" ]]; then + while true; do + php /var/www/html/artisan schedule:run --verbose --no-interaction & + sleep 60 + done +elif [[ "$role" == "app" ]]; then + # Check APP_ENV and run appropriate composer install + if [[ "$is_production" == true ]]; then + echo "Production environment detected. Running composer install --no-dev..." + composer install --no-dev + else + echo "Development environment detected. Running composer install..." + composer install + fi + + # Generate APP_KEY if not set in the .env file + if grep -q "^APP_KEY=" .env; then + if [[ -z "$(grep "^APP_KEY=" .env | cut -d '=' -f2)" ]]; then echo "APP_KEY is empty. Generating a new key..." php artisan key:generate --force - else + else echo "APP_KEY already set. Skipping key generation." - fi - else - echo "APP_KEY not found in .env. Generating a new key..." - php artisan key:generate --force - fi + fi + else + echo "APP_KEY not found in .env. Generating a new key..." + php artisan key:generate --force + fi - # Run migrations - php artisan migrate --force + # Run migrations + php artisan migrate --force - # Only run caching in production - if [ "$is_production" = true ]; then - echo "Production environment: Caching configurations..." - php artisan cache:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache - fi + # Only run caching in production + if [[ "$is_production" == true ]]; then + echo "Production environment: Caching configurations..." + php artisan cache:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache + fi - exec "php-fpm" + exec php-fpm else echo "Could not match the container role \"$role\"" exit 1