Refactor: Move npm/composer setup to entrypoint script for proper volume handling

This commit is contained in:
Mischa Spelt
2026-08-25 14:33:08 +02:00
parent 95cf933424
commit e070c9f374
3 changed files with 51 additions and 8 deletions
Executable → Regular
+13 -8
View File
@@ -1,5 +1,8 @@
FROM php:8.3-apache
# Install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
RUN apt-get update && apt-get install -y \
git \
curl \
@@ -43,12 +46,15 @@ RUN echo '<Directory /var/www/app/public>\n\
</Directory>' > /etc/apache2/conf-available/laravel.conf \
&& a2enconf laravel
# Copy app files (composer/npm setup happens at runtime via entrypoint)
COPY composer.json composer.lock ./
COPY package.json package-lock.json* ./
COPY scripts/ ./scripts/ 2>/dev/null || true
# Note: for Laravel, the COPY . . needs to be before the composer install
COPY . .
# Make sure the storage and cache directories exist and are writeable before running composer install
# Create storage directories
RUN mkdir -p \
storage/app \
storage/framework/cache/data \
@@ -56,13 +62,12 @@ RUN mkdir -p \
storage/framework/views \
storage/logs \
bootstrap/cache \
&& chown -R www-data:www-data storage bootstrap/cache \
&& chmod -R ug+rwX storage bootstrap/cache
public/assets/vendor
RUN composer install \
--no-dev \
--prefer-dist \
--no-interaction \
--optimize-autoloader
# Copy and set up entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 80