FROM php:8.4-apache

# Įjungiame Apache modulius
RUN a2enmod rewrite \
    && a2enmod headers \
    && a2enmod remoteip \
    && a2enmod deflate \
    && a2enmod ssl

# Įdiegiam sistemos priklausomybes
RUN set -xe \
    && apt-get update --fix-missing \
    && apt-get install -y --no-install-recommends \
        npm \
        zip \
        curl \
        cron \
        sudo \
        nano \
        unzip \
        supervisor \
        libzip-dev \
        libicu-dev \
        libbz2-dev \
        libpng-dev \
        libjpeg-dev \
        libfreetype6-dev \
        libonig-dev \
        g++ \
        -y git \
    && docker-php-ext-configure gd --with-freetype --with-jpeg

# Įdiegiam PHP extensions
RUN docker-php-ext-install \
    pdo \
    pdo_mysql \
    zip \
    intl \
    exif \
    gd \
    bcmath \
    mbstring

# Composer diegimas
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Nuimame default Apache config
RUN rm /etc/apache2/sites-enabled/000-default.conf

# Kopijuojame savo virtualhost config
COPY vhosts.conf /etc/apache2/sites-available/
RUN a2ensite vhosts

# PHP opcache konfig
COPY php/opcache.ini /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini

# Sertifikatai
COPY cert/localhost.crt /etc/apache2/cert/
COPY cert/localhost.key /etc/apache2/cert/

# Nustatome working dir
WORKDIR /var/www/html

# Nustatome www-data UID
RUN usermod -u 1000 www-data

# Supervisor config
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Xdebug, jei reikia (nebūtina prod)
# COPY php/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
