FROM php:8.1-apache

ENV TZ=America/Sao_Paulo

RUN a2enmod rewrite

# Dependências + extensões PHP (sem Redis)
RUN apt-get update && apt-get install -y \
    libicu-dev \
    libzip-dev \
    libjpeg-dev \
    libpng-dev \
    libfreetype6-dev \
    unzip \
    git \
    zip \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install intl zip pdo pdo_mysql gd opcache \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini

WORKDIR /var/www/html

RUN echo "DirectoryIndex login.php index.php" > /etc/apache2/conf-available/directoryindex.conf \
    && a2enconf directoryindex

COPY app.zip /var/www/html/
RUN unzip -o app.zip -d /var/www/html && rm app.zip

RUN chown -R www-data:www-data /var/www/html

EXPOSE 80

#mkdir -p /var/www/html/painel/images/_notes
#mkdir -p /var/www/html/painel/images/perfil
#mkdir -p /var/www/html/painel/images/arquivos
#mkdir -p /var/www/html/painel/images/assinaturas
#mkdir -p /var/www/html/painel/images/contas
#mkdir -p /var/www/html/painel/images/marketing
#
#chown -R www-data:www-data /var/www/html/painel/images
#chmod -R 775 /var/www/html/painel/images

CMD ["apache2-foreground"]
