Conversation
|
Help with docker-compose? |
Author
|
i can try! |
After trying several approaches, I found that this method works for now: You can still use Laravel Sail as usual, but with a slight modification to the #!/usr/bin/env bash
if [ "$SUPERVISOR_PHP_USER" != "root" ] && [ "$SUPERVISOR_PHP_USER" != "sail" ]; then
echo "You should set SUPERVISOR_PHP_USER to either 'sail' or 'root'."
exit 1
fi
if [ ! -z "$WWWUSER" ]; then
usermod -u $WWWUSER sail
fi
if [ ! -d /.composer ]; then
mkdir /.composer
fi
chmod -R ugo+rw /.composer
# Fix Git dubious ownership
git config --global --add safe.directory /var/www/html
git config --global --add safe.directory '*'
# Make sure we are in the correct directory
cd /var/www/html
# Always install dependencies before optimization
echo "Installing Composer dependencies..."
if [ "$SUPERVISOR_PHP_USER" = "root" ]; then
composer install --optimize-autoloader --no-dev --no-interaction
else
gosu $WWWUSER composer install --optimize-autoloader --no-dev --no-interaction
fi
# Check if vendor/autoload.php exists
if [ ! -f "/var/www/html/vendor/autoload.php" ]; then
echo "ERROR: vendor/autoload.php not found after composer install!"
echo "Trying composer install again..."
composer install --no-cache --optimize-autoloader --no-dev --no-interaction
fi
# Run production optimizations only if vendor exists
if [ -f "/var/www/html/vendor/autoload.php" ]; then
echo "Running production optimizations..."
# Wait for database to be ready
echo "Waiting for database connection..."
for i in {1..5}; do
if php artisan migrate:status > /dev/null 2>&1; then
echo "Database connection established."
break
fi
echo "Waiting for database... ($i/5)"
sleep 2
done
# Set permissions for writable folders
chmod -R 777 /var/www/html/storage 2>/dev/null || true
chmod -R 775 /var/www/html/bootstrap/cache 2>/dev/null || true
# Ensure required storage folders exist
mkdir -p /var/www/html/storage/framework/sessions 2>/dev/null || true
mkdir -p /var/www/html/storage/framework/views 2>/dev/null || true
mkdir -p /var/www/html/storage/framework/cache 2>/dev/null || true
mkdir -p /var/www/html/storage/logs 2>/dev/null || true
echo "Production optimizations completed."
else
echo "Skipping production optimizations (APP_ENV: $APP_ENV, vendor exists: $([ -f '/var/www/html/vendor/autoload.php' ] && echo 'yes' || echo 'no'))"
fi
if [ $# -gt 0 ]; then
if [ "$SUPERVISOR_PHP_USER" = "root" ]; then
exec "$@"
else
exec gosu $WWWUSER "$@"
fi
else
exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
fi |
|
I need to follow this PR, kudos Chris! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR for #3