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 \ oniguruma-dev \ git \ curl \ 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 # 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 composer.lock ./ # 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 # Install PHP dependencies (this layer will be cached) RUN composer install --no-interaction --no-progress --no-scripts # 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 RUN rm -rf vendor && mv /vendor_clean 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"]