Build and Deploy (dev) / build (push) Successful in 5m9s
- npm ci in a cached layer (package.json/lock only), setup-vendor.js after copying the app - Entrypoint only installs/copies when node_modules/ or public/assets/vendor is missing or empty (e.g. hidden by a volume) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.5 KiB
Bash
49 lines
1.5 KiB
Bash
#!/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 public/assets/vendor
|
|
chown -R www-data:www-data bootstrap/cache storage/framework storage/logs public/assets/vendor
|
|
chmod -R ug+rwX bootstrap/cache storage/framework storage/logs public/assets/vendor
|
|
|
|
# PHP dependencies are installed in the image. Only install them here as a
|
|
# fallback, e.g. when the app directory is mounted as a volume without vendor/.
|
|
if [ ! -f vendor/autoload.php ]; then
|
|
echo "vendor/ missing, installing PHP packages..."
|
|
composer install \
|
|
--no-dev \
|
|
--prefer-dist \
|
|
--no-interaction \
|
|
--optimize-autoloader
|
|
fi
|
|
|
|
# npm packages and public/assets/vendor are also built into the image. Only
|
|
# (re)create them here as a fallback, e.g. when they are hidden by a volume.
|
|
if [ ! -d node_modules ]; then
|
|
echo "node_modules/ missing, installing npm packages..."
|
|
npm ci --omit=dev --ignore-scripts
|
|
node scripts/setup-vendor.js
|
|
elif [ -z "$(ls -A public/assets/vendor 2>/dev/null)" ]; then
|
|
echo "public/assets/vendor is empty, copying npm packages..."
|
|
node scripts/setup-vendor.js
|
|
fi
|
|
|
|
# Fix permissions
|
|
echo "Fixing permissions..."
|
|
chown -R www-data:www-data \
|
|
bootstrap/cache \
|
|
public/assets/vendor
|
|
|
|
chmod -R ug+rwX bootstrap/cache
|
|
|
|
echo "✓ Setup complete, starting Apache..."
|
|
exec apache2-foreground
|