FROM php:8.1-fpm

RUN apt-get update && apt-get install -y --no-install-recommends \
        libpq-dev \
        libzip-dev \
        unzip \
        git \
    && docker-php-ext-install pdo pdo_pgsql pgsql zip \
    && rm -rf /var/lib/apt/lists/*

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR /var/www/html

COPY src/ /var/www/html/

RUN mkdir -p /var/www/html/service/permissions && chmod 777 /var/www/html/service/permissions

RUN if [ -f composer.json ]; then composer install --no-dev --no-interaction 2>/dev/null || true; fi

EXPOSE 9000

CMD ["php-fpm"]
