FROM php:8.4-apache

RUN apt update && \
    apt upgrade -y && \
    apt install -y \
    libzip-dev \
    unzip \
    libonig-dev \
    libxml2-dev \
    libpng-dev \
    libjpeg-dev \
    libicu-dev \
    libpq-dev \
    sqlite3 \
    curl \
    git \
    nano

RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-configure zip

RUN docker-php-ext-install \
    zip \
    mbstring \
    exif \
    pcntl \
    bcmath \
    xml \
    intl \
    pdo_mysql \
    pdo_pgsql

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
    php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
    php -r "unlink('composer-setup.php');"

RUN curl -sS https://get.symfony.com/cli/installer | bash && \
    mv /root/.symfony5/bin/symfony /usr/local/bin/symfony

COPY . /var/www/html/

RUN mv 000-default.conf /etc/apache2/sites-available/
RUN rm /var/www/html/.env*
RUN rm -rf /var/www/html/var/*
RUN rm -rf /var/www/html/vendor
RUN rm -rf /var/www/html/tests
RUN rm -rf /var/www/html/translations

RUN COMPOSER_ALLOW_SUPERUSER=1 composer install --no-scripts --no-dev --optimize-autoloader
RUN mkdir /data

RUN mkdir /var/www/html/var/cache
RUN mkdir /var/www/html/var/log

RUN chown -R 33:33 /var/www/html /data
RUN chmod -R 755 /var/www/html /data

EXPOSE 80
