FROM docker.io/php:8.4-fpm-alpine WORKDIR /var/www # We use the community repository to get pre-compiled PHP 8.4 extensions # This skips the source-code extraction that is causing your permission errors RUN apk add --no-cache \ php84-pecl-msgpack \ php84-pdo_mysql \ php84-mbstring \ php84-exif \ php84-pcntl \ php84-bcmath \ php84-gd \ php84-zip \ php84-intl \ icu-data-full # Symlink the extensions so PHP can find them (Alpine puts them in a different path) RUN ln -s /usr/lib/php84/modules/*.so /usr/local/lib/php/extensions/no-debug-non-zts-20240924/ # Get latest Composer COPY --from=docker.io/composer:latest /usr/bin/composer /usr/bin/composer # Copy application files COPY . /var/www # Permission fix: Use a single RUN to reduce layer complexity RUN chown -R www-data:www-data /var/www && \ chmod -R 775 /var/www/storage /var/www/bootstrap/cache USER www-data EXPOSE 8000 CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]