Skip to content

Commit

Permalink
mior adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
jackbayliss committed Dec 17, 2024
1 parent 09c0a9e commit e87b228
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ services:
container_name: ogamex-phpmyadmin
restart: always
ports:
- 8080:80
- "8080:80"
environment:
- PMA_ARBITRARY=1
- PMA_HOST=ogame-db
Expand Down
67 changes: 34 additions & 33 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

role=${CONTAINER_ROLE:-none}

# Extract environment information
Expand All @@ -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
Expand Down

0 comments on commit e87b228

Please sign in to comment.