FROM php:8.2-fpm-alpine # Install system dependencies RUN apk add --no-cache \ vim \ xxd \ libzip-dev \ postgresql-dev \ libpng-dev \ libjpeg-turbo-dev \ freetype-dev \ libxml2-dev \ icu-dev \ oniguruma-dev \ git \ curl \ postgresql-client \ nodejs \ npm \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) \ pdo_pgsql \ pgsql \ opcache \ zip \ bcmath \ gd \ exif \ pcntl \ xml \ dom \ intl # Configure git to allow safe directory RUN git config --global --add safe.directory /var/www/html # Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer WORKDIR /var/www/html # Copy ONLY composer files first COPY composer.json ./ # Create storage and bootstrap directories needed for composer scripts RUN mkdir -p storage/framework/cache \ && mkdir -p storage/framework/sessions \ && mkdir -p storage/framework/views \ && mkdir -p storage/framework/testing \ && mkdir -p storage/logs \ && mkdir -p bootstrap/cache \ && chmod -R 777 storage \ && chmod -R 777 bootstrap/cache # Configure Composer for stability on unstable networks ENV COMPOSER_ALLOW_SUPERUSER=1 \ COMPOSER_MEMORY_LIMIT=-1 \ COMPOSER_PROCESS_TIMEOUT=2000 # Install PHP dependencies (this layer will be cached) RUN composer config -g repo.packagist composer https://packagist.org \ && composer install --no-interaction --no-progress --no-scripts --prefer-dist --ignore-platform-reqs # Isolate the clean vendor directory #RUN mv vendor /vendor_clean # Copy the rest of the application files (will ignore vendor because of .dockerignore) COPY --chown=www-data:www-data . . # Restore the clean vendor directory and set proper permissions #RUN rm -rf vendor && mv /vendor_clean vendor && chown -R www-data:www-data vendor # Final build verification RUN if [ ! -f vendor/laravel/prompts/src/helpers.php ]; then \ echo "ERROR: laravel/prompts/src/helpers.php missing!" && exit 1; \ fi # Final check and debug listing RUN ls -l vendor/laravel/prompts/src/helpers.php \ && du -sh vendor/laravel/prompts # Copy package files for NPM COPY package*.json ./ COPY vite.config.js ./ # Install NPM dependencies RUN npm install --legacy-peer-deps --no-audit # Build Vite assets RUN npm run build # Copy entrypoint script and ensure it's executable COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh # Let the entrypoint handle artisan commands at runtime EXPOSE 8000 9000 ENTRYPOINT ["/entrypoint.sh"]