docker: run composer install at build time instead of in the entrypoint
- Install dependencies in a cached layer (composer.json/lock only), then dump the optimized autoloader after copying the app - Entrypoint only runs composer install if vendor/ is missing (e.g. when the app directory is mounted as a volume) - Force LF for *.sh so the entrypoint works when built from a Windows checkout Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a11dca62a4
commit
2ddcb1b6b0
3 files changed
+23
-11
No files matched your search
+10
-7
@@ -14,13 +14,16 @@ 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
|
||||
|
||||
# Install PHP dependencies
|
||||
echo "Installing PHP packages..."
|
||||
composer install \
|
||||
--no-dev \
|
||||
--prefer-dist \
|
||||
--no-interaction \
|
||||
--optimize-autoloader
|
||||
# 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
|
||||
|
||||
# Install npm dependencies if package.json has dependencies
|
||||
if grep -q "\"dependencies\"" package.json; then
|
||||
|
||||
Reference in new issue
Block a user