FROM php:8.3-fpm

WORKDIR /var/www

# Install system dependencies and PHP extensions
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        git \
        unzip \
        zip \
        libzip-dev \
        sqlite3 \
        libsqlite3-dev \
        libonig-dev \
    && docker-php-ext-configure zip \
    && docker-php-ext-install -j$(nproc) pdo pdo_sqlite zip \
    && rm -rf /var/lib/apt/lists/*

# Install Composer from the official image
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

# Ensure www-data owns the working dir
RUN chown -R www-data:www-data /var/www || true

EXPOSE 9000

CMD ["php-fpm"]
