Refactor: Move npm/composer setup to entrypoint script for proper volume handling
This commit is contained in:
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cd /var/www/app
|
||||
|
||||
# Set HOME for npm cache (www-data user needs writable cache directory)
|
||||
export HOME=/tmp
|
||||
|
||||
echo "Setting up dependencies..."
|
||||
|
||||
# Create vendor directories and fix permissions
|
||||
echo "Fixing permissions..."
|
||||
mkdir -p bootstrap/cache storage/framework storage/logs
|
||||
chown -R www-data:www-data bootstrap/cache storage/framework storage/logs
|
||||
chmod -R ug+rwX bootstrap/cache storage/framework storage/logs
|
||||
|
||||
# Install PHP dependencies
|
||||
echo "Installing PHP packages..."
|
||||
composer install \
|
||||
--no-dev \
|
||||
--prefer-dist \
|
||||
--no-interaction \
|
||||
--optimize-autoloader
|
||||
|
||||
# Install npm dependencies if package.json has dependencies
|
||||
if grep -q "\"dependencies\"" package.json; then
|
||||
echo "Installing npm packages..."
|
||||
npm ci --omit=dev
|
||||
fi
|
||||
|
||||
chmod -R ug+rwX bootstrap/cache
|
||||
|
||||
echo "✓ Setup complete, starting Apache..."
|
||||
exec apache2-foreground
|
||||
Reference in New Issue
Block a user