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 \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) \ pdo_pgsql \ pgsql \ opcache \ zip \ bcmath \ gd \ exif \ pcntl # Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer WORKDIR /var/www/html # Copy composer files first (for dependency caching) COPY composer.json composer.lock* ./ # Install dependencies BEFORE copying application files RUN composer install --no-interaction --no-progress --optimize-autoloader # Copy the rest of the application files COPY --chown=www-data:www-data . . # Create necessary directories RUN mkdir -p storage/framework/{cache,sessions,views} \ && mkdir -p storage/logs \ && mkdir -p bootstrap/cache \ && chmod -R 775 storage \ && chmod -R 775 bootstrap/cache \ && chown -R www-data:www-data storage bootstrap # Generate application key RUN php artisan key:generate --no-interaction --force # Clear and cache configurations (optional) RUN php artisan config:clear && php artisan cache:clear || true # Copy entrypoint script COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh EXPOSE 8000 9000 ENTRYPOINT ["/entrypoint.sh"]